
如何使用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}