I'm trying to use \docsvlist from etoolbox to generate a table row. However, I've found a weird interaction when I try to use this trick to skip the first ampersand in the output. Here's an MWVE:
\documentclass{standalone}
\usepackage{etoolbox}
\begin{document}
\def\nextitem{\def\nextitem{&}}%
\renewcommand*{\do}[1]{\nextitem #1}%
\begin{tabular}{c|c|c|c|c}
\docsvlist{a,b,c,d,e}
\end{tabular}
\end{document}
When I compile this file, the table it produces looks like this:
I'd expect it to look more like this:
Interestingly, if I modify the separator to be something other than &, like ,, it works as would be expected:
And even more interestingly, if I change \def\nextitem{\def\nextitem{&}} to just \def\nextitem{&}, it works correctly, except that it has an extra blank cell at the beginning:
To me this suggests that there is some very specific problem with redefining \nextitem to & while inside the tabular environment. How can I fix this issue?





