考试包标签多重定义

考试包标签多重定义

我正在使用考试包创建一份问卷。我有两个部分包含多项选择题。当我在每个部分下放置两个“问题”环境时,我收到乳胶警告,其中提到标签定义多次(标签“question@1”多次定义等)。有人知道如何避免两个问题具有相同的标签吗?下面给出了示例代码

\documentclass[12pt]{exam}

\begin{document}

\section{On part one}

\begin{questions}

\question
Which of the following statements is/are True?
\begin{choices}
  \choice B is true 
  \choice A is false
  \correctchoice C is false
\end{choices}

\question 
Why is this false
\begin{choices}
  \correctchoice  Yay
  \correctchoice  Bee
  \correctchoice  See
  \choice  Dee
\end{choices}


\end{questions}

\section{On part two}

\begin{questions}

\question
Which of the following statements is/are True?
\begin{choices}
  \choice B is true 
  \choice A is false
  \correctchoice C is false
\end{choices}

\question 
Why is this false
\begin{choices}
  \correctchoice  Yay
  \correctchoice  Bee
  \correctchoice  See
  \choice  Dee
\end{choices}

\end{questions}

\end{document}

答案1

为了完成任务,该类exam使用自定义标签,但这样做并没有考虑到问题编号在每个questions环境中都会重置的事实。实际上,该类似乎只期望 questions环境。

使用两个肯定会混淆积分系统。如果你不打算使用它,你可以这样做

\documentclass[12pt]{exam}
\usepackage{xpatch}

\makeatletter
\xpatchcmd{\questions}
  {question@\arabic{question}}
  {question@\arabic{section}@\arabic{question}}
  {}{}
\makeatother
\begin{document}

\section{On part one}

\begin{questions}
\question
Which of the following statements is/are True?
\begin{choices}
  \choice B is true 
  \choice A is false
  \correctchoice C is false
\end{choices}

\question
Why is this false
\begin{choices}
  \correctchoice  Yay
  \correctchoice  Bee
  \correctchoice  See
  \choice  Dee
\end{choices}

\end{questions}

\section{On part two}

\begin{questions}
\question
Which of the following statements is/are True?
\begin{choices}
  \choice B is true 
  \choice A is false
  \correctchoice C is false
\end{choices}

\question
Why is this false
\begin{choices}
  \correctchoice  Yay
  \correctchoice  Bee
  \correctchoice  See
  \choice  Dee
\end{choices}

\end{questions}

\end{document}

另一种方法是使用\section 里面单一questions环境。

\documentclass[12pt]{exam}

\begin{document}


\begin{questions}
\section{On part one}
\question
Which of the following statements is/are True?
\begin{choices}
  \choice B is true 
  \choice A is false
  \correctchoice C is false
\end{choices}

\question
Why is this false
\begin{choices}
  \correctchoice  Yay
  \correctchoice  Bee
  \correctchoice  See
  \choice  Dee
\end{choices}

\section{On part two}

\question
Which of the following statements is/are True?
\begin{choices}
  \choice B is true 
  \choice A is false
  \correctchoice C is false
\end{choices}

\question
Why is this false
\begin{choices}
  \correctchoice  Yay
  \correctchoice  Bee
  \correctchoice  See
  \choice  Dee
\end{choices}

\end{questions}

\end{document}

相关内容