Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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
\endfor

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
add comment

1 Answer

Command names in LaTeX are case sensitive:

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

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
add comment

Your Answer

 
discard

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.