我正在尝试编写一些客观题或多项选择题。任务除了以下两点之外,这个软件包可以完成这个工作:
我想写 \begin{choices} 和 \choice; 而不是 \begin{tasks} 和 \task
我想包含和选项 \correctchoice 并打印所有答案等。
我尝试阅读文档,但无法做到这一点。请帮助我。
\documentclass[12pt]{article}
\usepackage{tasks}
\usepackage{exsheets}
\SetupExSheets[question]{type=exam}
\begin{document}
\begin{question}
Which one of the entries does not fit with the others?
\begin{tasks}(4)
\task mercury
\task iron
\task lead
\task zinc
\end{tasks}
\end{question}
\settasks{
counter-format=(tsk[a]),
label-width=4ex
}
\begin{question}
What is a function?
\begin{tasks}(2)
\task A dancing electron
\task A dancing proton
\task A dancing neutron
\task A Dixie Dancing Duck
\end{tasks}
\end{question}
\end{document}
答案1
现在(问题发布两年多后),使用exsheets
' 后继者可以相当容易地xsim
实现您想要的目标。下面的示例定义了choices
如下环境:
\NewTasksEnvironment[
label = (\alph*) ,
label-width = 16pt
]{choices}[\choice]
answer
然后定义一个练习属性和一个保存答案的命令:
\DeclareExerciseProperty{answer}
\newcommand*\answer[1]{%
\SetExpandedExerciseProperty{answer}{ (\alph{task}) \unexpanded{#1}}%
#1%
}
最后定义一个检索答案的命令:
\newcommand*\getanswers{%
\def\betweenanswers{\def\betweenanswers{\hspace{2em}}}%
\ForEachUsedExerciseByID{%
\betweenanswers##3\ExercisePropertyGet{##1}{##2}{answer}%
}%
}
然后像这样使用——语法不完全符合要求但非常接近:
\begin{exercise}
Which one of the entries does not fit with the others?
\begin{choices}(4)
\choice mercury
\choice iron
\choice \answer{lead}
\choice zinc
\end{choices}
\end{exercise}
完整代码:
\documentclass[12pt]{article}
\usepackage[no-files]{xsim}
\usepackage{tasks}
\NewTasksEnvironment[
label = (\alph*) ,
label-width = 16pt
]{choices}[\choice]
\DeclareExerciseProperty{answer}
\newcommand*\answer[1]{%
\SetExpandedExerciseProperty{answer}{ (\alph{task}) \unexpanded{#1}}%
#1%
}
\newcommand*\getanswers{%
\def\betweenanswers{\def\betweenanswers{\hspace{2em}}}%
\ForEachUsedExerciseByID{%
\betweenanswers##3\ExercisePropertyGet{##1}{##2}{answer}%
}%
}
\xsimsetup{
exercise/name = Question ,
exercise/the-counter = \arabic{exercise}.
}
\begin{document}
\section{Questions}
\begin{exercise}
Which one of the entries does not fit with the others?
\begin{choices}(4)
\choice mercury
\choice iron
\choice \answer{lead}
\choice zinc
\end{choices}
\end{exercise}
\begin{exercise}
Which one of the entries does not fit with the others?
\begin{choices}(4)
\choice argon
\choice \answer{hydrogen}
\choice neon
\choice helium
\end{choices}
\end{exercise}
\section{Answers}
\getanswers
\end{document}