答案1
感谢一位前同学,我找到了一个解决方案,它满足了我的大部分愿望。说实话,我不知道大部分是如何实现的。但它效果很好。
\documentclass[addpoints]{exam}
\usepackage{tikz}
%-----------------------------------------
% This is some prework that needs to be done
%-----------------------------------------
\makeatletter
\providecommand{\exam@numpoints}{1}%
\newcommand{\GetNumPoints}{\exam@numpoints}%
\newcommand*{\@MyTempTableTokens}{}%
\newtoks\@tabtoks
%%% assignments to \@tabtoks must be global, because they are done in \foreach
\newcommand\AddTableTokens[1]{\global\@tabtoks\expandafter{\the\@tabtoks#1}}
\newcommand\eAddTableTokens[1]{%
\protected@edef\@MyTempTableTokens{#1}%
\expandafter\AddTableTokens\expandafter{\@MyTempTableTokens}}
%%% variable should always be operated on either always locally or always globally
\newcommand*\ResetTableTokens{\global\@tabtoks{}}
\newcommand*\PrintTableTokens{\the\@tabtoks}
\makeatother
\newcommand*{\NormFormule}[1]{%
\pgfmathparse{
9 * ( #1 / \GetNumPoints ) + 1
}
\pgfmathprintnumber[fixed, precision=1, fixed zerofill, use comma]{\pgfmathresult}}
%-----------------------------------------
% This is the command for making the table
%-----------------------------------------
\newcommand{\maketable}{\bigskip
\Huge Grading Table\bigskip\\\normalsize
\ResetTableTokens
\foreach \i in {0,...,14} %THIS IS WHERE I GOT STUCK!
{\eAddTableTokens{\i & \noexpand\NormFormule{\i} \\}}{}
\begin{minipage}[t]{.23\textwidth}\centering$(1{,}0-3{,}2)$\\
\begin{tabular}{|c|c|}
\hline
\textbf{score}&\textbf{grade}\\\hline\centering
\PrintTableTokens
\hline
\end{tabular}
\end{minipage}
\ResetTableTokens
\foreach \i in {15,...,29} {\eAddTableTokens{\i & \noexpand\NormFormule{\i} \\}}
\begin{minipage}[t]{.23\textwidth}\centering$(3{,}3-5{,}4)$\\
\begin{tabular}{|c|c|}
\hline
\textbf{score}&\textbf{grade}\\\hline\centering
\PrintTableTokens
\hline
\end{tabular}
\end{minipage}
\ResetTableTokens
\foreach \i in {30,...,44} {\eAddTableTokens{\i & \noexpand\NormFormule{\i} \\}}
\begin{minipage}[t]{.23\textwidth}\centering$(5{,}5-7{,}7)$\\
\begin{tabular}{|c|c|}
\hline
\textbf{score}&\textbf{grade}\\\hline\centering
\PrintTableTokens
\hline
\end{tabular}
\end{minipage}
\ResetTableTokens
\foreach \i in {45,...,\GetNumPoints} {\eAddTableTokens{\i & \noexpand\NormFormule{\i} \\}}
\begin{minipage}[t]{.23\textwidth}\centering$(7{,}8-10{,}0)$\\
\begin{tabular}{|c|c|}
\hline
\textbf{score}&\textbf{grade}\\\hline\centering
\PrintTableTokens
\hline
\end{tabular}
\end{minipage}
}
%-----------------------------------------
% And here the actual exam begins
%-----------------------------------------
\begin{document}
\begin{questions}
\question[60]
The content of this question is irrelevant.
\end{questions}
\maketable
\end{document}