1

I'm using the exam class and have the problem with the parts enviroment in combination with the solutionorbox enviroment. The part and the corresponding solutionorbox should be on the same page. Here is an example that demonstrate the problem:

\documentclass{exam}
\usepackage{blindtext}
\begin{document}
\begin{questions}
\titledquestion{Farben}
\begin{parts}
\part[4] Question 1 \blindtext
\begin{solutionorbox}[16cm]
    \blindtext
\end{solutionorbox}
\part[4] Question 2 \blindtext
\begin{solutionorbox}[10cm]
    \blindtext
\end{solutionorbox}
\end{parts}
\end{questions}
\end{document}

I have tried to modify the \part command by using etoolbox package but it does not work with:

\preto{\part}{\par\nobreak\vfil\penalty 9999\vfilneg\vtop\bgroup}

This is the part definition in the exam.cls:

\def\part{%
  \@bonusfalse
  \process@part
}%

How can I add a \newpage if needed that the question and the space for a solution is on the same page without adding the \newpage?

  • I thik it is easier to use '\clearpage' between both parts, and get a second page started with the question two. – djnavas May 2 '19 at 23:49
0

Probably not really a good solution, but it's a start.

First of all, you have to move you \preto patch within the parts environment, because \part is defined there. Then, because \part now has a \bgroup, you have to end your item with an \egroup.

\documentclass{exam}
\usepackage{blindtext}
\usepackage{etoolbox}
\begin{document}
\begin{questions}
\titledquestion{Farben}
\begin{parts}
\preto{\part}{\par\nobreak\vfil\penalty 9999\vfilneg\vtop\bgroup}
\part[4] Question 1 \blindtext
\begin{solutionorbox}[16cm]
    \blindtext
\end{solutionorbox}
\egroup
\part[4] Question 2 \blindtext
\begin{solutionorbox}[10cm]
    \blindtext
\end{solutionorbox}
\egroup
\end{parts}
\end{questions}
\end{document}

enter image description here

| improve this answer | |

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.