在考试类别中将题目中的分数指定为 m + n

在考试类别中将题目中的分数指定为 m + n

看下面的例子,第一题中,各部分所分配的点数是分开指定的,第一题为6个,第二题为4个。

但是,对于一些局部要求,我需要将其指定为 6 + 4,我在第二个问题中尝试了这一点。

\documentclass[addpoints]{exam}

\usepackage{lipsum}

% Placement of marks 
\bracketedpoints 
\pointsinrightmargin
\setlength{\rightpointsmargin}{20.0mm}
\extrawidth{-15.0mm}



\begin{document}

% Total points is wrongly reported as 16
Total points: \numpoints

\begin{questions}
  \question 
  \begin{parts}
    \part [6] \lipsum[1]
    \part [4] \lipsum[2]
  \end{parts}

  % The following produces a spurious + 4+ 4+ 4 in the output just
  % before this question

  \question [6 + 4] 
  \begin{parts}
    \part \lipsum[1]
    \part \lipsum[2]
  \end{parts}


\end{questions}

\end{document}

然而,上述情况会产生两个不良影响。

  1. 所报告的总分不正确。
  2. 输出中的问题前出现了一些虚假文本。

我该如何解决这个问题?

答案1

您可以修补向计数器添加点的命令,以便它接受表达式:

\documentclass[addpoints]{exam}
\usepackage{etoolbox}
\usepackage{lipsum}

% Placement of marks 
\bracketedpoints 
\pointsinrightmargin
\setlength{\rightpointsmargin}{20.0mm}
\extrawidth{-15.0mm}

\makeatletter
%% patch the command for adding points
%% so that it accepts an expression
\patchcmd{\addto@hlfcntr}{0#2}{\numexpr0#2\relax}{}{}
\makeatother


\begin{document}

% Total points is wrongly reported as 16
Total points: \numpoints

\begin{questions}
  \question 
  \begin{parts}
    \part [6] \lipsum[1]
    \part [4] \lipsum[2]
  \end{parts}

  % The following produces a spurious + 4+ 4+ 4 in the output just
  % before this question

  \question [6 + 4] 
  \begin{parts}
    \part \lipsum[1]
    \part \lipsum[2]
  \end{parts}
\end{questions}

\end{document}

在此处输入图片描述

答案2

以下是扭曲的解决方法:

% The following produces a spurious + 4+ 4+ 4 in the output just
      % before this question
       \noaddpoints    %% don't add points
       \question [6 + 4]
       \addpoints       %% add them now onwards
       \pointformat{}   %% don't display points
      \begin{parts}
        \part[6] \lipsum[1]
        \part[4] \lipsum[2]
      \end{parts}
      \bracketedpoints  %% start displaying points

看起来有点奇怪但是可以工作。

\documentclass[addpoints]{exam}

\usepackage{lipsum}

% Placement of marks
\bracketedpoints
\pointsinrightmargin
\setlength{\rightpointsmargin}{20.0mm}
\extrawidth{-15.0mm}



    \begin{document}

    % Total points is wrongly reported as 16
    Total points: \numpoints

    \begin{questions}
      \question
      \begin{parts}
        \part [6] \lipsum[1]
        \part [4] \lipsum[2]
      \end{parts}

      % The following produces a spurious + 4+ 4+ 4 in the output just
      % before this question
       \noaddpoints    %% don't add points
       \question [6 + 4]
       \addpoints       %% add them now onwards
       \pointformat{}   %% don't display points
      \begin{parts}
        \part[6] \lipsum[1]
        \part[4] \lipsum[2]
      \end{parts}
      \bracketedpoints  %% start displaying points

      \question [6]
       \addpoints
       \pointformat{}
      \begin{parts}
        \part[6] \lipsum[1]
        \part[4] \lipsum[2]
      \end{parts}


    \end{questions}

    \end{document}

在此处输入图片描述

相关内容