I am trying to compile a simple cases example, but I'm having trouble with the tabular separator &. Here's my code:

    f(x) = 
        x + 1 & \mbox{blabla} \\
        x & \mbox{otherwise}

I am getting the following errors:

Misplaced alignment tab character &. x + 1 &

Misplaced alignment tab character &. x &

What could be wrong?

closed as too localized by cmhughes, Marco Daniel, percusse, clemens, Torbjørn T. Aug 27 '12 at 6:30

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 9
    Welcome to tex exchange! Are you loading the amsmath or mathtools package? The following MWE works for me \documentclass{article} \usepackage{amsmath} \begin{document} \begin{equation} f(x) = \begin{cases} x + 1 & \mbox{blabla} \ x & \mbox{otherwise} \end{cases} \end{equation} \end{document} – cmhughes Jul 23 '12 at 16:32
  • I'll also confirm that @cmhughes MWE works for me. When I remove \usepackage{amsmath}, I get the "Misplaced alignment tab character &." error that you mention. – Henry DeYoung Jul 23 '12 at 16:34
  • 8
    It's a known problem: for historical reasons, LaTeX has an undocumented \cases macro inherited from Plain TeX, which has a very different syntax than the cases environment provided by amsmath. – egreg Jul 23 '12 at 16:55
  • @egreg: Interesting. – Marco Daniel Jul 23 '12 at 17:15
  • Thank you for the answers! I had to load the amsmath package. I had just tried a couple of examples I found on the web which didn't mention the package. – erickrf Jul 23 '12 at 18:57

Short answer

The cases environment requires the amsmath package:


Long answer

For historical reasons, LaTeX defines a \cases macro: on page 232 of Lamport's manual one reads

Most Plain TeX commands can be used in LaTeX, but only with care.

and \cases is indeed a Plain TeX command which has quite a different syntax than the cases environment. It would be possible to use it without loading amsmath, but the features of this package are much better than the Plain TeX commands: more flexible and with a uniform syntax.

By the way, here's how one could input the equation with this method:

f(x) = 
  x + 1 & blabla \cr
  x & otherwise \cr

It's evident that the syntax is foreign to LaTeX: the second column is typeset in text mode and not math mode and the lines must be terminated by \cr. Most important, the alignment must go between braces: this is the main cause of the error.

Don't use it and stick to \usepackage{amsmath}.

Not the answer you're looking for? Browse other questions tagged or ask your own question.