# How to prevent my theorems from breaking off at a pagebreak?

I styled the theorems in my document a bit, using the mdframed package. I'm glad with the result, but the frame sometimes breaks off incorrectly. I've created a sample to show you what's going wrong.

\documentclass[a4paper]{article}

\usepackage{amsthm}
\usepackage{mdframed}
\usepackage{lipsum}

\textheight 22.4cm
\parskip 12pt
\definecolor{lichtgrijs}{gray}{0.95}
\mdfdefinestyle{mystyle}{ %
backgroundcolor=lichtgrijs, %
linewidth=0pt, %
innertopmargin=10pt, %
innerbottommargin=10pt %
}

\newmdtheoremenv[style=mystyle]{theorem}{Theorem}

\begin{document}
\lipsum[1-5]
\begin{theorem}
This is my theorem.
\vspace{-15pt}
\begin{enumerate}
\item It breaks of ugly.
\end{enumerate}
\end{theorem}
\end{document}


As you can see, a gray banner from the theorem is shown on the second page. Obviously, that's not very desirable.

How can I prevent this?

You can add nobreak=true to your definition of mystyle:
\mdfdefinestyle{mystyle}{ %
`