如何更改考试文档类中评分表的布局(后续)

如何更改考试文档类中评分表的布局(后续)

这个 8 年前的答案似乎不再适用于最新版本的exam课程。

因此,我想了解需要进行哪些更改才能获得所需的点表输出

在此处输入图片描述

此外,如何将同样的方法应用于评分表?

\documentclass[a4paper,addpoints,11pt]{exam} 

\usepackage{booktabs}


% Change table layout
\makeatletter            % @ a normal letter

%first table:
\def\@vpttblquestions{%
    % Vertical non-bonus point table, indexed by questions:
    \set@hlfcntr{tbl@points}{0}%
    \begin{tabular}{cc}
        %   \hline  % topline
        {\@vqword}& {\@vpword}\\
        \midrule
        \setcounter{question}{\tbl@firstq}%
        \addtocounter{question}{-1}\do@vptloop
        {\@vtword}& \prt@tablepoints\\
        %    \hline  % endrule
    \end{tabular}%
}% @vpttblquestions
\def\do@vptloop{%
    % \do@vptloop is used by \@vpttblquestions
    \addtocounter{question}{1}%
    \ref{question@\arabic{question}} &
    \pointsofquestion{\arabic{question}}\\
    %  \hline
    \@ifundefined{pointsofq@\romannumeral \c@question}%
    {}%
    {\addto@hlfcntr{tbl@points}
        {\csname pointsofq@\romannumeral \c@question\endcsname}}%
    \ifnum \value{question} < \tbl@lastq\relax
    \let\next@vptloop=\do@vptloop
    \else
    \let\next@vptloop=\relax
    \fi
    \next@vptloop
}% do@vptloop

% second table
\def\@htblquestions{%
    % We get here from \@tblquestions.
    % The table is horizontal and indexed by question numbers.
    % The question range has already been determined.
    % Set num@cols equal to the number of questions on the table, and
    % do either bonus, combined, or non-bonus table, in each case
    % putting in a line for scores only if it's a gradetable:
    \@ifundefined{exam@numquestions}%
    {}%
    {%
        \setcounter{num@cols}{\tbl@lastq}%
        \addtocounter{num@cols}{-\tbl@firstq}%
        \addtocounter{num@cols}{1}%
    }%
    % Do either bonus, combined, or non-bonus table.  In each case, put
    % in a line for scores if it's a gradetable:
    \begingroup
    % Save the current value of question in @iterator, so that
    % we can restore it after doing the table:
    \setcounter{@iterator}{\value{question}}%
    \renewcommand\arraystretch{\@gtblstretch}%
    \if@bonus
    % It's a horizontal bonus table, by questions:
    \begin{tabular}{l*{\thenum@cols}{c}c}
        %        \hline
        {\@bhqword}& \setcounter{question}{\tbl@firstq}%
        \addtocounter{question}{-1}\do@qnumloop
        {\@bhtword}\\
        %        \hline
        \set@hlfcntr{tbl@bonuspoints}{0}%
        {\@bhpword}& \setcounter{question}{\tbl@firstq}%
        \addtocounter{question}{-1}\do@bptloop
        \prt@tablebonuspoints\\
        %        \hline
        % If it's a grade table, add in the score line:
        \if@scores
        {\@bhsword}& \setcounter{question}{\tbl@firstq}%
        \addtocounter{question}{-1}\do@sloop
        \\
        %          \hline
        \fi
    \end{tabular}%
    \else
    \if@combined
    % It's a horizontal combined table, by questions:
    \begin{tabular}{l*{\thenum@cols}{c}c}
        %          \hline
        {\@chqword}& \setcounter{question}{\tbl@firstq}%
        \addtocounter{question}{-1}\do@qnumloop
        {\@chtword}\\
        %          \hline
        \set@hlfcntr{tbl@points}{0}%
        {\@chpword}& \setcounter{question}{\tbl@firstq}%
        \addtocounter{question}{-1}\do@ptloop
        \prt@tablepoints\\
        %          \hline
        \set@hlfcntr{tbl@bonuspoints}{0}%
        {\@chbpword}& \setcounter{question}{\tbl@firstq}%
        \addtocounter{question}{-1}\do@bptloop
        \prt@tablebonuspoints\\
        %          \hline
        % If it's a grade table, add in the score line:
        \if@scores
        {\@chsword}& \setcounter{question}{\tbl@firstq}%
        \addtocounter{question}{-1}\do@sloop
        \\
        %            \hline
        \fi
    \end{tabular}%
    \else
    % Horizontal non-bonus table, indexed by question number:
    \set@hlfcntr{tbl@points}{0}%
    \begin{tabular}{l*{\thenum@cols}{c}c}
        %          \hline
        {\@hqword}& \setcounter{question}{\tbl@firstq}%
        \addtocounter{question}{-1}\do@qnumloop
        {\@htword}\\
        \midrule
        {\@hpword}& \setcounter{question}{\tbl@firstq}%
        \addtocounter{question}{-1}\do@ptloop
        \prt@tablepoints\\
        %          \hline
        % If it's a grade table, add in the score line:
        \if@scores
        {\@hsword}& \setcounter{question}{\tbl@firstq}%
        \addtocounter{question}{-1}\do@sloop
        \\
        %            \hline
        \fi
    \end{tabular}%
    \fi
    \fi
    % Restore the saved value of question:
    \setcounter{question}{\value{@iterator}}%
    \endgroup
}% @htblquestions

\makeatother


\begin{document}
    
    \begin{questions}
        \question[10]
        Example question
        \question[20]
        Example question
        \question[30]
        Example question
        \question[40]
        Example question
        \question[50]
        Example question
    \end{questions}
    
    \begin{center}
        \pointtable[v][questions]
    \end{center}
    
    \begin{center}
        \pointtable[h][questions]
    \end{center}
    
\end{document} 

相关内容