# How to avoid bad page breaks with lettrine?

I use the lettrine package to lower the first letter at the beginning of some paragraphs. But sometimes it happens to be the last line of the page and the result is awful. Is there any way to move it to the next page automatically?

Here is a small example file to show the problem.

\documentclass{article}
\usepackage{lettrine}

\usepackage[paperwidth=200pt,paperheight=300pt, offset=0pt, hmargin=40pt, tmargin=50pt, bmargin=80pt,

\newcommand{\TestLettrine}[2]{\lettrine[lines=2, loversize=1.0]{#1}{ #2}}

\begin{document}

\TestLettrine{L}{atex} as found in nature is a milky fluid found in 10\% of all flowering plants (angiosperms). It is a complex
emulsion consisting of proteins, alkaloids, starches, sugars, oils, tannins, resins, and gums that coagulates on
exposure to air. It is usually exuded after tissue injury. In most plants, latex is white, but some have yellow, orange,

\TestLettrine{L}{atex} as found in nature is a milky fluid found in 10\% of all flowering plants (angiosperms). It is a complex

\end{document}

-

Use the needspace package. It provides \needspace{<length>} (or \Needspace{<length>}) that issues a break if <length> is not available on the page, or does nothing otherwise:

\documentclass{article}
\usepackage{lettrine}% http://ctan.org/pkg/lettrine
\usepackage{needspace}% http://ctan.org/pkg/needspace

\usepackage[paperwidth=200pt,paperheight=300pt, offset=0pt, hmargin=40pt, tmargin=50pt, bmargin=80pt,

\newcommand{\TestLettrine}[2]{\lettrine[lines=2, loversize=1.0]{#1}{ #2}}

\begin{document}

\TestLettrine{L}{atex} as found in nature is a milky fluid found in 10\% of all flowering plants (angiosperms). It is a complex
emulsion consisting of proteins, alkaloids, starches, sugars, oils, tannins, resins, and gums that coagulates on
exposure to air. It is usually exuded after tissue injury. In most plants, latex is white, but some have yellow, orange,

\needspace{2\baselineskip}% Break if needed.

\TestLettrine{L}{atex} as found in nature is a milky fluid found in 10\% of all flowering plants (angiosperms). It is a complex

\end{document}


It may even be better to include the \needspace command in your definition of \TestLettrine:

\newcommand{\TestLettrine}[2]{%
\needspace{2\baselineskip}% Need at least 2 lines of text available on page, or else...
\lettrine[lines=2, loversize=1.0]{#1}{ #2}%
}


The "relative" length 2\baselineskip ensures that there should be at least 2 lines of text that need to fit at the bottom of the page, otherwise a \break is issued.

Of course, you could also just use \newpage or \pagebreak yourself before the paragraph. However, that's a little too manual that doesn't adapt to changes in your document.

-
This can only be manually applied, imagine a page that is almost typeset, you giving it two extra lines and will then insert the lettrine paragraph. Me thinks rather save the position and automate, rather use \pdfsavepos. –  Yiannis Lazarides Oct 8 '11 at 4:29
By including \needspace in the \TestLettrine macro, how can the page breaking requirement be considered manual? –  Werner Oct 8 '11 at 5:05
Sorry if I was not very clear, when I said can only be manually applied, I meant rather use \needspace manually as required. Personally, I wouldn't like the page to end with a dropcap. –  Yiannis Lazarides Oct 8 '11 at 5:57