7

It seems that \COMMENT in the algorithm package is broken. It gives an error when used in a FOR or FORALL line, so the first comment gives a compilation error:

\begin{algorithm}[ht]
  \caption{My algorithm}
  \begin{algorithmic}
   \FORALL{$p \in P$}   \COMMENT{loop over all puppies}
   \STATE PatPuppy($p$) \COMMENT{sooo nice!}
   \ENDFOR
  \end{algorithmic}
\end{algorithm}

The error is:

Something's wrong--perhaps a missing \item.
leading text:     \FORALL{$p \in P$}

Is there a workaround? I really need to display a comment on that line.

1
  • You've found the answer, OK. Next time you should make sure that you post everything that we need to reproduce the problem, including the preamble (like \documentclass{article}...\usepackage{...}).
    – topskip
    Commented Oct 6, 2010 at 15:59

2 Answers 2

6

The answer is given in the manual. Use an optional argument.

\FORALL[loop over all puppies]{$p \in P$}
0

Found the solution. The comment has to be embedded in the \FORALL:

\FORALL{$p \in P$ \COMMENT{loop over all puppies} }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .