Math & ScienceFlexibly start new page for proof environment

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
MathDood
Posts: 2
Joined: Fri Sep 11, 2015 5:50 am

Flexibly start new page for proof environment

Post by MathDood »

I would like to redefine my proof environment so that if the content of the proof environment is only, say, 3 lines or fewer, then the entire proof environment will just start on a new page. Here is a MWE:

Code: Select all

\documentclass[11pt]{article}

\usepackage{lipsum}
\usepackage{amsthm}

\begin{document}

\lipsum[1-4]

\begin{proof}
\lipsum[1]
\end{proof}

\end{document}
In this case, there are only 2 lines of a proof on the first page, so I would like the new proof environment to automatically start the proof on the next page. If the proof environment contained 4 or more lines on a page, then it will behave as normal.

I found a thread on the TeX Stack Exchange where they gave an example of defining an environment with different spacing and page breaking rules, but I do not understand the solution well enough to adapt it to what I am trying to do with the proof environment.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Flexibly start new page for proof environment

Post by Stefan Kottwitz »

Hi MathDood,

that's possible using the needspace package. I described using it a bit: here.

You simply need to redefine the proof environment to insert a \needspace command at the beginning of that environment.

Stefan
LaTeX.org admin
Post Reply