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

Jonas
  • 1
  • tblr just doesn't support that, as you've already discovered. Stick with NewEnviron. – user202729 Aug 31 '22 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). – Ulrike Fischer Aug 31 '22 at 10:56
  • @user202729 I've already tried it with NewEnviron (by placing the \BODY there instead). Same error messages – Jonas Aug 31 '22 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 '22 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). – Ulrike Fischer Aug 31 '22 at 11:21
  • @UlrikeFischer Hm, I've tried the sample code in the documentation, but it seems like the tabularray version from 2021 isn't supported (I'm on texlive2019). I'd use tabular normally as well, but it doesn't look good on Adobe Reader and other PDF viewers, see my other question – Jonas Sep 01 '22 at 11:53

0 Answers0