Sign up ×
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 writing some algorithms using the algorithmicx package.

I'm trying to create an if statement with an And boolean operator but using \And is causing an Undefined Control Sequence error


\If{$i < j+bandSize$ \And $j < i+bandSize$}
    \State $DTW_{i,j}\gets min(DTW_{i,j-1},DTW_{i-1,j},DTW_{i-1,j-1})+(f[i]-s[j])^2$

What's causing this?

share|improve this question

1 Answer 1

I did not find any \And in algpseudocode or algorithmicx, but you can easily add one:

share|improve this answer
Since \And is typically used as a parameterless macro almost like a binary relation in text, using \algnewcommand{\And}{\textbf{and}\xspace} seems a good idea (of course, including the xspace package). –  Werner Apr 5 '12 at 20:36
Is it OK in pseudocode to use the logical and operator instead? –  Chris Apr 6 '12 at 12:03

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.