I have this code
\documentclass{report}
\usepackage{tabularray}
\usepackage{mathtools}
\NewColumnType{C}{>{$}c<{$}}
\def\myformula{Area = side \times side \\ Perimeter = side \times 4}
\begin{document}
\begin{tblr}{
colspec={cX},
row{2}={C,fg=white,bg=black}
}
{One} & {Two} & \SetCell[c=2]{C}{\myformula} \\
\end{tblr}
\end{document}
This code doesn't compile, the most relevant error during compilation ( reported on row 12 ) is:
Missing $ inserted. \end
I understand that using a math environment inside a tabular one is more complicated than usual, for this reason I tried to use \NewColumnType
to make my life easier but apparently I'm missing something and I already tried a lot of variations.
What I'm missing ? Something to do with how Latex3 works ?
Best Answer
\tabularray
you use?myformula
to number of defined columns ...tabularray
package differ from syntax of "classic" packages for tables. For example, it define option for math mode of columns. For details see package documentation.With recent version of
\tabularray
(2022A) your MWE should be:Edit: I cases, when you like to have aligned equations at
=
sign, you need to replacegathered
withaligned
environment (both are defined inamsmath
package):using above in suggested MWE gives the following result.
If you still have some open problems, I suggest you to ask new question where clearly (maybe with link to this) where clearly explain what is your problem.