0

For some reason there's a conflict if I try to use tabularray in combination with macro + token.

\documentclass{article}

\usepackage{environ}
\usepackage{tabularray}

\newtoks\mynames
\NewEnviron{Names}{
    \global\mynames=\expandafter{\BODY}
}

\newcommand{\Name}[2]
{%
    #1 & #2 \\
}

\newenvironment{NameList}{
    \begin{tblr}{hlines, vlines, colspec = {XX}}
    First name & Surname \\
}{\end{tblr}}

\begin{Names}
    \Name{James}{McGil}
    \Name{Charles}{McGil}
\end{Names}

\begin{document}
    
    \begin{NameList}
        \the\mynames
%       James & McGil \\ % this works
%       Charles & McGil \\ % this works
    \end{NameList}

\end{document}

I get the following errors:

errors

This is how it should look like:

desired result

6
  • tblr just doesn't support that, as you've already discovered. Stick with NewEnviron.
    – user202729
    Aug 31, 2022 at 10:54
  • tabularray parses the content of the tabular body and so don't like if if you hide it inside commands. There are imho some options like execute which expand macros first, check the documentation (or use a normal tabular). Aug 31, 2022 at 10:56
  • @user202729 I've already tried it with NewEnviron (by placing the \BODY there instead). Same error messages
    – Jonas
    Aug 31, 2022 at 11:17
  • @UlrikeFischer Is that an option for newenvironment? I wasn't able to find it. Can you please clarify what you mean?
    – Jonas
    Aug 31, 2022 at 11:18
  • I meant check the documentation of tabularray, and the name of the option I had in mind is evaluate. (But I would use tabular normally). Aug 31, 2022 at 11:21

0

You must log in to answer this question.

Browse other questions tagged .