# Avoid widowed signature lines

I have documents created in XeLaTeX with signature lines appearing at the end of the document. Sometimes these signatures appear on pages by themselves i.e. without preceding content. I would like to avoid having these "widowed" signatures, and in particular have the signatures preceded by at least two lines of text (i.e. something that would essentially make it possible to identify the documents to which the signatures would likely attach).

The content of the documents and the number of signatures are variable, so I would like to have a solution that is as automatic as possible.

Here is an example of the document, using the memoir class:

\documentclass{memoir}
\usepackage{lipsum}

% signature
% ~~~~~~~~~
%                _____________
%                *Name* (1)
%
\newcommand{\signature}[2]{%
\bigskip\par{}%
\begin{SingleSpace}%
\begin{tabular}{ p{6cm} p{8cm} }
& \rule{6cm}{0.5pt}\newline{}%
\textbf{#1}\\%
& #2 %
\end{tabular}%
\end{SingleSpace}%
\medskip%
}

\begin{document}

% some arbitrary number of lipsum
\lipsum[1-5]

% an arbitrary number of signatures
\signature{John Doe}{42 Wallaby Way, Sydney}
\signature{Jane Smith}{Bates Motel, California}

\end{document}


What I have considered is using a combination of the following to automatically achieve the best outcomes (insofar as they are practical):

1. Making the page sizes slightly larger, particularly if there is only one page;

2. Increase the spacing between paragraphs;

3. Prevent page breaking before the list of signatures.

I believe #1 may be achieved by using \sloppybottom.

I am not sure how to achieve #2, or if it would be aesthetically acceptable.

Perhaps #3 can be achieved with \noprelistbreak or \nopagebreak - though I would presumably have to convert the signatures into a list environment for the prior.

I would be very interested in thoughts on this interesting issue.

-

The widow line is formed in your paragraph text before the signature code really starts so you need to prevent them at that level (I just set widowpenalty to be infinite here) The signature code was making overfull box warnings so I modified it a bit, unrelated to the question.

\documentclass{memoir}
\usepackage{lipsum}

% signature
% ~~~~~~~~~
%                _____________
%                *Name* (1)
%
\newcommand{\signature}[2]{%
\par\nobreak\bigskip
\begin{SingleSpace}%
\mbox{}\hfill\begin{tabular}{p{8cm} }
\rule{8cm}{0.5pt}\newline{}%
\textbf{#1}\\%
#2 %
\end{tabular}%
\end{SingleSpace}%
\medskip%
}

\begin{document}
\raggedbottom
% some arbitrary number of lipsum
\widowpenalty10000
\lipsum[1-5]

% an arbitrary number of signatures
\signature{John Doe}{42 Wallaby Way, Sydney}
\signature{Jane Smith}{Bates Motel, California}

\end{document}

-
Many thanks David. I didn't mean for you to have to fix my signature code too, but it is much appreciated. If I may ask, why might one prefer \widowpenalty to e.g. \nopagebreak? –  Brian M. Hunt Mar 3 at 18:20
widowpenalty is a global setting saying you don't want last lines of a paragraph to break over the page, \nopagebreak ads a penalty node at a single point in the document so for it to work here you'd have to insert it by hand by some text that you observe comes on the last but one line of the paragraph. widowpenalty is the kind of thing you set when setting up a document class, \nopagebreak is the kind of thing you use in final hand correction stage before you print a book and need to hand tweak some page breaks. –  David Carlisle Mar 3 at 20:17