8

I am using a command that contains more than one cell (containing an & to separate them).

It worked with tabular it does not work with tbrl though. Why?

\documentclass{article}

\usepackage{tabularray}
\newcommand{\ab}{a & b}

\begin{document}
    \begin{tblr}{c|l}
        \ab \\
    \end{tblr}
\end{document}

The error message is misplaced alignment tab character &

1 Answer 1

8

Use the argument expand in the table specification:

\documentclass{article}

\usepackage{tabularray}
\newcommand{\ab}{a & b}

\begin{document}
    \begin{tblr}[expand=\ab]{c|l}
        \ab \\
    \end{tblr}
\end{document}

enter image description here

More information on this can be found in the docs p. 30, the reasoning is:

In contrast to traditional tabular environment, tabularray environments need to see every & and \ when splitting the table body with l3regex. And you can not put cell text inside any table command defined with \NewTableCommand. But you could use outer key expand to make tabularray expand every occurrence of a specified macro once before splitting the table body. Note that you can not expand a command defined with \NewDocumentCommand

You must log in to answer this question.

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