How do I take the output from \numqinrange
and use it in my own custom command?
I have created a custom grading table for the Exam Class. This allows me to add custom elements to the table that we use for grading our exam. Everything in my exam latex file is automatic (question totals, number of points per section, etc.), thereby leading to less user-error in making exams in the future. However, currently, in order to use my custom \GradingTable
command, you must enter the start and end of the ranges of questions. How can I make this automatic? Since \numqinrange
outputs the exact numbers I need, it would be nice to get this into the \GradingTable
command.
I have attempted many solutions to this including \expandafter
, but I am not familiar enough with LaTeX to make it work.
Here is a minimum working example:
\documentclass[12pt, addpoints]{exam}
% Grading Table Packages
\usepackage{makecell}
\usepackage{adjustbox}
\usepackage{forloop}
\usepackage{xfp}
\begin{document}
\begin{questions}
\section*{Section A}
\label{section-a}
\begingradingrange{seca}
\question[4] Question Text
\question[7] Question Text
\endgradingrange{seca}
\section*{Section B}
\label{section-b}
\begingradingrange{secb}
\question[2] Question Text
\question[8] Question Text
\endgradingrange{secb}
\end{questions}
\newcounter{QNum}
\newcommand{\InnerContent}[2]{
\forloop{QNum}{#1}{\value{QNum} < \fpeval{#2+1}}
{ \\\hline
$\theQNum$ &
\pointsofquestion{\value{QNum}} &
\makecell{\vspace{-1mm} \\ ------ \\ \vspace{-1mm}} &
\makecell{\vspace{-1mm} \\ ------ \\ \vspace{-1mm}}}
}
\newcommand{\GradingTable}[3]{
\adjustbox{valign=t}{
\begin{tabular}{|c|c|c|c|} \hline
\multicolumn{4}{|c|}{#1} \\\hline
Q & P & M1 & M2%
\InnerContent{#2}{#3}
\\\hline
\end{tabular}
}
}
% These numbers: "1,2,3,4" are hard coded. How can I use the "numinrange" to automate this?
\GradingTable{Section A}{1}{2}
\GradingTable{Section B}{3}{4}
% This does not work
% \GradingTable{Section A}{1}{\numqinrange{seca}}
\end{document}
Any and all help is appreciated. Thank you.
Lloyd