3

I am making a worksheet for a task for my teachertraining. My worksheet should leave the students enough place to answer, but also show what answer I expect.

The exam-class is perfect for making worksheets, however, I have one problem: I am using dotted lines for answers. If I print the answer, the dotted lines disappear and instead, my answer is printed in a box (which wraps perfectly around the answer, thus not showing how much place I would leave for the students to answer).

Is there some way, to make the answer appear on the dotted lines? This way, I can show my expected answer and how much place I think students would need. I am aware of the answerline-command, but I prefer dotted lines.

EDIT: As per comment, some code to show my problem:

1) version with answering lines, without answer:

\documentclass[11pt]{exam}

\setlength\dottedlinefillheight{.25in}

\begin{document}
\begin{questions}
   \question What is $2 + 2$?
   \begin{solutionordottedlines}[0.5in]
   This sum equals $4$.
\end{solutionordottedlines}
\end{document}

2) version with answer, but the dotted lines disappeared

\documentclass[11pt, answers]{exam}

\setlength\dottedlinefillheight{.25in}

\begin{document}
   \begin{questions}
   \question What is $2 + 2$?
   \begin{solutionordottedlines}[0.5in]
   This sum equals $4$.
   \end{solutionordottedlines}
\end{document}

Question: how to combine both documents, such that, when the answer is displayed, it appears on top of the dotted lines, while keeping the original amount of dotted lines?

0
3

Based on this answer, with some changes (using ulem package), following solution maybe used.

    \documentclass[11pt, answers]{exam}
    \usepackage[normalem]{ulem} 
    \newbox\allanswers
    \setbox\allanswers=\vbox{}
    \newenvironment{answer}
    {%
      \global\setbox\allanswers=\vbox\bgroup
      \unvbox\allanswers
    }%
    {%
      \bigbreak
      \egroup
      }
    \newcommand{\showanswers}{\unvbox\allanswers}
    \begin{document}
       \begin{questions}
       \question What is $2 + 2$?
       \begin{answer}
      \dotuline{ This sum equals $4$. Hence the answer is "four". Also the answer is $2^2$}
       \end{answer}
       \vspace{0.5cm}
       \showanswers
       \end{questions}
    \end{document}

enter image description here

EDIT: The answer is displayed, it appears on top of the dotted lines, while keeping the original amount of dotted lines.

\documentclass[11pt]{exam}
\newbox\allanswers
\setbox\allanswers=\vbox{}
\newenvironment{answer}
{%
  \global\setbox\allanswers=\vbox\bgroup
  \unvbox\allanswers
}%
{%
  \bigbreak
  \egroup
  }
\newcommand{\showanswers}{\unvbox\allanswers}
\setlength\dottedlinefillheight{.25in}
\begin{document}
   \begin{questions}
   \question What is $2 + 2$?
   \begin{answer}
   This sum equals $4$. This sum equals $4$. This sum equals $4$. This sum equals $4$. This sum equals $4$.This sum equals $4$. This sum equals $4$. This sum equals $4$. This sum equals $4$.
   \begin{solutionordottedlines}[0.5in]
   \end{solutionordottedlines}
   \end{answer}

   \vspace{0.5cm}
  \showanswers
   \end{questions}
\end{document}

enter image description here

3
  • Thank you for your answer. If I remove the showanswers option, the dotted line disappears. Also, it does not allow to manually controle the length of the dotted line (for example: if I type a sentence which spannes two lines, a written answer would be four lines. Hence, I would like the answer to appear on the first two lines, while the other two lines are still there...). I'll try to use your answer to experiment a bit and see what I can make from it, so thank you for your suggestion! – Student Mar 28 '19 at 23:41
  • @Student, Ok. I edited my answer. – ferahfeza Mar 29 '19 at 0:35
  • I was hoping there would be a more 'automatic' solution. Since there is not so much response, I suppose this will not be possible. Thank you for your time. – Student Mar 30 '19 at 7:59

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.