I am working on a paper in double-column format, and I am using the algorithmic
package to typeset my algorithms. One of my while loops' condition is a bit long hence doesn't fit into the column.
When I try to split the condition into several lines, it is not properly indented, as in \WHILE{this is the first line which barely fits into the column \\ this is the second line
}.
I have also tried the following:
\WHILE{this is the first line which barely fits into the column \\
\hskip\algorithmicindent this is the second line}
However, it indents the second line of the condition only as much as the body of the WHILE
, it needs to be aligned with the first line of the loop condition. How can I achieve this?
MWE is as follows:
\documentclass[twocolumn]{article}
\usepackage{algorithmic}
\begin{document}
\begin{algorithmic}
\WHILE{There is an element which satisfies \\
\hskip\algorithmicindent properties which are long}
\STATE{while-body}
\ENDWHILE
\end{algorithmic}
\end{document}
Best Answer
The following MWE provides
\pushcode[<num>]
which indents your code<num>
indents (\algorithmicindent
) from the left margin. The default (since<num>
is optional) is1
indent. You could also "undent" your code by specifying a negative number (be careful that this might push code into the line numbers).