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.

  • i think you shuold be using \state instead of \item
    – phimuemue
    Commented Oct 17, 2011 at 13:58

1 Answer 1


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$).

  • egregs solution (and example) is not working for me. I also added the package algpseudocode \usepackage{algorithmicx} \usepackage{algpseudocode}
    – Dennis
    Commented Mar 26, 2012 at 18:43

You must log in to answer this question.

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