2

I am trying to use the cases construct within a table. I tried to follow this example. When I copy paste the entire example, it compiles without an error.

But when I try to reproduce it, I get immediately into trouble:

\documentclass{article}

\begin{document}

\begin{table}
\begin{tabular}{c}
\hline
\[ e \]    \\
\hline
\end{tabular}
\end{table}

\end{document}

Bad math environment delimiter [ e ].

What am I doing wrong?

1 Answer 1

1

The difference between your example and the one you refer to from how-to-add-equation-with-cases-inside-the-table is that you are trying to put a displayed equation into a "centred" table cell whereas the example puts one inside a "paragraph" in a tabular environment.

You either need to use a p-cell in your tabular environment:

\begin{tabular}{p{5cm}}
\hline
\[ e \]    \\
\hline
\end{tabular}

OR you can use a normal (centred) cell with in-line mathematics that you explicitly typeset in \displaystyle:

\begin{tabular}{c}
\hline
\(\displaystyle f(x)=\begin{cases}1,&\text{if }x=1,\\0,&\text{otherwise}\end{cases}\)
\hline
\end{tabular}

Of course, you could also leave the \displaystyle out here.

(Btw, here I am assuming that you have loaded the amsmath package for the \text command.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .