以下是我从 MWE 获得的输出:
注意,我定义了一个命令\qfrom
来添加每个案例中问题的来源。当问题来源未知时,它将为空。
如何使其像下面的输出一样工作?
平均能量损失
\documentclass{exam}
\pointname{}
\pointsinrightmargin
\newcommand{\qfrom}[1]{\hfill{[#1]}}
\usepackage{geometry}
\geometry{
paper = a4paper,
outer = 3in
}
\begin{document}
\begin{questions}
\question[10]
Why is there air?
\question[15] \qfrom{JAM2018}
How much wood would a woodchuck chuck if a woodchuck could chuck
wood?
\qformat{\thequestion. \textbf{[\thequestiontitle]}\hfill}
\titledquestion{Title of the Quesiton}[10] \qfrom{NEST2015}
Compute $\displaystyle\int_0^1 x^2 \, dx$.
\end{questions}
\end{document}
附言:由于某种原因,我也需要标题问题,所以我不想对其进行格式化。
答案1
下面是一个尝试解决您的问题的示例。首先,\qform
必须在实际问题之前调用。它将其参数保存到名为的宏中\qfromsource
。该宏稍后会使用。
接下来,我们\droppoints
从exam
类中重新定义宏,将宏\qfromsource
与分配给问题的点一起打印。
在开始提问之前,\qfromat
必须调用\droppoints
它。参见代码。
\documentclass{exam}
\pointname{}
\pointsinrightmargin
\newcommand{\qfrom}[1]{\global\def\qfromsource{#1}}
\usepackage{geometry}
\geometry{
paper = a4paper,
outer = 3in,
}
\makeatletter
\def\droppoints{%
\leavevmode\unskip\nobreak\hfill
\rlap{\hskip\rightmargin % Defined by the list environment
\hskip\@rightmargin % Defined by exam.cls
\hskip-\rightpointsmargin
\llap{[\qfromsource] (\thepoints)}%
}% rlap
\par
}
\makeatother
\begin{document}
\begin{questions}
\qformat{\thequestion. \textbf{[\thequestiontitle]}\droppoints}
\qfrom{JAM2018}
\titledquestion{Some physics}[5]
Why is there air?
\qfrom{JAM2018}
\titledquestion{Question for dyslectics}[15]
How much wood would a woodchuck chuck if a woodchuck could chuck
wood?
\qfrom{NEST2015}
\titledquestion{Simple integration}[10]
Compute $\displaystyle\int_0^1 x^2 \, dx$.
\end{questions}
\end{document}