7

When I try to use mdframed box inside Exercise enviroment from package exercise, the page breaking does not work. It does work if I switch the order - if I use Exercise inside a box. I however need the box IN the Exercise, and correctly broken. How can I achieve that?

\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{exercise}
\usepackage{lipsum}

\newmdenv{mybox}


\begin{document}
\lipsum[1-3]

\begin{Exercise}   %%% Works correctly if I swap these two enviroments
    \begin{mybox}
        \lipsum[1-3]
    \end{mybox}
\end{Exercise}


\end{document}

EDIT: Well, apparently you get the exact same results with tcolorbox and other boxing packages. I am removing mdframed from tags and the title, as this is issue with general colored boxes, or something they have in common.

Kiraa
  • 647
  • It would probably be a whole lot easier to fix/replace the exercise package than mdframed. Parsing the list of keywords seems to be the only complicated thing it does. – John Kormylo Aug 31 '15 at 22:16

1 Answers1

2

I can't offer a full solution (and don't have the rep to comment yet), but my suspicion is that this is caused by the exercise package storing the contents of environments in vboxes. If you have the option, you may have better luck with one of the other packages for putting together exercise sheets.

The following seems to produce the frame correctly for me:

\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}
%\usepackage{exercise}
\usepackage{exsheets}
\usepackage{lipsum}

\newmdenv{mybox}

\begin{document}
\lipsum[1-3]

\begin{question}
  \begin{mybox}
    \lipsum[1-3]
  \end{mybox}
\end{question}

\end{document}
Ben
  • 195
  • I knew about other packages, but I've built on top of the exercise package quite a lot of code and I would not like to rewrite it using different package.

    However, if no other solution will be presented near time, I will accept this as an answer.

    – Kiraa Aug 31 '15 at 18:31