# Avoiding orphans at the start of quote/quotation environments

To me, orphans -- page breaks after the first line of a paragraph -- are tolerable in the normal text body, and so I leave TeX's default settings (\clubpenalty=150) alone. On the other hand, I want to get rid of orphans at the start of quote/quotation environments.

• My first (naïve?) attempt was to define a new environment based on quote and set \clubpenalty=10000 within this environment; this still produced orphans.

• After rummaging through the LaTeX2e sources, I tried to embed \@afterheading (p. 287) into my custom environment; this resulted in an error message.

• Finally (and out of sheer desparation), I inserted \@nobreaktrue (which is used in \@afterheading) into my custom environment; this worked.

This poses the following questions:

• Why did my attempt at locally redefining \clubpenalty fail?

• What does \@nobreaktrue do? Are there adverse effects?

• If the latter is the case, what is the proper way to avoid orphans at the start of quote/quotation environments?

\documentclass{report}

\usepackage[latin]{babel}

\usepackage{blindtext}

\setlength{\textwidth}{350pt}

\newenvironment{failednoorphanquote}{\begin{quote}\clubpenalty=10000\relax}{\end{quote}}

\makeatletter
\newenvironment{noorphanquote}{\begin{quote}\@nobreaktrue}{\end{quote}}
\makeatother

\begin{document}

\chapter{bla}

\blindtext[3]

\begin{quote}
\blindtext
\end{quote}

\chapter{blubb}

\blindtext[3]

\begin{failednoorphanquote}
\blindtext
\end{failednoorphanquote}

\chapter{foo}

\blindtext[3]

\begin{noorphanquote}
\blindtext
\end{noorphanquote}

\end{document}


EDIT: In response to Martin Scharrer's answer: I'm looking for a solution that (unlike \Needspace) does not make implicit assumptions about the vertical space above the quote environment.

-

\@nobreaktrue is the correct way to do this. The reason it works is that the quote environment eventually does something like

\everypar{%
\if@nobreak
\@nobreakfalse
\clubpenalty=10000
\else
\clubpenalty=150
\fi
}


so your \clubpenalty is being overridden.

To answer your other questions, \@nobreaktrue expands to \global\let\if@nobreak\iftrue. There are no adverse effects because if it is true, then it is immediately (globally) set back to false as soon as the paragraph has started.

-
Thanks! With hindsight, I should have searched in source2e not only for \@nobreaktrue, but also for \if@nobreak. –  lockstep Mar 25 '11 at 20:33
@lockstep: I just used the trace package to trace the invocation of failednoorphanquote to see what was going wrong with \clubpenalty. –  TH. Mar 25 '11 at 20:43

I can't answer why \clubpenalty fails and \@nobreaktrue works, but here an alternative solution:

You can use the needspace package to force a pagebreak before the quote if the space isn't enough for two lines:

\usepackage{needspace}
\newenvironment{noorphanquote}{\Needspace*{3\baselineskip}\begin{quote}}{\end{quote}}


Here 3\baselineskip is used for the skip above the quote plus two lines. You might want to refine this value.

-
True, but I'm looking for a solution that does not make implicit assumptions about the vertical space above the quote environment. –  lockstep Mar 25 '11 at 18:39
@lockstep: Like I wrote: You might want to refine that value. I couldn't find the correct dimension and I'm aware that it is a stretchable amount. You might also put the \Needspace inside the quote environment to avoid this issue. –  Martin Scharrer Mar 25 '11 at 19:15
By default, the vertical space is mutable -- it's either \topsep or \topsep plus \partopsep, depending on whether the quote environment starts a new paragraph or not. –  lockstep Mar 25 '11 at 19:24

A few months after I had asked this question, I released my quoting package. Its new environment of the same name offers, among other things, control of orphans at the start of it – disable them for individual environments with \begin{quoting}[noorphanfirst] and globally with \usepackage[noorphanfirst]{quoting}. (There's also a related option noorphanafter.)

\documentclass{report}

\usepackage[latin]{babel}

\usepackage{quoting}

\usepackage{blindtext}

\setlength{\textwidth}{350pt}

\begin{document}

\chapter{bla}

\blindtext[3]

\begin{quoting}
\blindtext
\end{quoting}

\chapter{blubb}

\blindtext[3]

\begin{quoting}[noorphanfirst]
\blindtext
\end{quoting}

\end{document}

-