When the remaining rows of a longtable
fit exactly onto the current page, longtable
will instead create a widow by printing a footer on the current page and moving the last row onto the next page (with repeated header and footer).
This can be prevented by printing the last row as part of the last footer, but I am wondering why this is happening in the first place, and whether this could perhaps be fixed in the longtable
package. (Conceptually, I would expect the algorithm to only start a new page after it has determined that the remaining contents do not fit onto the current page.)
\documentclass{article}
\usepackage{booktabs}
\usepackage{longtable}
\begin{document}
\begin{longtable}{l}
\caption{Caption}\\
\toprule
Column heading\\
\midrule
\endfirsthead
\caption[]{Caption} \\
\toprule
Column heading\\
\midrule
\endhead
\midrule
Continued on next page\\
\midrule
\endfoot
\bottomrule
\endlastfoot
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
x\\
\end{longtable}
\end{document}
longtable
-- I will assume that you have more important things to do than typesetting tables with rows and rows consisting of the single letter "x" :-) -- you may decide to either forbid a linebreak in the penultimate row by changing\` to
\*` or to provide a strategically placed\enlargethispage{1\baselineskip}
instruction.\enlargethispage{1\baselineskip}
such that it affects the right page, if your longtable runs across many pages (i.e. the general case).longtable
to contain at least two rows, in addition to whatever is produced by\endhead
, instead of just one row.