[Tex/LaTex] Longtable and floats: wrong table breaks on pages with floats (part 2)

longtable

I think I may have stumbled upon an undocumented feature regarding page breaking in longtable.

The following MWE produces (at least in my TeXlive 2014 setup) a document in which the last paragraphs overflow the bottom of the page.

\documentclass{article}

\usepackage[margin=1in]{geometry}
\usepackage{lipsum}
\usepackage{longtable}

\begin{document}
  \begin{figure}
    \sffamily \lipsum[2]
    \caption{A figure}
  \end{figure}
  \lipsum[1-2]

 \begin{longtable}{ll}
    a & b \\
    c & d 
  \end{longtable}

  \begin{figure}
    \sffamily \lipsum[1]
    \caption{A figure}
  \end{figure}

  \lipsum[1-4]

\end{document}

The result is:

enter image description here

The problem is, I think, related to longtabu and floats: wrong table breaks on pages with floats. Note that I am working with a patched version of longtable.sty, as per David Carlisle's suggestions (patch available at http://www.latex-project.org/cgi-bin/ltxbugs2html?pr=tools/3512, which, incidentally has not made it into TeXlive 2014, despite having been around >2 years).

The difference with the earlier question is that my float appears after the long table. Moving the float above the longtable fixes the problem, but this is clearly not a real solution. Does anyone happen to know how to fix this?

Best Answer

There's no bugs in longtable: only interesting features.

so.. LT overshoots the page and TeX complains:

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

In an ideal world that wouldn't happen, but if it does, you can give the page breaker a helping hand and shorten it by the stated amount.

\begin{longtable}{ll}
    a & b \\
    c & d 
  \end{longtable}
\makeatletter
\global\advance\@colroom-90pt
\makeatother

I think it's cruelty to output routine authors to have a multi-page table that's less than a page long and have one float before the table and one float after the table, all on the same page:-)

Related Question