TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

  \caption{My algorithm}
   \FORALL{$p \in P$}   \COMMENT{loop over all puppies}
   \STATE PatPuppy($p$) \COMMENT{sooo nice!}

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.

share|improve this question
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 Oct 6 '10 at 15:59
up vote 5 down vote accepted

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

\FORALL[loop over all puppies]{$p \in P$}
share|improve this answer

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

\FORALL{$p \in P$ \COMMENT{loop over all puppies} }
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.