0

So, I want to display cases inside a table. This is my Latex document, as minimized as I could to reproduce the problem. Apparently, it says:

(./redundant.aux)
! Missing $ inserted.
<inserted text> 
                $
l.12 \begin{cases}

I don't get it. The cases environment works totally fine outside tables. What's wrong with my Latex code and how do I fix it?

\documentclass[11pt, fullpage, lefteqn]{article} 
\usepackage{amsmath}

\begin{document}
\begin{table}[h!]
\centering
\begin{tabular}{|c|c|}
 \hline
  $a^2 - x^2$
            & 
\[
\begin{cases}
a \sin x \\ a \cos x
\end{cases}
\] & \\
\end{tabular}
\end{table}
\end{document}

Edit: when I try to change the cs to ps, I get

! Missing number, treated as zero.
<to be read again> 
                   |
l.9   $
       a^2 - x^2$


3
  • c columns are single line like \mbox and can not have display constructs, use a p column such as p{5cm} which is like \parbox and can have vertical display material like \[ – David Carlisle Jan 22 at 23:55
  • @DavidCarlisle When I try to change the cs to ps, it says "Missing number, treated as zero." – new QOpenGLWidget Jan 23 at 0:01
  • you need a width eg p{5cm} as I showed – David Carlisle Jan 23 at 0:08
1

Vertical display material like \[ needs to be in a par (vertical) mode column such as p or m

\documentclass[11pt, 
%fullpage, % article does not have fullpage or lefteqnoptions
%lefteqn
leqno
]{article} 
\usepackage{amsmath}
\usepackage{array}% for m

\begin{document}
\begin{table}[htp] % [h!]
\centering
\begin{tabular}{|c|m{5cm}|}
 \hline
  $a^2 - x^2$
            & 
\[
\begin{cases}
a \sin x \\ a \cos x
\end{cases}
\] \\
\hline
\end{tabular}
\end{table}
\end{document}

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.