3

I'd think this is super common but no matter how I search I cannot find anyone else even asking this question.

I'm finding that the longtable package is keeping the last row with the rest of the table, rather than inserting a page break, depending on where the table is allowed to start in the page.

In this MWE, it keeps the 'final step' row with the rest of the table, resulting in

Overfull \vbox (8.2999pt too high) has occurred while \output is active

\documentclass[12pt,letterpaper,notitlepage,oneside]{article}
\usepackage{array}
\usepackage{longtable}
\begin{document}

\rule{2pt}{457pt}%Takes up enough space for this problem to come up

\begin{longtable}{| m{5cm} |}
    \hline\endfirsthead
    \hline\endhead
    \hline\endfoot
    \hline\endlastfoot

    step 1\\
    step 2\\
    step 3\\
    step 4\\
    step 5\\
    final step\\
\end{longtable}
\end{document}

The \rule before the longtable is just a placeholder, representing stuff (text, other tables, etc.) that take up enough space before a longtable for the problem to happen. It's just a small 'sweet spot' of space before a longtable that can result in the issue.

I'd be very grateful if anyone can recommend a way I can automatically prevent this. I understand I can manually put in a \pagebreak command at the end of the 'step 5' row, but part of the point of using the longtable package is to avoid having to manually break up my tables.

1
  • 1
    You HAD to start at a distance where it either overshot or undershot the bottom of the page. Nasty! Commented Nov 13, 2019 at 5:07

1 Answer 1

1

You would think that adding some glue before the longtable would take care of it, but that doesn't work.

Not sure why this splits off two lines instead of one, but it probably has something to do with widows or orphans.

\documentclass[12pt,letterpaper,notitlepage,oneside]{article}
\usepackage{array}
\usepackage{longtable}
\usepackage{showframe}
\begin{document}

\rule{2pt}{457pt}%with \hline, no captions

\normalbaselineskip=\baselineskip
\begin{longtable}{| m{5cm} |}
    \hline\endfirsthead
    \hline\endhead
    \hline\endfoot
    \hline\endlastfoot
    \global\advance\baselineskip by 0pt plus 1fil
    step 1\\
    step 2\\
    step 3\\
    step 4\\
    step 5\\
    final step\\
\end{longtable}
\baselineskip=\normalbaselineskip% restore global value
\end{document}

This version plays with \arraystretch (trial and error).

\documentclass[12pt,letterpaper,notitlepage,oneside]{article}
\usepackage{array}
\usepackage{longtable}
\usepackage{showframe}
\begin{document}

\rule{2pt}{457pt}%with \hline, no captions

\def\arraystretch{1.1}
\begin{longtable}{| m{5cm} |}
    \hline\endfirsthead
    \hline\endhead
    \hline\endfoot
    \hline\endlastfoot
    step 1\\
    step 2\\
    step 3\\
    step 4\\
    step 5\\
    final step\\
\end{longtable}
\end{document}
3
  • thanks for your response! I have 2 questions: 1) I commented out the new lines immediately before and after the longtable environment, and the result was the same. What do they do? 2) On the first page, there are gaps between the rows - the vertical lines framing the table contents aren't continuous. Is that the compromise I'd have to live with, or what?
    – James
    Commented Nov 14, 2019 at 17:28
  • The two line you commented out have to do with later text having normal spacing. And yes, the gaps are caused by the glue expanding. Commented Nov 14, 2019 at 22:12
  • Thanks for your answers to my questions, and the other option you provided!
    – James
    Commented Nov 15, 2019 at 23:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .