exam.cls 中从问题句末尾到右边距的水平线

exam.cls 中从问题句末尾到右边距的水平线

我需要从问题中的句子末尾到右边距画一条线。在考试课上,\hrulefill如果我不使用,我可以用 来做这件事\droppoints,但一旦我使用 ,线就不再到右边距了。

第一个问题没有 就行\droppoints,第二个问题把线剪短了。

\question[2]
    This is a question to answer here:\hrulefill

    \question[2]
    This is another question:\hrulefill \droppoints

在此处输入图片描述

答案1

这样做的原因是 因为\droppoints还插入了一段橡胶长度 - \hfill- 以拉伸到页面的右侧。该长度由\hfill和两个组件共享\hrulefill

您可以强制新建一个段落然后跳转回插入\droppoints,或者创建一个\droppointshere不插入的新宏(比如说) \hfill

在此处输入图片描述

\documentclass{exam}

\makeatletter
\def\droppointshere{%
  % \leavevmode\unskip\nobreak\hfill% <----- removed
  \rlap{\hskip\rightmargin  % Defined by the list environment
        \hskip\@rightmargin % Defined by exam.cls
        \hskip-\rightpointsmargin
        \llap{\padded@point@block}%
  }% rlap
  \par
}
\makeatother

\begin{document}

\begin{questions}
  \question[2]
    This is a question to answer here: \hrulefill

  \question[2]
    This is another question: \hrulefill \droppoints

  \question[2]
    This is another question: \hrulefill \par
    \vspace{\dimexpr-\parskip-\baselineskip}\droppoints

  \question[2]
    This is a final question: \hrulefill \droppointshere
\end{questions}

\end{document}

相关内容