I'm trying to expand in tabularry multiple macros to automatically add different background colors, but the color is not taken into account:
\documentclass{memoir}
\usepackage{tabularx}
\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\NewExpandableDocumentCommand{\yes}{O{Yes}m}{\SetCell{bg=green9} #1}
\NewExpandableDocumentCommand{\no}{O{No}m}{\SetCell{bg=red8} #1}
\begin{document}
\begin{tblr}[expand=\expandafter]{cc}
What I want & is below\
\SetCell{bg=green9} Yes & \SetCell{bg=red8} No\
\SetCell{bg=green9} Great & \SetCell{bg=red8} Bad\
What I get & is below\
\expandafter\empty\yes{} & \expandafter\empty\no{}\
\expandafter\empty\yes[Great]{} & \expandafter\empty\no[Bad]{}
\end{tblr}
\end{document}
Related, but don't fix my issue: tabulararray: can't use def to set cell properties? tabularray: Expand multiple macros




\empty\SetCell{bg=green9} Yesdoesn't work. – Ulrike Fischer Feb 15 '23 at 14:48