I'm trying to learn the algorithmic package for typesetting pseudocode. One problem I'm running into is that I can't figure out how to insert blank lines, to separate blocks of code. The usual \\ or starting a new paragraph doesn't seem to work. How can I insert blank lines in in the algorithmic environment?
Asked
Active
Viewed 2.8k times
28
4 Answers
39
If you want the empty line to be numbered, just insert
\STATE
on this line.
If you want an unnumbered empty line, insert
\item[]
instead.
Andrey Vihrov
- 22,325
2
It’s a kludge, but you might be able to use
\renewcommand{\algorithmiccomment}[1]{}
\begin{algorithmic}
\STATE $x \leftarrow 1$
\COMMENT{}
\STATE $x \leftarrow 2$
\end{algorithmic}
bdesham
- 193
2
Just use \[\] instead of \\. Math formula is not numbered as a single line in algorithmicx.
Tyler Liu
- 21
-
-
Thank you. \begin{algorithm}\end{algorithm}. I tried that on algorithm and it works! – Avv Apr 05 '21 at 21:41
algorithmicxwhich provides a set of macros to extend packagealgorithmicand is more customizable than the latter). Usingalgorithmicx, a blank line can be produced by \State (numbered) or \Statex (unnumbered). – hengxin Oct 15 '13 at 03:01\STATEor\item[]before a\COMMENTline, then it doesn't work. I need to add it twice in order to see the same effect. – Agostino May 22 '15 at 00:47