1

I need to draw a line from the end of a sentence in a question to the right margin. In exam class, I can do this with \hrulefill if I don't use \droppoints, but as soon as I do, the line is no longer to the right margin.

First question works without \droppoints, second question cuts line short.

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

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

enter image description here

1 Answer 1

2

The reason for this is because \droppoints also inserts a rubber length - \hfill - to stretch to the right side of the page. The length is shared between the two components, \hfill and \hrulefill.

You can either force a new paragraph and then jump back to insert the \droppoints, or create a new macro (say) \droppointshere that doesn't insert the \hfill:

enter image description here

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.