[Tex/LaTex] Continuing solution frame for exams


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





\question A short question.
A short solution.

\question A question with a long solution.

The long solution continues onto another page: \lipsum[1-8]


produces a page break that looks like

enter image description here

instead of the following desired look:

enter image description here

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 and endexam@MakeFramed

So you should change




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.

Related Question