
クラスを使用してカスタムの質問を作成するにはどうすればよいですかexam
? たとえば、ラベル A1、B1、C1 を付け、異なる色を使用する 3 つの異なる質問を作成する必要があります。
このようなもの
\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
の内部で増分します。Aquestion
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}