Generating tables with \@for command
The error might be caused because of the special way &
are treated inside a tabular (actually in the internal used \halign
). The \@for
loop might be executed in a different column, read group, than the \authname
.
It would be saver if you collect the rows into a macro outside the tabular
first. This is quite easy with the etoolbox
package which is also able to loop over comma separated lists. You could also use its list-generating macro for \reportAuthors
. See its manual for more details.
\documentclass{article}
\newcommand{\reportAuthors}{Bob Jones,Sally Smith,Humpty Dumpty}
\usepackage{array}
\usepackage{etoolbox}
\begin{document}
\begingroup
\newcommand\tablecontent{}
\def\do#1{\appto\tablecontent{Approved by: & & #1 \\}}%
\expandafter\docsvlist\expandafter{\reportAuthors}
\begin{tabular}{|b{4cm}|b{6cm}|b{4cm}|}
\hline
\multicolumn{3}{l}{\begin{Large}\textbf{Signatures}\end{Large}} \\
\hline
\tablecontent
\end{tabular}
\endgroup
\end{document}
It's not necessary to construct the \tablecontent
first and then print it. Instead, you can use \docvslist
to add lines directly inside the tabular
environment:
\documentclass{article}
\usepackage{array}
\usepackage{etoolbox}
\usepackage{booktabs}
\newcommand\AuthorList[1]{%
\renewcommand*\do[1]{Approved by &&##1\\}
\begin{tabular}{|b{4cm}|b{6cm}|b{4cm}|}
\toprule
\multicolumn{3}{l}{\begin{Large}\textbf{Signatures}\end{Large}} \\
\midrule
\docsvlist{#1}
\bottomrule
\end{tabular}
}
\begin{document}
\AuthorList{Bob Jones,Sally Smith,Humpty Dumpty}
\end{document}
If you want to use a predefined list \reportAuthors
as in the question then you'll need
\expandafter\AuthorList\expandafter{\reportAuthors}
or use \expandafter\docsvlist\expandafter{#1}
in the definition of \AuthorList
.