# Create Table from Template with Variable Number of Arguments

I would like to create the following table in LaTeX:

\begin{table}[h]\centering
\begin{tabular}{|c|c|c|}\hline
Problem & Score & Max \\ \hline
5B       &       &     \\ \hline
5I       &       &     \\ \hline
5J       &       &     \\ \hline
5K       &       &     \\ \hline
5L       &       &     \\ \hline
Total   &       &     \\ \hline
\end{tabular}
\end{table}


In this example, I have the assigned problems 5B, 5I, etc, but I would like to create a command that takes in a variable number of questions as arguments, i.e. something like

\tableofproblems{5B,5I,5J,5K,5L}


or

\tableofproblems{5B}{5I}{5J}{5K}{5L}


preferably the first one. Is this possible? I would like to be able to call this command to create tables with 2 problems, 7 problems, etc.

\documentclass{article}
\usepackage{array}

\ExplSyntaxOn
\NewDocumentCommand \tableofproblems { m }
{
\begin{tabular}{|c|c|c|}\hline
Problem & Score & Max \\ \hline
\clist_map_inline:nn { #1 }
{ ##1 & & \\ \hline }
Total &  & \\ \hline
\end{tabular}
}
\ExplSyntaxOff

\begin{document}

\tableofproblems{5B,5I,5J,5K,SL}

\end{document}


• This is great! Thanks! Sep 30 at 5:07