I have this code

\def\myformula{Area = side \times side \\ Perimeter = side \times 4}
        {One} & {Two} & \SetCell[c=2]{C}{\myformula} \\

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 \NewColumnTypeto 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 ?

  • 1
    Welcome to teX.SE!
    – Mensch
    Apr 24, 2022 at 19:04

1 Answer 1

  • Which version of \tabularray you use?
  • Your MWE (Minimal Working Example) contain many errors. From definition of myformula to number of defined columns ...
  • Syntax of 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.
  • I guess, that you looking for the following result:

enter image description here

With recent version of \tabularray (2022A) your MWE should be:


    \mathrm{Area} = \mathrm{side} \times \mathrm{side} \\ \mathrm{Perimeter} = \mathrm{side} \times 4

\begin{tblr}{colspec={cc X[c, m] X[c, m] },
One &   Two & \SetCell[c=2]{c,$$}{\myformula} 
                    &       \\

Edit: I cases, when you like to have aligned equations at = sign, you need to replace gathered with aligned environment (both are defined in amsmath package):

    \mathrm{Area}   & = \mathrm{side} \times \mathrm{side}
\mathrm{Perimeter}  & = \mathrm{side} \times 4

using above in suggested MWE gives the following result.

enter image description here

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.

  • thanks for the answer, this is what I found Package: tabularray 2022-03-01 v2022A Typeset tabulars and arrays with LaTeX3 , I'm also looking for a 2x2 table with the last row with both columns collapsed into 1. I would also like to aling the formulas according to the =equal sign and the classic &=doesn't work.
    – pafao
    Apr 24, 2022 at 20:23
  • @pafao, your question is not very clear, so answer is as it is (based on guessing. For aligning of equations you should use aligned environment `myformula definition. See edited answer (will appear soon).
    – Zarko
    Apr 24, 2022 at 20:37
  • What I meant was: a 2x2 table with 3 cells in total, first row with 2 cells, the second row with just 1 ( 2 columns collapsed into 1 ). Anyway thanks for the suggestions, any good links on where to find more docs about this ?
    – pafao
    Apr 24, 2022 at 20:52
  • @pafao, as I say, please ask new question (if you will stuck at writing it) , where you show what you tray so far. In above answer you have solid skeleton for design desired table :-).
    – Zarko
    Apr 24, 2022 at 20:58

You must log in to answer this question.

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