0

The second longtable is unnecessarily pushed to the next page:

pages

I have tried to make it into a minimal example as much as possible:

\documentclass[]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{fancyvrb}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
\usepackage{longtable,booktabs,array}

\begin{document}

Some line of text

\begin{longtable}[]{@{}l@{}}
\toprule
header \\
\midrule
\endhead
value \\
\bottomrule
\end{longtable}

\vspace*{97mm}

\begin{Highlighting}[]
1
2
3
4
5
6
7
\end{Highlighting}

\begin{Highlighting}[]
1
2
3
4
5
6
7
8
\end{Highlighting}

Another line of text

\begin{longtable}[]{@{}l@{}}
\toprule
header \\
\midrule
\endhead
value \\
\bottomrule
\end{longtable}

\end{document}
5
  • You can add a \newpage or \needspace{2\baselineskip} before "Another line of text." Evidently longtable thinks it is at the bottom of page 1 rather than the top of page 2. May 26, 2021 at 20:44
  • Putting \needspace{\baselineskip} after "Another line of text." also works (needspace package). May 26, 2021 at 20:49
  • No, longtable starts formatting before page 1 is completed. There is enough room to put the paragraph "Another line of text." on page one, but for some reason it gets moved to page 2. You don't have to put \needspace before every longtable, but OTOH it doesn't hurt. I imagine @davidcarlisle will provide a bug fix in the next release. May 27, 2021 at 4:23
  • You can also put \pagebreak[3] after "Another line of text", but now the break occurs after rather than before. May 27, 2021 at 4:29
  • The longtable tag should have already caught his attention. The important thing is that you can patch it now and not have to wait. May 28, 2021 at 13:14

1 Answer 1

0

It seems like this issue was a bug and has been fixed somewhere between release LaTeX2e <2020-10-01> patch level 4 and LaTeX2e <2021-06-01> patch level 1.

See: https://github.com/latex3/latex2e/issues/604

You must log in to answer this question.

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