让 \numquestions\ 不计算奖励问题

让 \numquestions\ 不计算奖励问题

我想使用 \numquestions 和 \numparts,但不要像 \numpoints 那样计算 bonusquestions 和 -parts。我该如何实现?

举个例子,我希望以下内容能够表达“本次考试包含 2 个问题和 1 个奖励问题。

\documentclass[addpoints]{exam}

\begin{document}
This exams contains \numquestions\ questions and a bonusquestion.

    \begin{questions}
    \question[100]
    Is this the first question?
    \question[100]
    Is this the second question?
    \bonusquestion[100]
    Does this question count?
    \end{questions}
    
\end{document}

答案1

使用包totcount和命令\qquestion\bbonusquestion而不是\question\bonusquestion

A

\documentclass[addpoints]{exam}
    
%****************************** added <<<<<<<<<<<<<<<<<<
\usepackage{totcount}
\newtotcounter{q}
\setcounter{q}{0}
\newtotcounter{b}
\setcounter{b}{0}
\newcommand{\qquestion}[0]{\stepcounter{q}\question}
\newcommand{\bbonusquestion}[0]{\stepcounter{b}\bonusquestion}
%****************************** 
    
\begin{document}
    
This exams contains \total{q}\ question(s) and \total{b}\ bonusquestion(s).
    
    \begin{questions}
        \qquestion[100]
        Is this the first question?
        \qquestion[100]
        Is this the second question?
        \bbonusquestion[100]
        Does this question count?
        \bbonusquestion[100]
        Does this question count?       
    \end{questions}
    
\end{document}

灵感来自分别统计问题的数量...

相关内容