Im trying to get a table added to my exam tex file that shows the grade earned based on all possible amounts of scorable points.
I am running intwo two issues:
-
The amount of \numpoints of the {exam} class should be the amount of loops of the table (after all: points scored will be between 0 and the max amount of points). I cannot use the \numpoints command that is builtin {exam} documentclass in the forloop however without getting errors. (In the MWE I manually entered the \numpoints amount)
-
I cannot use for loop to generate lines of the table.
\documentclass[addpoints,answers]{exam}
\usepackage{tikz}
\usepackage{pgffor}
\usepackage{xfp}
%Workaround for not being able to use exam's builtin \numpoints in the formula (bonus points for workaround)
\newcommand{\manualpoints}{10}
\begin{document}
\begin{questions}
\question[2] A Question
\question[2] A Question
\question[2] A Question
\question[2] A Question
\question[2] A Question
%nb. 10 points earnable
\end{questions}
\foreach \n in {0,...,12 }{ \n \quad \quad \pgfmathparse{2*\n + \manualpoints }\pgfmathresult \par }
\hfill \break
\begin{tabular}{|c|c|}
\textbf{score}&\textbf{Grade}\\
the above loop & in this table
\end{tabular}
\end{document}
Best Answer
Here is an example of building up a table where the number of rows is variable and the entry in the row is computed via the
\Formula
macro defined aswhere
#1
is the row number. This yields:References:
Code: