I've been very impressed with xparse
and expl3
, and have written a wonderful document command using \ProcessList
that takes a comma separated list and turns it into a (basically) 1 column table.
\stacky{A,B,C,D}
-> \begin{tabular}{rr}
\tiny 1st & A \\
\tiny 2nd & B \\
\tiny 3rd & C \\
\tiny 4th & D
\end{tabular}
Now I've become mad with the power and want to specify more than one column at a time. Something like:
\stacksy{ 5: A,B,C,D ; 6: A,C,D,B ; 3: C,A,B,D }
-> \begin{tabular}{rrrr}
& 5 & 6 & 3 \\ \hline
\tiny 1st & A & A & C \\
\tiny 2nd & B & C & A \\
\tiny 3rd & C & D & B \\
\tiny 4th & D & B & D \\
\end{tabular}
Everything is fine, except that the input is in column-major order, but TeX (or the tabular environment) expects row-major order.
How do I transpose the input list of lists?
xparse
is about 'parsing' in the sense 'reading LaTeX2e command syntax' rather than 'parsing arbitrary input'.expl3
instead of ProcessList fromxparse
? Scott's solution is working very well, and I'll likely rewrite my single-stack version to use those ideas.\ProcessList
and the like can only take you so far: we've been asked before about extremely complex input, which is really beyond the scope ofxparse
. Currently, so are nested lists (indeed, I'd have to think hard about a suitable syntax!).