考试班级如何分别统计不同部分的试题数量?

考试班级如何分别统计不同部分的试题数量?

我正在创建一个包含两部分的考试,第一部分是简题,第二部分是论述题,我想自动计算这两部分的问题数量分别地默认情况下,\numquestions显示问题总数在文档中

\documentclass{exam}

\begin{document}

\begin{questions}
\fullwidth{\Large \textbf{Short questions}}    
There are \numquestions\ short questions. %display the number of short questions.

\question
This is the first short question.
\question
This is the second short question.

\setcounter{question}{0}

\fullwidth{\Large \textbf{Essay questions}}
There are \numquestions\ essay questions. %display the number of essay questions.

\question
This is the first essay question.
\question
This is the second essay question.
\question
This is the third essay question.
\question
This is the fourth essay question.
\end{questions}
\end{document}

答案1

totcount这是使用包并重新定义\question命令以\squestion解决简答题和\equestion论述题的解决方案。

\documentclass{exam}

\usepackage{totcount}

\newtotcounter{s}
\setcounter{s}{0}
\newtotcounter{e}
\setcounter{e}{0}
\newcommand{\squestion}[0]{\stepcounter{s}\question}
\newcommand{\equestion}[0]{\stepcounter{e}\question}


\begin{document}

\fullwidth{\Large \textbf{Short questions}}    
There are \total{s}\ short questions. %display the number of short questions.

\begin{questions}
\squestion
This is the first short question.
\squestion
This is the second short question.
\end{questions}

\setcounter{question}{0}

\fullwidth{\Large \textbf{Essay questions}}
There are \total{e}\ essay questions. %display the number of essay questions.

\begin{questions}
\equestion
This is the first essay question.
\equestion
This is the second essay question.
\equestion
This is the third essay question.
\equestion
This is the fourth essay question.
\end{questions}

For the record there is a total of \numquestions\ questions.

\end{document}

输出如下:

输出

笔记\numquestions命令尚未修改,因此如果您需要知道问题总数(包括简答题和论文题),您仍然可以使用它。

相关内容