# \answerline to the right of a question with dot line between answer line and question

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

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.

\documentclass[a4paper]{exam}

\usepackage{letltxmacro,xpatch}
\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
\makeatletter
\LetLtxMacro{\oldanswerline}{\answerline}
\RenewDocumentCommand{\answerline}{s o}{%
\begingroup
\IfBooleanTF{#1}
{\def\@queslevel{\relax}}% \answerline*
{}% \answerline
\IfNoValueTF{#2}
{\oldanswerline[{}]}% \answerline
{\oldanswerline[#2]}% \answerline[..]
\endgroup
}
\makeatother

\begin{document}
\begin{questions}
\question Write hello \answerline*[hello] to your mother
\question Write hello \answerline[hello] to your mother
\end{questions}
\end{document}

-
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 '13 at 5:11