# Tabularray and bracket in cell

I try to use the tabularray package but I have a error with brackets :

\documentclass{article}
\usepackage{tabularray}
\begin{document}

\begin{tblr}{cells={mode=math}}
1      &   2   \\
[1;2]  & [3;4] \\
\end{tblr}

\end{document}


I find a solution without mode math, but it's not very satisfactory :

\documentclass{article}
\usepackage{tabularray}
\begin{document}

\begin{tblr}{}
$1$        &   $2$    \\
$[1;2]$    &  $[3;4]$ \\
\end{tblr}

\end{document}


The exercise I'm trying to do is here and it works without math mode :

\begin{tblr}{
hlines,vlines,
colspec={ccQ[c,7em]Q[c,7em]},
}
$I$ & $J$  &  $I \cap J$ &  $I \cup J$ \\
$[3;6]$ & $[4,2;7,1]$ &  &  \\
$[-4;6]$ & $]2;+\infty[$ & & \\
$]-\infty;1]$ & $]0;+\infty[$ & & \\
$[-2;8]$ & $[1;3]$ & & \\
$[-3;1]$ & $[2;4]$ & &
\end{tblr}

• Can you please add some context to your question: do you want to show a certain kind of mathematical matrix? Or: what is this table about to show or teach about? Commented Sep 29, 2023 at 7:43
• @MP-SPO It is an exercise with a table to complete on the union and intersection of intervals but i give a MWE. Commented Sep 29, 2023 at 7:49
• Hm, still puzzling. Can you add the exercises text to your question, e.g. as screenshot? I.e. an interval for me is a mathematical object, so using math-mode would be a natural choice, if not a must ... Commented Sep 29, 2023 at 7:52
• @MP-SPO I put the exercice in the question. Commented Sep 29, 2023 at 8:07
• Thanks for clarifying. Are you restricted to use a certain table like tblr, or can use whatever you want? Commented Sep 29, 2023 at 8:54

It's a known problem with (almost) all alignment environments: since \\ accepts an optional argument for specifying a vertical separation and ignores spaces when looking for the possible [, your bracket is mistaken for the start of an optional argument.

Math mode or not, it's irrelevant. In your second case, the \$ avoids the [ to be mistaken. But the error would happen also in text mode.

Add \relax before a bracket starting a table cell.

\documentclass{article}
\usepackage{tabularray}
\begin{document}

\begin{tblr}{cells={mode=math}}
1      &   2   \\ \relax
[1;2]  & [3;4] \\
\end{tblr}

\end{document}


• Thanks, now I understand why it was a dimension error Commented Sep 29, 2023 at 9:18