# How to avoid defined para from appearing at bottom of page?

I defined a poem-environment for two lined poems with the macro below. And could get both lines unbroken with samepage environment.

But how do I make them to not end on last line of a page.

\def\shloka{\bgroup\bfseries\begin{flushleft}\fontsize{13}{15}\selectfont\leftskip=10pt\begin{samepage}}
\def\endshloka{\end{samepage}\end{flushleft}\egroup}
-
You can use the needspace package, and use \needspace{r\baselineskip} to reserve at least three lines so that it won't end of the last line of the page. – Peter Grill Nov 2 '12 at 7:09

Without the use of any extra package it can be done as follows:

<material without pagebreak, e.g., your two line poem>
\vspace*{\baselineskip}%
\allowbreak
\vspace{-\baselineskip}%
\vspace{0pt}%

Explanation:

• the first \vspace* adds a vertical space without adding a break possibility before
• at the \allowbreak LaTeX will check if the page can be broken here. If this makes the page overfull LaTeX will break before your poem. If it is a possible breakpoint it will be recorded as such and possibly chosen later as the best one (in which case one baselineskip of space would end up at the bottom)
• if the break is chosen at this point then the following two vertical spaces will vanish into the page break
• then we back up so that we are directly after the last line of text to typeset further material without this extra space.
• the \vspace{0pt} is only added to guard against something like \addvspace that should not "see" our artificial negative space.
-