New edit: The proposed answer by magula, which used to work with version 2.5
of exam.cls
no longer works with the current version 2.603
. The following was included as a note for version 2.601
: "We changed command and environment names in the code from framed.sty that's included (slightly modified) in exam.cls so that the user can say \usepackage{framed} without creating conflicts. This also allows the user to use packages, such as minted.sty, that load framed.sty." I'm not sure if the changes made now render the current given answer/hack useless, but it simply deosn't work anymore.
Question: Can TheSolution
environment be renewed in such a way that the framed box provided for the solution does not break into separate boxes on different pages as also illustrated in this question.
The code
\documentclass[answers]{exam}
\usepackage{lipsum}
\usepackage{mdframed}
\def\MakeFramed#1{\begin{mdframed}}
\def\endMakeFramed{\end{mdframed}}
\begin{document}
\begin{questions}
\question A short question.
\begin{solution}
A short solution.
\end{solution}
\question A question with a long solution.
\begin{solution}
The long solution continues onto another page: \lipsum[1-8]
\end{solution}
\end{questions}
\end{document}
produces a page break that looks like
instead of the following desired look:
In the manual, on page 74, it mentions that one could use \renewenvironment
to completely customize the solution environment by changing the definition of TheSolution
. My question is how I could do this to make the frame extend onto the next page in the desired way indicated above and the linked to question at the beginning of this question.
Best Answer
With the new version, the commands you need to change to remimplement the original solution are
exam@MakeFramed
andendexam@MakeFramed
So you should change
to
This is a classic example of namespacing in TeX, where private macros have their name prefixed with the name of the package they belong to.