8

I run into trouble with this example.

\documentclass{article}
\usepackage{tabularray}
\begin{document}
        \begin{tblr}{ccc} \hline 
        m & mG & Weight \\ \hline 
        [0, 0, 0] & [0, 0, 0, 0] & 0 \\ \hline 
        [0, 0, 1] & [1, 0, 1, 1] & 3 \\ \hline 
        [0, 1, 0] & [0, 1, 0, 1] & 2 \\ \hline 
        [0, 1, 1] & [1, 1, 1, 0] & 3 \\ \hline 
        [1, 0, 0] & [1, 0, 0, 1] & 2 \\ \hline 
        [1, 0, 1] & [0, 0, 1, 0] & 1 \\ \hline 
        [1, 1, 0] & [1, 1, 0, 0] & 2 \\ \hline 
        [1, 1, 1] & [0, 1, 1, 1] & 3 \\ \hline 
    \end{tblr}
\end{document}

I get the error message "Illegal unit of measure(pt inserted)". I suspect that the square brackets used is the culprit, but I can't find a workaround in the documentation. The example compiles fine with round brackets instead of square brackets.

2 Answers2

10

tabulararray redefines \hline to take an optional argument (specifying the width of the rule that is inserted). With square brackets in the first column, you need to note that it's not part of the optional argument using something like \relax:

enter image description here

\documentclass{article}

\usepackage{tabularray}

\begin{document}

\begin{tblr}{ccc} \hline m & mG & Weight \ \hline\relax [0, 0, 0] & [0, 0, 0, 0] & 0 \ \hline\relax [0, 0, 1] & [1, 0, 1, 1] & 3 \ \hline\relax [0, 1, 0] & [0, 1, 0, 1] & 2 \ \hline\relax [0, 1, 1] & [1, 1, 1, 0] & 3 \ \hline\relax [1, 0, 0] & [1, 0, 0, 1] & 2 \ \hline\relax [1, 0, 1] & [0, 0, 1, 0] & 1 \ \hline\relax [1, 1, 0] & [1, 1, 0, 0] & 2 \ \hline\relax [1, 1, 1] & [0, 1, 1, 1] & 3 \ \hline \end{tblr}

\end{document}

Don't think there is a need for the multitude of \hlines:

enter image description here

\documentclass{article}

\usepackage{tabularray}

\begin{document}

\begin{tblr}{ccc} \hline[0.08em]% Similar to \toprule of booktabs m & mG & Weight \ \hline\relax [0, 0, 0] & [0, 0, 0, 0] & 0 \\relax [0, 0, 1] & [1, 0, 1, 1] & 3 \\relax [0, 1, 0] & [0, 1, 0, 1] & 2 \\relax [0, 1, 1] & [1, 1, 1, 0] & 3 \\relax [1, 0, 0] & [1, 0, 0, 1] & 2 \\relax [1, 0, 1] & [0, 0, 1, 0] & 1 \\relax [1, 1, 0] & [1, 1, 0, 0] & 2 \\relax [1, 1, 1] & [0, 1, 1, 1] & 3 \ \hline[0.08em] \end{tblr}

\end{document}

Werner
  • 603,163
2

Another simple solution is to put [] after \hline if the following row starts with [.

\documentclass{article}
\usepackage{tabularray}
\begin{document}
        \begin{tblr}{ccc} \hline 
        m & mG & Weight \\ \hline[] 
        [0, 0, 0] & [0, 0, 0, 0] & 0 \\ \hline[] 
        [0, 0, 1] & [1, 0, 1, 1] & 3 \\ \hline[] 
        [0, 1, 0] & [0, 1, 0, 1] & 2 \\ \hline[] 
        [0, 1, 1] & [1, 1, 1, 0] & 3 \\ \hline[] 
        [1, 0, 0] & [1, 0, 0, 1] & 2 \\ \hline[] 
        [1, 0, 1] & [0, 0, 1, 0] & 1 \\ \hline[] 
        [1, 1, 0] & [1, 1, 0, 0] & 2 \\ \hline[] 
        [1, 1, 1] & [0, 1, 1, 1] & 3 \\ \hline
    \end{tblr}
\end{document}

enter image description here

CarLaTeX
  • 62,716