6

In the article class, sometimes our definitions or theorems (theorem-like environments) may be split into two parts across two pages. I would like to know if there is a way to avoid this situation to happen without manually clearing the page?

4
  • You could put it into a float: figure, table and create a new one. Jan 9, 2015 at 14:44
  • @JohnKormylo: Thanks so much for your concern :) If possible, would you mind sharing me with a simple example?
    – Yes
    Jan 9, 2015 at 14:45
  • It might be easier to use the mdframed to generate your theorem envs. It can color them etc. But you can then ask it not not add any frames and set it to be unbreakable.
    – daleif
    Jan 9, 2015 at 14:55
  • @daleif: Much appreciated. Would you mind showing me an example? For now I just need the function "making unbreakable".
    – Yes
    Jan 9, 2015 at 15:00

3 Answers 3

7

Here is an example using mdframed. You will see that the paragraphs on the first page are stretched because the theorem env are not allowed to break.

If it is for a twosided book, the best solution might be to have a system which allows breaking if from a left hand to a right hand page, but not the other way around. I would be surprised if tcolorbox didn't have something similar.

\documentclass[a4paper]{memoir}

% standard packages
\usepackage{amsmath,amssymb,amsthm,mathtools,bm}

\usepackage{mdframed}
\usepackage{kantlipsum}

\mdfdefinestyle{myenvs}{%
  hidealllines=true,%
  nobreak=true, % comment this to allow breaking
  leftmargin=0pt,
  rightmargin=0pt,
  innerleftmargin=0pt,
  innerrightmargin=0pt,
}

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


\begin{document}

\kant[1-3]
\begin{theorem}
  \kant[1-2]
\end{theorem}
\kant


\end{document}
6

As @daleif suspected, there is also a tcolorbox way to answer the question.

The most basic answer assumes that the OP only wants an existing theorem environment to become unbreakable. Lets name this environment theorem. It is made unbreakable by:

\tcolorboxenvironment{theorem}{blanker,before skip=10pt,after skip=10pt}

The skip values can be adapted as needed. The complete proposed answer is:

\documentclass{article}

\usepackage{amsmath,amssymb,amsthm}

\usepackage[skins]{tcolorbox}
\usepackage{lipsum}

\theoremstyle{plain}% from amsthm
\newtheorem{theorem}{Theorem}% from amsthm

\tcolorboxenvironment{theorem}{blanker,before skip=10pt,after skip=10pt}

\begin{document}

\lipsum[1-4]
\begin{theorem}
  \lipsum[1]
\end{theorem}
\lipsum[2]

\end{document}

Of course, there is a plethora of ways to make the box colorful and fancy, if needed. Also, tcolorbox provides own theorem environments, but this is another story.

For completeness: mdframed has the same mechanism with \surroundwithmdframed to patch an existing environment. You can flip a coin which package to use for this :-)

1

Without the figure, it would have been split across pages.

\documentclass{article}
\usepackage{mathtools}
\usepackage{lipsum}

\newtheorem{thm}{Theorem}

\begin{document}

\lipsum[1-4]

\begin{figure}[thb]
\begin{thm}
\lipsum[5-6]
\end{thm}
\end{figure}

\lipsum[7-10]
\end{document}
5
  • Thanks; but when I use [thb] then the words inside the theorem block get smaller?
    – Yes
    Jan 9, 2015 at 15:06
  • They stand for Top, Here, Bottom of page. Jan 9, 2015 at 15:08
  • 1
    Using a float might send theorems far away, not really a good idea. And h does not mean here, but rather here if possible
    – daleif
    Jan 9, 2015 at 15:13
  • @dateif, would you prefer to use \vfil and a minipage? Jan 9, 2015 at 15:19
  • You will have to do it by hand, which is annoying.
    – daleif
    Jan 9, 2015 at 15:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .