# Errors with multicolumn-equations inside tabular (inside tcolorbox)

I try to rebuild a fairly complicated math-table, and I'm almost satisfied with the result. The MWE actually compiles to the table I want, but with error messages. When I include the table in my real (big) document, I get the error messages too, but in that case the document doesn't compile anymore.

I spent quite some time experimenting with and checking the $, but cannot find the error, and would be grateful for any tip. \documentclass[]{scrbook} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{latexsym} \usepackage{amsmath} \usepackage[listings,theorems]{tcolorbox} \tcbset{before={\par\medskip\pagebreak[0]\noindent},after={\par\medskip}}% \begin{document} \newcounter{texercise}[chapter] \begin{tcolorbox}[colback=blue!5,colframe=blue!50!black,arc=0mm, theorem={Algebra}{texercise}{(Vereinfachter) Datentyp 'Liste'}{myMarker}]{} \medskip \begin{tabular}{llll} \textbf{algebra} &$list_1$& & \\ \textbf{sorts} & \multicolumn{3}{l}{$list$,$elem$\{$bool$ist im folgenden immer implizit dabei\}} \\ \textbf{ops} &$empty$&$:$&$\to list$\\ &$first$&$:list$&$\to elem$\\ &$append$&$:list$&$\to list$\\ &$concat$&$:list \times elem$&$\to list$\\ &$isempty$&$:list \times list$&$\to bool$\\ \textbf{sets} &$list$& \multicolumn{2}{l}{$= \{ <a_1,\dots,a_n> \mid n \ge 0, a_i \in elem$\}}\\ \textbf{functions} & & & \\ &$empty$& \multicolumn{2}{l}{$ = \Diamond$}\\ & \multicolumn{3}{l}{ \begin{equation*}$first(a_1 \dots a_n) =$\begin{cases}$a_1$& \text{falls$n>0$} \\ undefiniert & \text{sonst} \end{cases} \end{equation*}} \\ \textbf{end}$list_1$& & & \\ \end{tabular} \end{tcolorbox} \end{document}  Here is the error message: ERROR: Missing$ inserted.

--- TeX said ---
<inserted text>
$l.36 \end{equation*}} \\ --- HELP --- TeX probably found a command that can be used only in math mode when it wasn't in math mode....  And here is the result: - ## 1 Answer There is no need for equation* in order to use the cases environment. Just use the following definition: %... & \multicolumn{3}{l}{%$first(a_1 \dots a_n) =
\begin{cases}
a_1 & \text{falls $n>0$} \\
\text{undefiniert} & \text{sonst}
\end{cases}$} \\ %...  In part, the problem was that you're using equation* and then initiating math mode using $...$. An equation* already initiates math mode, so the use of $ is not needed.

You may also wish to use \langle...\rangle instead of <...> for your list notation.

-
It took me a while to check that out, but if I follow your example exactly, both the MWE and the real document compile - thanks a lot. What caused a lot of confusion on my side was the fact, that the way you positioned the '$ resulted in a (completely) wrong fontification in my Emacs buffer, but it works. Putting more '$' in the formula restores the correct fontification, but results in LaTeX errors. – user17106 Dec 4 '12 at 22:11
@user17106: Yes, some editors rely on the use of explicit math environments or switches (like $) in order to display the correct syntax highlighting. Mixing these in odd locations (like an equation* environment inside a tabular`, say) causes the engine to not pick up on it properly, I guess. Perhaps advisable to submit a bug report to the editor programmers. It may be that the syntax parser has a number of exclusions in it for ad-hoc - yet completely appropriate in LaTeX terms - configurations. I don't know much about it, but have seen that in other editors. – Werner Dec 4 '12 at 22:20 Including the \begin{cases} and \end{cases} inside$...$doesn't seem right at first sight, and thus Emacs puts the whole part in math-font. But if I exclude the begin and end expressions by setting more$, there are LaTeX errors, strangely enough. But anyway, it works fine now, thanks. – user17106 Dec 4 '12 at 22:26