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

I'm trying to specify an algorithm in pseudocode in a LaTeX document, but I'm having trouble with the for-Loop. My statement:

\for{$bin=0 to binCount$}
\item blablabla

keeps on generating the error "Undefined Control Sequence". I also tried the usual for-notation (bin=0;bin<binCount;bin++).
I have not defined any of the variables before, nor do I want to do that; I just want LaTeX to print exactly what I'm writing in an algorithm layout.

Is there a way to "switch off" this sort of code interpretation? What exactly am I doing wrong?

Add'l information: I have stated bot the algortihm and algorithm environment. Without this for-Loop, it generates the document without any errors. The \item statement is just a filler.

share|improve this question
i think you shuold be using \state instead of \item – phimuemue Oct 17 '11 at 13:58

Command names in LaTeX are case sensitive:

\FOR{$\mathit{bin}=0$ to $\mathit{binCount}$}

is what the documentation says (I added the \mathit around the multiletter variables, that renders better than writing $binCount$).

share|improve this answer
egregs solution (and example) is not working for me. I also added the package algpseudocode \usepackage{algorithmicx} \usepackage{algpseudocode} – Dennis Mar 26 '12 at 18:43

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.