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

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
@Chris I think it depends on the pseudocode style you use. If you're not restricted, you can use it. – logo_writer Mar 3 at 0:58

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.