
Как я могу создавать пользовательские вопросы с помощью 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}