I have a theorem which is half of it on another page, as I do for you automatically (without \newpage
) get full theorem on the next page?
\documentclass[a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{theorem}
\newtheorem{teo}{Teorema}[chapter]
\begin{document}
\lipsum[1-5]
\begin{teo}
\lipsum[1]
\end{teo}
\end{document}
I have the left and I need right automatically (without \newpage
).
Best Answer
Building on @cmhughes' answer, and therefore technically similar, the
etoolbox
package provides a means to hook into the start and end of an environment using\AtBeginEnvironment
and\AtEndEnvironment
. As such, a similar result is obtained (without using thentheorem
package):As you see from the input, the
theorem
package is not needed to reproduce the output. However, this may also just be due to your MWE. I would think, this is probably the best way to answer your question. However...I'm more curious as to why you would want to do this. For example, you'll notice in the aforementioned example that the paragraph skips are stretched to fill the remainder of the page since the theorem overflows to the following page. This can be avoided by using something like a
\newpage
. So, in the hypothetical yet likely scenario where you have a very long theorem description, you might want to consider foregoing to flush the entire theorem body over to the next page. In this case I would suggest conditioning on where to break or not, based on the amount of space left on the current page. Theneedspace
package provides\Needspace{<length>}
and issues a\break
if the remaining open space on the page is less than<length>
. You may use it in the following sense:The above code adds
\Needspace{5\baselineskip}
to the beginning of theteo
environment (using\AtBeginEnvironment
) which will issue a\break
if less than5\baselineskip
is available on the current page. If more than this length is available, no\break
will be issued. For this example, it produces the same result. Compare that to the disastrous output generated byand you'll understand why.