如何使用exam
类创建自定义问题?例如,我需要创建 3 个不同的问题,但标签分别为 A1、B1 和 C1,并且可能使用不同的颜色。
像这样
\begin{questions}
\Aquestion
This question starts with item label A1, and the text of this question is in blue color.
\Aquestion
This question starts with item label A2, and the text of this question is in blue color.
\Bquestion
This question starts with item label B1, and the text of this question is in red color.
\Cquestion
This question starts with item label C1, and the text of this question is in green color.
\Bquestion
This question starts with item label B2, and the text of this question is in red color.
\end{questions}
答案1
以下方法可能不是万无一失的,但却能按预期发挥作用,且不会丢失太多的考试类别选项。
我们尝试过的步骤:
- 为每种类型定义计数器
aqn
,例如bqn
,等等, \def
在forAquestion
、等内部增加它们Bquestion
,\questionlabel
根据您的计数器和所需文本重新定义前缀。- 当然,您可以在此之前添加任何格式。但请注意,此格式也适用于该问题下方的所有内容。
如果上述方法对您来说没问题,您可以实现它。我在这里给出了我的代码。显然,您可能想添加更多内容。
\documentclass{exam}
\usepackage{color}
\newcounter{aqn}
\newcounter{bqn}
\newcounter{cqn}
\def\Aquestion{
\stepcounter{aqn}
\renewcommand*{\questionlabel}{A\theaqn.}
\color{blue}
\question }
\def\Bquestion{
\stepcounter{bqn}
\renewcommand*{\questionlabel}{B\thebqn.}
\color{red}
\question
}
\def\Cquestion{
\stepcounter{cqn}
\renewcommand*{\questionlabel}{C\thecqn.}
\color{green}
\question
}
\begin{document}
\begin{questions}
\Aquestion
This question starts with item label A1, and the text of this question is in blue color.
\Aquestion
This question starts with item label A2, and the text of this question is in blue color.
\Bquestion
This question starts with item label B1, and the text of this question is in red color.
\Cquestion
This question starts with item label C1, and the text of this question is in green color.
\Bquestion
This question starts with item label B2, and the text of this question is in red color.
\end{questions}
\end{document}