3

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?

0

You can add nobreak=true to your definition of `mystyle:

\mdfdefinestyle{mystyle}{ %
    backgroundcolor=lichtgrijs, %
    linewidth=0pt, %
    innertopmargin=10pt, %
    innerbottommargin=10pt,%
    nobreak=true% prevent page breaks in the middle of mystyle
}

With this your theorem stays on the bottom of the first page:

enter image description here

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.