I have a command that needs more than 9 arguments. I stumbled over this solution: How to define a command that takes more than 9 arguments. This works fine in regular text. But I tried using this within a tabular environment, but then I get undefined control sequence errors. Here is a MWE:
\documentclass{article}
\begin{document}
\newcommand*\foo[9]{%
\def\tempa{#1}%
\def\tempb{#2}%
\def\tempc{#3}%
\def\tempd{#4}%
\def\tempe{#5}%
\def\tempf{#6}%
\def\tempg{#7}%
\def\temph{#8}%
\def\tempi{#9}%
\foocont
}
\newcommand\foocont[1]{\tempa & \tempb & \tempc & \tempd & \tempe & \tempf & \tempg & \temph & \tempi & #1 \cr}
\begin{tabular}{*{10}c}
\foo{1}{2}{3}{4}{5}{6}{7}{8}{9}{a}
\end{tabular}
\end{document}
If you remove all &, the \cr and the tabular environment, and just call \foo with 10 arguments the code compiles just fine (printing out 123456789a).
How can I make this "argument extension" work together with tabular?


\gdefor\xdefbut I doubt this is a very good way – Jul 03 '15 at 14:27\foo{1,2,3,4,5,6,7,8,9,a,b,c,d}? – David Carlisle Jul 03 '15 at 14:31