4

I often introduce new text with the last line of a paragraph, terminated by a colon. Perhaps the text before and after is ordinary text (between pages 1 and 2 in the example), or the text thereafter is a list (between pages 3 and 4 in the example), or the first paragraph is within a list with the next one being in a nested list (between pages 5 and 6 in the example). I would like to keep the last line of the first paragraph with the subsequent paragraph because that last line is often of an introductory nature. How can I do this? (I know about \Needspace, but I don't know how to use it for a solution here.)

I believe this question makes most sense in a \raggedbottom-context; this is also where I need this resolved. Here is an example:

\documentclass{memoir}
\usepackage{lipsum}
\raggedbottom

\begin{document}

\lipsum[1-4]
Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text:

Some filler text. Some filler text.

\newpage

\lipsum[1-4]
Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text:

\begin{itemize}
\item Some text.
\item Some text.
\item Some text.
\end{itemize}

\newpage

\begin{itemize}
\item \lipsum[1-4]
\item Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Now a nested list:
    \begin{itemize}
    \item Some text.
    \item Some text.
    \item Some text.
    \end{itemize}
\end{itemize}

\end{document}

Here I would specifically like the last lines of pages 1, 3, and 5 kept together with the first lines of pages 2, 4, and 6, respectively. \nopagebreak works in the first case, but not in the two list cases.

3
  • 1
    Having the blank line before the itemize is a markup error, if the preceding text ends with : then the list is part of the same sentence so part of the same paragraph, LaTeX goes to a lot of effort to distinguish in-paragraph lists from end or start of paragraph lists Commented Jan 22, 2013 at 10:15
  • 1
    the blank line problem is also a markup error before a math display, with the same unwanted result. Commented Jan 22, 2013 at 15:50
  • 1
    @barbarabeeton Yes it's actually much worse before a (primitive tex) math display as you get a blank paragraph in that case (an hbox just containing indentation and parfillskip glue) rather than just different vertical glue Commented Jan 23, 2013 at 0:43

1 Answer 1

7
Some filler text. Some filler text. Some filler text. Some filler text. Some filler text. Some filler text:
\widowpenalty=-5000 \nopagebreak
\begin{itemize}
\item Some text.
\item Some text.
\item Some text.
\end{itemize}

pushes

Some filler text:

To the top of page 4. The negative widow penalty encourages rather than discourages a break before the last line of the partial paragraph and the \nopagebreak stops it breaking before the list.

7
  • If I insert \widowpenalty=-5000 between pages 3/4 (at the place you suggest), it remains active for the pagebreak between 5/6 as well. Is this good? Then I might as well set it once, in the preamble, or are there any adverse effects to beware of? Commented Jan 23, 2013 at 0:34
  • 1
    oops no best to set it back again it encourages the last line of a paragraph to be widowed (pushed over to the next page) which isn't usually what you want. You could use {\widowpenalty=-5000 \nopagebreak\par} except as I noted above that defeats latex list code checking for an in-par list, so probably best to set it back after (both) \begin{itemize} and \end{itemize} Commented Jan 23, 2013 at 0:42
  • Actually, {\widowpenalty=-5000 \nopagebreak\par} seems like the perfect solution for my case, because if I don't want to use "keep together" functionality, I just don't use this (and use an empty line in before the list instead). Correct me if I'm wrong. I'll try it out a little later and will report back. Commented Jan 23, 2013 at 2:16
  • 1
    latex puts on more vertical space (above and below) usually if there is a par before the list (\partopsep) see \documentclass[twocolumn]{article} \raggedbottom \begin{document} \hrule a \begin{enumerate}\item b\end{enumerate} c \hrule \pagebreak \hrule a \begin{enumerate}\item b\end{enumerate} c \hrule \end{document} Commented Jan 23, 2013 at 2:38
  • Oh in that case I don't want the \par. So I basically need \widowpenalty=-5000 \nopagebreak before and then \widowpenalty=previousvalue both after \begin{itemize} and \end{itemize}, correct? Is there a trivial way of storing previousvalue just before \widowpenalty=-5000 \nopagebreak? Then I'll just define macros for both <save \widowpenalty somehow in previousvalue> \widowpenalty=-5000 \nopagebreak and \widowpenalty=previousvalue. Commented Jan 23, 2013 at 7:04

You must log in to answer this question.

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