# Shaded theorems (thmtools) spanning pages

When the thmtools package is used to create theorem environments with a shaded background, it does not allow separate theorems to span more than one page. This is a rather severe problem if the document contains many long theorems, one after the other. Here is a minimal example.

\documentclass{minimal}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage[english]{babel}
\usepackage{blindtext}

\declaretheoremstyle[
shaded={bgcolor=\color{rgb}{0.9,0.9,0.9}}  % comment this line in/out
]{theorem}
\declaretheorem[style=theorem]{theorem}

\begin{document}

\begin{theorem}
\blindtext[5]
\end{theorem}

\begin{theorem}
\blindtext[5]
\end{theorem}

\end{document}


Here is what it looks like including and not including shading:

How does one include shading, but allow the theorems to span between pages?

-
You should try the theorem environment definitions provided by package mdframed – egreg Nov 10 '11 at 20:48

You can use \newmdtheoremenv from the mdframed package; a little example (change the lengths and other settings according to your needs):

\documentclass{article}
\usepackage[english]{babel}
\usepackage[margin=2cm]{geometry}% just for the example
\usepackage{xcolor}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{mdframed}
\usepackage{blindtext}

\definecolor{mybg}{rgb}{0.9,0.9,0.9}

\newmdtheoremenv [backgroundcolor=mybg, %
innertopmargin =0pt , %
splittopskip = \topskip, %
skipbelow= 6pt, %
skipabove=6pt, %
topline=false,bottomline=false,leftline=false,rightline=false,]{theorem}{Theorem}

\begin{document}

\begin{theorem}
\blindtext[5]
\end{theorem}

\begin{theorem}
\blindtext[5]
\end{theorem}

\end{document}


As Ulrich Schwarz comments, you can use the preheadhook, postfoothook hooks form thmtools to add the mdframed environment with the desired specifications:

\documentclass{article}
\usepackage[english]{babel}
\usepackage[margin=2cm]{geometry}% just for the example
\usepackage{xcolor}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{mdframed}
\usepackage{blindtext}
\usepackage{thmtools}

\definecolor{mybg}{rgb}{0.9,0.9,0.9}

\declaretheoremstyle[
notefont=\mdseries, notebraces={(}{)},
bodyfont=\normalfont\itshape,
innertopmargin =0pt , splittopskip = \topskip, %
skipbelow= 6pt, skipabove=6pt, %
topline=false,bottomline=false,leftline=false,rightline=false]},
postfoothook=\end{mdframed}
]{mystyle}
\declaretheorem[style=mystyle]{theorem}

\begin{document}

\begin{theorem}
\blindtext[5]
\end{theorem}

\begin{theorem}
\blindtext[5]
\end{theorem}

\end{document}

-
Oh dear. I was hoping to stick with thmtools, but it looks like I'll stick with mdframed from now. I will mark this as answered. – TSGM Nov 10 '11 at 21:43
I noticed that you added an innertopmargin=0pt option to the theorem declaration, and yet there is still substantial spacing between the top of the shaded region and the top of the first line. What is the option which controls that spacing? It's strange, because I thought that it -was- innertopmargin – TSGM Nov 10 '11 at 22:21
@TSGM: yes, innertopmargin controls that spacing; according to the documentation, its default values is 0.4\baselineskip, but apparently it really is bigger, setting it to 0pt has not the expected effect. I'll give a look at the code of the package to see what exactly is going on, but I don't promise anything (I can't spend too much time reading the code). Anyway, you could use innertopmargin =-.4\baselineskip (or any other suitable negative length) which apparently gives equal top and bottom spacing. – Gonzalo Medina Nov 10 '11 at 23:17
@TGSM: thmtools' shade and box settings all pass through to thmbox (if I recall) anyway. Nothing stops you from adding \begin{mdframed} (or whatever its syntax is) to the beforehead/afterfoot hooks. – Ulrich Schwarz Nov 11 '11 at 5:36
@UlrichSchwarz: good point. – Gonzalo Medina Nov 11 '11 at 13:04