1

Consider the following MWE:

\documentclass{article}
\usepackage{mathtools}
\begin{document}
    \begin{equation}
        \label{eq:cond}
        \begin{rcases*}
            % this fails
            % x,& foo \in bar \\
            % y,& baz \in baq
            % this works
            x,& foo bar \\
            y,& baz baq
        \end{rcases*} t\in[0,\infty)
    \end{equation}
\end{document}

Somehow, adding \in causes a missing $ inserted type of error. Any ideas why, how to work around it?

Pouya
  • 7,269
  • 3
    In the starred <x>cases* environments the second column is a text column and not a math column. Either use the unstarred rcases if you want the second column to be in math mode or switch to math mode with $...$ โ€“ moewe Aug 30 '18 at 10:04
  • @moewe Thank you. Then how is it that this works? โ€“ Pouya Aug 30 '18 at 10:07
  • As I said the second column is in text mode, foo and barbaz are totally benign in text mode and won't raise an error. You can clearly see that they are in text mode though, when you look at the output: They are written in upright and not in math italics. โ€“ moewe Aug 30 '18 at 10:09

1 Answers1

3

The second column of a starred cases*-like environment defined by mathtools is in text mode and not in math mode (as the unstarred cases ones are). See ยง3.4.3 More cases -like environments, pp. 18-19 of the mathtools documentation.

That means that

\documentclass{article}
\usepackage{mathtools}
\begin{document}
  \begin{align}
    (-1)^n&=
    \begin{cases*}
      -1,& if $n$ is odd \\
      1,& otherwise
    \end{cases*}\\
    &=
    \begin{cases}
      -1,& n \in \{\dots, -3, -1, 1, 3, \dots\} \\
      1,& n \in \{\dots -4, -2, 0, 2, 4, \dots\}
    \end{cases}
  \end{align}
\end{document}

displays as

output of MWE

With the second column of the first cases* in text mode (no command is needed to make sure the text is typeset as text and not math) and the second column of cases in math mode (no error from \in and friends).

The difference is clear also in

\documentclass{article}
\usepackage{mathtools}
\begin{document}
  \begin{align}
    (-1)^n&=
    \begin{cases*}
      -1,& if $n$ is odd \\
      1,& otherwise
    \end{cases*}\\
    &=
    % don't do this!
    \begin{cases}
      -1,& if $n$ is odd \\
      1,& otherwise
    \end{cases}
  \end{align}
\end{document}

output of the second example. The second column in the second lines is wrongly  displayed in math mode

moewe
  • 175,683