我正在尝试了解 LaTeX 上的考试类别。到目前为止,文档很有帮助,但我不知道如何按我想要的方式修改 \question \part 和子部分的结构。
这是我目前所拥有的。
\documentclass[12pt,a4paper]{exam}
\renewcommand\questionlabel{\textbf{Question \thequestion}}
\marksnotpoints
\pointformat{\textbf{\thepoints}}
\pointsdroppedatright
\pointsinrightmargin
\begin{document}
\begin{questions}
\question[1] Why is there air? This should start on a new line and aligned with the question.
\question
\begin{parts}
\part[2] Why is there water? This should also start on a new line and algined with the question.
\part[3] Why is there smoke?This should also start on a new line and algined with the question.
\end{parts}
\question
\begin{parts}
\part Consider the following sentence “Blah Blah Blah”.
\begin{subparts}
\subpart[4] Prove “Blah Blah Blah” is true.
\end{subparts}
\end{parts}
\end{questions}
\end{document}
答案1
这考试类提供了一个\qformat
命令,可以完成你想要的大部分操作(参见手册第 4.4 节)。添加
\qformat{\textbf{Question \thequestion\hfill\thepoints}}
将问题编号和标记单独放在一行上。然后\questionhook
您可以使用一个命令将零件编号拉回到左边距:
\renewcommand{\questionshook}{%
\setlength{\leftmargin}{0pt}%
\setlength{\labelwidth}{-\labelsep}%
}
完成这些操作后,标记会与问题文本稍微重叠,您可以使用以下方法修复:
\setlength{\rightpointsmargin}{5mm}
综合起来,得出以下结论:
这几乎满足了您的所有要求,只是问题行上的标记与右边距不齐平。我对手册的理解是它应该是...除此之外,您可能需要微调页边距。
完整代码如下:
\documentclass[12pt,a4paper]{exam}
\marksnotpoints
\pointformat{\quad\textbf{\thepoints}}
\pointsdroppedatright
\pointsinrightmargin
\setlength{\rightpointsmargin}{5mm}
\qformat{\textbf{Question \thequestion\hfill\thepoints}}
\renewcommand{\questionshook}{%
\setlength{\leftmargin}{0pt}%
\setlength{\labelwidth}{-\labelsep}%
}
\begin{document}
\begin{questions}
\question[1] Why is there air? This should start on a new line and aligned with the question.
\question
\begin{parts}
\part[2] Why is there water? This should also start on a new line and algined with the question.
\part[3] Why is there smoke?This should also start on a new line and algined with the question.
\end{parts}
\question
\begin{parts}
\part Consider the following sentence “Blah Blah Blah”.
\begin{subparts}
\subpart[4] Prove “Blah Blah Blah” is true.
\end{subparts}
\end{parts}
\end{questions}
\end{document}