LaTeX cmd: Verbatim-like command '\checkboxYesNo' illegal in argument.
I get the above message when I tried to migrate away from using tabu & xstring combination to tabularray & native LaTeX3 combination for creating a requirements table. I use \checkboxYesNo to determine if the state of some checkboxes that are embedded into the table. This macro is embedded in a larger one, as it gets called 4 times per call to the larger one. I have attached a MWE with comments on what to comment out to make it work correctly. If I switch in the old \checkboxYesNoOld function, it will work with the new tabularray package.
I am not sure how to embed a macro inside a second one where inner macro makes decision based on the inputs being fed to it. I read through some of the other previous answers but I just cannot wrap my head around this issue.
\documentclass{article}
\usepackage{tikz}
\usepackage{tabu}
\usepackage{booktabs}
\usepackage{tabularray} % Replaces 'tabu', 'tabularx', & 'multirow'
\UseTblrLibrary{booktabs} % Used by 'tabularray' to load packages for internal use
\usepackage{xstring} % Needed for "checkboxYesNoOld" command
\newcommand{\checkYes}{%
\begin{tikzpicture}[scale=1, line width=1.0pt]%
\draw
( 0, 0) -- +
( 0, 1.5ex) -- +
( 1.5ex, 1.5ex) -- +
( 1.5ex, 0) --
cycle
( 0.3ex, 0.3ex) -- +
( 0.9ex, 0.9ex)
( 0.3ex, 1.2ex) -- +
( 0.9ex, -0.9ex);
\end{tikzpicture}%
}
% Creates Unchecked Checkbox
\newcommand{\checkNo}{%
\begin{tikzpicture}[scale=1, line width=1.0pt]%
\draw
( 0, 0) -- +
( 0, 1.5ex) -- +
( 1.5ex, 1.5ex) -- +
( 1.5ex, 0) --
cycle;
\end{tikzpicture}%
}
\ExplSyntaxOn
\NewDocumentCommand{\checkboxYesNo}{vv}
{
\prg_generate_conditional_variant:Nnn \str_if_in:nn {ee} { TF, T, F }
\str_if_in:eeTF { \str_foldcase:n { #2 } } { \str_foldcase:n { #1 } } {\checkYes} {\checkNo}
}
\ExplSyntaxOff
\newcommand{\checkboxYesNoOld}[2]{
%% #1--Find This; #2--Search This List
%% Outputs a Checked or Unchecked box
\lowercase{\def\myList{#2}}%
\lowercase{\def\findMe{#1}}%
\IfSubStr{\myList}{\findMe}{\checkYes}{\checkNo}%
% \IfSubStr{\myList}{\findMe}{Yes \findMe - \myList}{No \findMe - \myList}%
}
\newcommand{\reqUserOld}[6]{%
\begin{tabu} to 0.99\textwidth{p{60pt} *{3}{p{1pt} X[2,l] } p{1pt} X[3,l] }
\toprule
{\small \textbf{Req Name}} & \multicolumn{8}{l}{\textbf{#2}} \
\cmidrule(r){1-1} \cmidrule(l){2-9}
{\small Req ID} & \multicolumn{8}{l}{#1} \
\cmidrule(r){1-1} \cmidrule(l){2-9}
{\small Requirement} & \multicolumn{8}{l}{#3} \
\cmidrule(r){1-1} \cmidrule(l){2-9}
{\small Remarks} & \multicolumn{8}{l}{#4} \
\cmidrule(r){1-1} \cmidrule(l){2-9}
{\small Parent} & \multicolumn{8}{l}{#5} \
\cmidrule(r){1-1} \cmidrule(l){2-9}
{\small Verification} &
%%%% Use this for "correct" output
%{\small \checkYes} & {\small Test} &
%{\small \checkNo} & {\small Analysis} &
%{\small \checkNo} & {\small Inspection} &
%{\small \checkYes} & {\small Review-of-Design} \
%%%% This may cause a different error.
{\small \checkboxYesNoOld{t}{#6}} & {\small Test} &
{\small \checkboxYesNoOld{a}{#6}} & {\small Analysis} &
{\small \checkboxYesNoOld{i}{#6}} & {\small Inspection} &
{\small \checkboxYesNoOld{r}{#6}} & {\small Review-of-Design} \
\bottomrule
\tabuphantomline
\end{tabu}
}
\newcommand{\reqUser}[6]{%
\begin{tblr}{
width = 0.99\textwidth,
colspec = {t{60pt} *{3}{t{1pt} X[2,l] } t{1pt} X[3,l]}
}
\toprule
{\small \textbf{Req Name}} & \SetCell[r=1,c=8]{l}{\textbf{#2}} \\
\cmidrule[r]{1-1} \cmidrule[l]{2-9}
{\small Req ID} & \SetCell[r=1,c=8]{l}{#1} \\
\cmidrule[r]{1-1} \cmidrule[l]{2-9}
{\small Requirement} & \SetCell[r=1,c=8]{l}{#3} \\
\cmidrule[r]{1-1} \cmidrule[l]{2-9}
{\small Remarks} & \SetCell[r=1,c=8]{l}{#4} \\
\cmidrule[r]{1-1} \cmidrule[l]{2-9}
{\small Parent} & \SetCell[r=1,c=8]{l}{#5} \\
\cmidrule[r]{1-1} \cmidrule[l]{2-9}
{\small Verification} &
{\small \checkboxYesNoOld{t}{#6}} & {\small Test} &
{\small \checkboxYesNoOld{a}{#6}} & {\small Analysis} &
{\small \checkboxYesNoOld{i}{#6}} & {\small Inspection} &
{\small \checkboxYesNoOld{r}{#6}} & {\small Review-of-Design}
\bottomrule
\end{tblr} % ! So the \checkboxYesNo command is causing the table to be super tall
}
\begin{document}
% This produces the desired results under the old tabu/xstring system
\reqUserOld{M-03}{Req Name 3}{A description}{Some remarks}{The Parent Requirement}{tr}
%% Use this for "error" output (The verbatim command '\checkboxYesNo' cannot be used inside)
%\reqUser{M-03}{Req Name 3}{A description}{Some remarks}{The Parent Requirement}{tr}
\end{document}

expl3solution but using classical argument handling with your older one – Joseph Wright May 18 '22 at 12:55\prg_generate_conditional_variant:Nnnoutside of your macro definition. This doesn't need to run everytime you call your macro, just use it once in your preamble. And like other's already said, instead ofv vas argument specifier in your\NewDocumentCommand, usem minstead and everything should work as you expect. – Skillmon May 18 '22 at 14:55\small, it might be a good idea to use\smalloutside the table instead of in every cell (and if a single cell shouldn't be small you could use\normalsizethere). – Skillmon May 18 '22 at 14:57tikzpictures you could use\draw (0,0) rectangle (1.5ex, 1.5ex);instead of yourcycle-construct to draw the box. – Skillmon May 18 '22 at 15:02