# xcolor breaking and align environments inside tabu I'm having trouble with a "Bad math environment delimiter" when using certain math environments inside tabu. Minimal example: \documentclass[a4paper,12pt]{scrreprt} \usepackage{xcolor} \usepackage{tabu} \begin{document} \begin{table}[h!] \begin{tabu}{ X } \[ b
\end{tabu}
\end{table}
\end{document}


This error only shows when xcolor is loaded and also appears when is replaced with an equation, align, or gather environment, but not when using . The above example used to work a year ago and the error appeared recently after updating MikTex and all packages. • you should consider that tabu is not maintained, so it not respond on recent changes in many of packages. for example in array and it seems that in xcolor too. – Zarko Jan 9 at 2:37 • @Zarko I don't think any change in xcolor is responsible for this, it all comes from change in array. – user4686 Jan 9 at 13:36 ## 1 Answer # UPDATE 2019-01-14 An equivalent patch has been applied in tabu 2.9 which has been submitted to ctan. ## This is not a full solution, only a first try!!! At some place in the code tabu checks the "current group type" (What combinations of mode and \currentgrouptype exist?). The problem is that array added an additional "color group" to p-columns to avoid that colors leaks out. This color group is active if a color package is used. When tabu tests the current group type it now gets a different answer then previously and so takes the wrong code path. One possibility to get around the problem is to save the currentgrouptype before the color group and to use this value in the tabu code. Attention I suspect that more places will need adjustments. \documentclass{article} \usepackage{color,array,longtable} %Save the currentgrouptype before the color@begingroup: \makeatletter \newcount\array@currentgrouptype \def\@startpbox#1{\bgroup \array@currentgrouptype\currentgrouptype \color@begingroup \setlength\hsize{#1}\@arrayparboxrestore \everypar{% \vrule \@height \ht\@arstrutbox \@width \z@ \everypar{}}% } \makeatother \usepackage{tabu} \makeatletter %Use the new \array@currentgrouptype \def\tabu@verticalmeasure{\everypar{}% %\showthe\currentgrouptype %14 in tl18, 5 in tl17 \ifnum \array@currentgrouptype>12 % \setbox\tabu@box =\hbox\bgroup \let\tabu@verticalspacing \tabu@verticalsp@lcr \d@llarbegin % after \hbox ... \else \edef\tabu@temp{\ifnum\array@currentgrouptype=5\vtop \else\ifnum\array@currentgrouptype=12\vcenter \else\vbox\fi\fi}% \setbox\tabu@box \hbox\bgroup\tabu@temp \bgroup \let\tabu@verticalspacing \tabu@verticalsp@pmb \fi }% \tabu@verticalmeasure \usepackage{etoolbox} \patchcmd\tabu@startpboxmeasure {\aftergroup\tabu@endpboxmeasure} {\aftergroup\tabu@endpboxmeasure \color@begingroup }{\typeout{tabu patched}}{\typeout{tabu patch failed!}} \patchcmd\tabu@LT@startpbox {\bgroup}{\bgroup\color@begingroup} {\typeout{tabu patched}}{\typeout{tabu patch failed!}} \makeatletter \begin{document} \begin{tabu}{X} \[ b
\end{tabu}

\begin{longtabu}{X}
$b$
\end{longtabu}

\end{document}