3

I was following a Wikibooks section to create multiple lines within a single large bracket. Something like this.

The problem is that when I type in the given code, which is

\[
 u(x) =
  \begin{cases}
   \exp{x} & \text{if } x \geq 0 \\
   1       & \text{if } x < 0
  \end{cases}
\]

I get the following error in my document:

Misplaced alignment tab character &.

Any idea what might be going wrong?

  • 2
    You probably don't have \usepackage{amsmath} – egreg Jul 16 '13 at 8:34
  • 1
    include a MWE and you might get help – bene Jul 16 '13 at 8:58
  • 1
    @egreg: Thanks, it was the missing amsmath package only! But that's not fair; why didn't I get a "not found" error in that case? – ankush981 Jul 16 '13 at 10:30
  • 2
    @dotslash Unfortunately, the first version of LaTeX copied the \cases macro from Plain TeX and it's still there for backwards compatibility. So LaTeX doesn't balk when finding \begin{cases} because this means doing \cases; but the syntax of the Plain TeX \cases is very different (and foreign to LaTeX), so the weird error messages. – egreg Jul 16 '13 at 10:37
  • 1
    Amazing info! What, then, is the native LaTeX syntax for \cases? – ankush981 Jul 16 '13 at 15:48
3

The LaTeX kernel provides a \cases command that's literally copied from Plain TeX. This is a remnant from the olden days and it is the reason why

\begin{cases}
...
\end{cases}

without loading amsmath doesn't raise the Environment cases undefined error.

The syntax for \cases is really foreign to LaTeX; it must be used in math mode (inline or display) as

\cases{
   \exp{x} & if $x \geq 0$ \cr
   1       & if $x < 0$    \cr
}

Notice \cr for terminating the row, where \\ wouldn't work; note also that the second column is typeset in text mode, differently from the cases environment of amsmath.

It's surely better to load amsmath (which also provides \text) and input your equation as

\usepackage{amsmath}

...

\[
 u(x) =
  \begin{cases}
   \exp{x} & \text{if $x \geq 0$} \\
   1       & \text{if $x < 0$}
  \end{cases}
\]

I always recommend reentering math mode without closing \text; it's more practical.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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