为什么弹出的是 (C) 而不是 (D)。(D) 应该是正确的解决方案。代码从 xsim 手册复制/粘贴。
\NewTasksEnvironment[label=(\Alph*),label-width=15pt]{choices}[\choice]
\newcommand*\correct{\thetask\expanded{\SetExerciseProperty{choice}{\thetask}}}
\begin{exercise}
The system of units that is based on the powers of 10 is called
\begin{choices}(1)
\choice US System of Units
\choice EU System of Units
\choice Imperial System
\choice[\correct] The Metric System
\end{choices}
\end{exercise}
\begin{solution}
\GetExerciseProperty{choice}
\end{solution}
答案1
尝试将宏的定义更改\correct
为
\newcommand*\correct{\refstepcounter{task}\thetask\expanded{\SetExerciseProperty{choice}{\thetask}}}
(可能是tasks
包改变了它的行为;当用户使用自定义标签时,原始标签的计数器不应该增加,这是有道理的。)
另一方面,我不确定为什么需要将“ \correct
”放在括号内。对我来说,这样做更有意义
\NewTasksEnvironment[label=(\Alph*),label-width=15pt]{choices}[\choice]
\newcommand*\correct{\expanded{\SetExerciseProperty{choice}{\thetask}}}
\begin{exercise}
The system of units that is based on the powers of 10 is called
\begin{choices}(1)
\choice US System of Units
\choice EU System of Units
\choice Imperial System
\choice\correct The Metric System
\end{choices}
\end{exercise}