3

I just searched for a way of allowing pagebreaks when using shaded theorem-environments from thmtools. I found my question was, somewhat, answered here (the second solution) with a comment from the package's author Ulrich Schwarz. However, I'd like to keep defining theorem-like environments as follows

\declaretheorem[shaded={bgcolor=LightGrey},name=Definition,parent=chapter,
    % refname={definition,definitions},
    Refname={Definition,Definitions}]{Def}

i.e. without having to declare an extra (rather bulky) theoremstyle for each environment I define.
Is it possible to use the "preheadhook-postfoothook-trick" with mdframed globally, while retaining the overall interface and style I would get with my above \declaretheorem-example?

As I understand, shaded theorem-environments in thmtools are already implemented using mdframed anyway, so I thought it should be possible to allow pagebreaks by redefining some internal thmtools command, by setting some global option, or something along those lines.

I hope this is actually a valid question, as it was, more or less, already answered in 2011.

1 Answer 1

2

Shaded theorems in thmtools are implemented with the shadethm package, not mdframed.

You can do the shading with mdframed instead by passing the option

mdframed={backgroundcolor=LightGrey}

to the theorem declaration. This will allow page breaks in the defintion and gives output as in the sample below.

If the options you want to pass to mdframed are more complicated, you can set-up a style

\usepackage{mdframed}
\mdfdefinestyle{thmstyle}{backgroundcolorl=LightGrey,
   leftmargin=40pt,
   rightmargin=40pt} 

and then pass

mdframed={style=thmstyle}

to the declaration instead of the shaded option.

Sample output

\documentclass{book}

\usepackage{amsthm}
\usepackage[svgnames]{xcolor}
\usepackage{thmtools}
\declaretheorem[mdframed={backgroundcolor=LightGrey},
  name=Definition,parent=chapter,
  Refname={Definition,Definitions}]{Def}

\begin{document}

\mbox{}
\vspace{14cm}
\begin{Def}
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
  Some long definition.
\end{Def}

\end{document}
1
  • 1
    Just note that it is a good idea to leave the breaking until when the document is almost done. mdframed may have some issues with theorem break that ends up looking odd (such as placing the box end on the next page, not sure if this is an issue when combined with thmtools). So for my own projects I now use unbreakble theorems and also provide theorems that are breakable and then manually change the environment. That seems to provide better results.
    – daleif
    Apr 16, 2015 at 11:36

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.