1

This question is related to one of my previous questions: Specifying exact placement of answers in exam tests

I would like to make exam tests that can be compiled without and with answers, and the answers should be placed exactly in the empty spaces between the questions. That is, everything except from the answers should overlap in the two compiled pdf files.

At the moment I achieve this with the following codes:

without answers:

\documentclass{article}
\usepackage{lipsum}
\usepackage{etoolbox}
\newtoggle{wta}
\settoggle{wta}{false}
\usepackage[T1]{fontenc}
\usepackage{enumitem}

\begin{document}

\begin{enumerate}

\item\parbox[t]{\linewidth}{
\lipsum[1][1]\\
\parbox[t][1.5cm][t]{\linewidth}{
\iftoggle{wta}{\lipsum[1][4-5]}{}}
}

\item\parbox[t]{\linewidth}{
\lipsum[1][1]\\
\parbox[t][1.5cm][t]{\linewidth}{
\iftoggle{wta}{\lipsum[1][4-5]}{}}
}

\end{enumerate}

\end{document}

With answers:

\documentclass{article}
\usepackage{lipsum}
\usepackage{etoolbox}
\newtoggle{wta}
\settoggle{wta}{true}
\usepackage[T1]{fontenc}
\usepackage{enumitem}

\begin{document}

\begin{enumerate}

\item\parbox[t]{\linewidth}{
\lipsum[1][1]\\
\parbox[t][1.5cm][t]{\linewidth}{
\iftoggle{wta}{\lipsum[1][4-5]}{}}
}

\item\parbox[t]{\linewidth}{
\lipsum[1][1]\\
\parbox[t][1.5cm][t]{\linewidth}{
\iftoggle{wta}{\lipsum[1][4-5]}{}}
}

\end{enumerate}

\end{document}

This works more or less but still the questions' placements do not overlap in the pdf outputs. I thought that if I put a fixed sized box under the questions and fill it with the answer (\settoggle{wta}{true}) or leave it empty (\settoggle{wta}{false}) it would result in the very same placement of the questions (and boxes), but it doesn't. What do I miss or do I wrong?

3
  • a parbox with no content will have zero width not the width specified. see X\parbox{3cm}{}X and X\parbox{3cm}{.}X Commented Jun 10 at 21:29
  • Maybe you can use a \phantom instead? Commented Jun 11 at 5:55
  • 1
    If the answer text is not complicated then you could consider the censor package. This prints black boxes by default but you can make them white as well. Commented Jun 11 at 11:36

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.