1

If I have pseudocode as shown below using the algorithm and algorithmic packages, is it possible to indent the pseudocode, including the line numbers, so that it lines up with the indentation of the first line of the paragraph above, i.e. so that the line numbers of the pseudocode are indented as much as the first line of the paragraph above.

enter image description here

1
  • Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Commented Sep 7, 2014 at 4:33

1 Answer 1

1

This is one possible solution via adjustwidth environment from changepage package. It takes two arguments.

As to the par indention value, please check HERE

\begin{adjustwidth}{left indent}{right indent}
\begin{algorithmic}[1]
content
\end{algorithmic}
\end{adjustwidth}

enter image description here

Code

\documentclass[12,a4paper]{article}
\usepackage[showframe,papersize={\paperwidth,8cm}]{geometry}
\pagestyle{empty}
\usepackage{algorithmic}
\usepackage[plain]{algorithm}
%\usepackage{algpseudocode}
\usepackage{changepage}    %adjustwidth environment from changepage package


\begin{document}

Paragraph text, Paragraph text, Paragraph text, Paragraph text, Paragraph text, Paragraph text, Paragraph text, Paragraph text,

\begin{algorithm}
\begin{adjustwidth}{1em}{}
\begin{algorithmic}[1]
\STATE{\textit{pollingDateTime $\leftarrow$ now $-$ 1 hour}}
\FOR {\textbf{each} rssFeed}
\STATE {\textit{pollingDateTime $\leftarrow$ now $-$ 1 hour}}
\ENDFOR 
\IF {\textit{pollingDateTime is even}}
\STATE {\textit{pollingDateTime $\leftarrow$ now $-$ 1 hour}}
\ENDIF
\end{algorithmic}
\caption{Algorithm 1}\label{alg1}
\end{adjustwidth}
\end{algorithm}
\end{document}
1
  • @MrMorgan, glad it helps. Commented Sep 7, 2014 at 12:40

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.