如何在有分數或無分數的考試課中使用 \titledquestion?

如何在有分數或無分數的考試課中使用 \titledquestion?

使用考試類別時,可以有類似\question[5]或簡單的命令\question(即沒有分數)。前者預設包含括號內的點,後者則省略點及其周圍的括號。

要在考試中使用標題問題(要點用括號括起來),我使用了以下命令:

\qformat{\bf \thequestiontitle ~(\thepoints) \hfill}

現在,當我使用\titledquestion{my title}[5]和命令時,它們的行為方式與和命令的行為\titledquestion{my title}方式不同。不同之處在於,標題版本總是以括號結尾,無論是否已指定點。\question[5]\question

我想知道的是: 修改 的參數\qformat以使括號僅在指定點值時才出現的正確方法是什麼?我無法在 exam.cls 手冊中找到它(我認為它位於處理標題問題的部分中的某個位置)。

答案1

您可以使用\if@placepoints有條件地包含括號和值:

\documentclass{exam}

\makeatletter
\qformat{\bfseries\thequestiontitle\if@placepoints~(\thepoints)\else\fi\hfill}
\makeatother

\begin{document}

\begin{questions}
\titledquestion{my title}[5]
\titledquestion{my title}
\end{questions}

\end{document}

在此輸入影像描述

相關內容