4

Possible Duplicate:
Unbreakable block

I have a block of text (possibly comprising many paragraphs) near the end of a page. The page break is being inserted in the middle of this block--how do I prevent that? (How do I tell LaTeX that this block of text needs to always stay together on the same page?)

This question should apply to all formats, but in my case I am using the memoir class, and am willing to include any necessary packages.

3
  • 1
    Of course you're willing to accept a badly filled page.
    – egreg
    Feb 17, 2012 at 22:04
  • 1
    Yes, that's definitely an unavoidable side-effect. Feb 17, 2012 at 22:05
  • 2
    You could just wrap it into a \begin{minipage}{\linewidth}...\end{minipage} environment. Feb 17, 2012 at 22:06

1 Answer 1

7

If you wrap the contents within a minipage then TeX will put that block on the next page if it does not fit on the current page.

In the example below, the text in red is on Page 2. But if you remove the minipage environment by commentig out the \begin{minipage}{\linewidth} and \end{minipage}, then the text will be on Pages 1 and 2.

Note:

Code:

\documentclass{article}
\usepackage{lipsum}% for dummy text
\usepackage{xcolor}
\begin{document}
\lipsum[1-4]% dummy text to get towards bottom of page
\noindent
\begin{minipage}{\linewidth}% Following stays together
    \color{red}
    \lipsum[1-2]
\end{minipage}
\end{document}
6
  • 1
    The interline spacing after the minipage won't be uniform.
    – egreg
    Feb 17, 2012 at 22:12
  • 1
    and the minipage will set the glue (vertical stretch if any) so that it doesn't participate with other glue on the page. Feb 17, 2012 at 22:58
  • Thanks! What is the difference between \begin{minipage}{\lindwidth} (what you wrote) and \begin{minipage}{\textwidth}? Feb 18, 2012 at 2:33
  • 2
    Basically \textwidth is the full width on the page between the margins, where \linwidth adjusts for multiple columns, lists, etc. See difference between textwidth linewidth and hsize for a more detailed discussion. Feb 18, 2012 at 3:14
  • 1
    @jamaicanworm: This seems like a new question. Feb 18, 2012 at 16:30

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