I see a nice feature \answerline to the right of a question. The answer is put to the right of a question. What I want is:

  1. the number before the answer line should be removed, because I think the number before answer line is redundant.
  2. dotted line between the question end and the answer.

Is that possible?

1 Answer 1


Using the code from Werner's solution to the other question, you can put a \leaders command in the replacement text that was removing the vertical skip.

\leaders takes some box and copies it enough times to fill up some specified horizontal space. So here is one version: we make a box containing a dot with some space around it, we ask the sequence of boxes to fill up an aggressively stretchable horizontal space of 0pt plus 1filll. This will squeeze out the other stretchable space on the line before the answer material, pushing it to the right and filling the intervening space with a line of dots.

For removing the number, we just note that Werner's code already provided a command \answerline* command, so we may use that when we wish to suppress numbers.

Sample output


\xpatchcmd{\answerline}% <cmd>
  {\par\nobreak\vskip\answerskip}% <search>
  {\leaders\hbox{\hskip0.2em .\hskip0.2em}\hskip 0pt plus 1filll}% <replace>
  {}{}% <success><failure>
\xpatchcmd{\answerline}{\fi \par}{\fi}{}{}% Remove line break after \answerline
\RenewDocumentCommand{\answerline}{s o}{%
    {\def\@queslevel{\relax}}% \answerline*
    {}% \answerline
    {\oldanswerline[{}]}% \answerline
    {\oldanswerline[#2]}% \answerline[..]

  \question Write hello \answerline*[hello] to your mother
  \question Write hello \answerline[hello] to your mother
  • Dear Andrew, thanks for the answer, though the thanks come a litter later. I just mark your post as a good answer, thank you again.
    – ollydbg23
    Oct 16, 2013 at 5:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .