37

I want to do something like the following in TeX:

\begin{nobreak}  

Text here will not split over pages, it will remain
as one continuous chunk. If there isn't enough room
for it on the current page a pagebreak will happen
before it and the whole chunk will start on the next
page.  

\end{nobreak}

Is this possible?

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
fredley
  • 32,953
  • 42
  • 145
  • 236

2 Answers2

52

You could try:

\begin{samepage}
 This is the first paragraph. This is the first paragraph. 
 This is the first paragraph. This is the first paragraph. 

 \nopagebreak
 This the second. This the second. This the second. 
 This the second. This the second. This the second. 
 This the second. This the second. 
\end{samepage}

samepage prevents LaTeX from pagebreaking within one paragraph, i.e. within the samepage environment, pagebreaks are only between paragraphs. Thus, you need nopagebreak as well, to prevent LaTeX from pagebreaking between two paragraphs.

phimuemue
  • 34,669
  • 9
  • 84
  • 115
17

A quick test reveals thatminipage has this behavior, too.

\begin{minipage}{3in}
One contiguous chunk.
\end{minipage}

\begin{minipage}{3in}
Another contiguous chunk.
\end{minipage}
Steve Tjoa
  • 59,122
  • 18
  • 90
  • 101
  • 4
    One may also use `\textwidth` as the required parameter to minipage if you'd like to maintain the same width as the rest of the document: `\begin{minipage}{\textwidth}` – Ivan G. Apr 05 '18 at 19:36
  • Also note that this doesn't work if there are floats in the minipage. The floats won't be constrained by it apparently. – Zertrin Sep 07 '20 at 14:34