I have been searching on here for information about comma separated lists, but the only info I have found is how to sort, or iterate over a single list, which isn't quite what I need. If there is a relevant question somewhere I can't find, please feel free to link to it and close this.
What I am after is a way of merging several comma separated lists into a single tabular-type table to generate an answer key to several forms of a multiple choice section of an exam.
So, I would have something like the following:
\begin{document}
\magicFunction{
{A, b, b, a, a, b, b, c}% Test Form A, form is first entry.
}{
{B, a, b, c, c, e, a, a}% Test form B
}{
{C, c, c, c, a, a, b, c}% Test form C
}
\end{document}
Which I would want to expand into the following:
\begin{document}
\begin{tabular}{cccc}
\textbf{Problem Number} & \textbf{Form A} & \textbf{Form B} & \textbf{Form C} \\\hline\hline
1 & b & a & c \\
2 & b & b & c\\\hline
3 & a & c & c \\
4 & a & c & a \\\hline
5 & b & e & a \\
6 & b & a & b \\\hline
7 & c & a & c \\
\end{tabular}
\end{document}
The header info isn't hard to just program in, especially since I don't mind having different functions for each number of forms (ie a "2 form" function vs "3 forms" vs "4 forms"; 4 would be the most). The problem I'm having is figuring out how to place the correct answer forms in the correct places. If it were transposed so that I could just inject the entire line I could write the &
symbol in the list instead of using a comma-separated list, but for typesetting reasons it's better to have the answers listed vertically since most exams are more like 12-30 multiple choice problems. Moreover I would prefer the magicFunction
to be length-independent... meaning that each form will have the same number of answers (so the table will always be full) but any given test might have a different number of answers in it, so that can't be hard coded. I could pass the number of answers in as an argument to the function, but I don't know how to iterate over multiple comma-separated lists simultaneously rather than concatenating the process.
Any help would be hugely appreciated. I don't mind using LaTeX3, which is what I imagine would be the most succinct way to do this, but I'm still clumsy and heavy handed trying to get through parsing all the syntax and naming schemes in LaTeX3, so when I try anything with it myself and get errors I can't figure out what the errors are actually being generated by.
Thanks!