\answerline to the right of a question

using exam class. I want the answerline on the same line as the question, to be used in mid-sentence actually.

I have this:

\documentclass[a4paper]{exam}
\begin{document}
\begin{questions}
\end{questions}
\end{document}

-
Is your problem that \answerline is placed a line below \question but you want both of them to be in the same line? (If so, please state it, if not, please tell us your problem to be solved.) (A \vspace{-2\baselineskip} before \answerline could help, but there is probably some better solution, if that is indeed the issue here.) – Stephen Nov 10 '12 at 15:08
I've updated my answer to include your request, as well as provided some more modifications (using \answerline*) to remove the number typesetting. – Werner Nov 11 '12 at 4:06

You can remove the separation by patching \answerline with xpatch:

\documentclass[a4paper]{exam}
\usepackage{xpatch}% http://ctan.org/pkg/etoolbox
{}% <replace>
{}{}% <success><failure>
\begin{document}
\begin{questions}
\end{questions}
\end{document}


This will remove the skip for all \answerlines. Alternatively, on a case-by-case basis, you can set \answerskip carefully:

\question Write hello%


Further modifications are also possible. The following MWE incorporates the above changes, but also provides a starred variant of \answerline that removes the number before the answer and allows for things to follow \answerline:

\documentclass[a4paper]{exam}
\usepackage{letltxmacro}% http://ctan.org/pkg/letltxmacro
\usepackage{xpatch}% http://ctan.org/pkg/etoolbox
{}% <replace>
{}{}% <success><failure>
\makeatletter
\begingroup
\IfBooleanTF{#1}
\IfNoValueTF{#2}
\endgroup
}
\makeatother
\begin{document}
\begin{questions}
\end{questions}
\end{document}


letltxmacro provides the means to store macros with optional arguments created using \newcommand.

-
will it still print the answers when I use \printanswers? – MaoYiyi Nov 11 '12 at 4:13
@MaoYiyi: Yes. Try it! – Werner Nov 11 '12 at 4:21
Nice solution. How do I turn this on in one part of my document and then back to the normal behavior for the rest of it? – Jeff Apr 18 '15 at 20:45
@me: Put the usepackage commands in the top (before start document), then put the rest inside \begingroup and \par\endgroup. (But it adds an xparse/redefine-command warning). – Jeff Apr 18 '15 at 20:53
@Werner, This still includes the question number (or letter) before the answerline and it's still not quite in line with the text. Can that be fixed? – Jeff Apr 18 '15 at 21:04