16

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?

1

2 Answers 2

6

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:-)

3
  • Thanks, David. I was hoping you in particular could help with this. You're right, I missed one additional line in the MWE. I've updated it and added a screenshot. Could you have another look if you have time? Much appreciated!
    – yori
    Commented Sep 28, 2014 at 23:41
  • 1
    LOL @ interesting features btw. I have rephrased the question accordingly.
    – yori
    Commented Sep 28, 2014 at 23:45
  • @Yori answer undeleted and edited:-) Commented Sep 30, 2014 at 20:40
6

I can't comment because I am new so I will have to put this in an answer. I ran into this issue the other day because pandoc has switched to using longtable for all latex tables.

http://johnmacfarlane.net/pandoc/releases.html

"The LaTeX writer now uses longtable instead of ctable. This allows tables to be split over page boundaries."

Anyway I imagine a lot more people are running into this since pandoc is what is used to generate tables when using RMarkdown to generate latex documents.

I applied the old patch and it did fix it however the linenumbers are slightly different now:

diff longtable.sty.bak longtable.sty
167c167
<     \advance\vsize-\ht\LT@foot
---
>     \global\advance\vsize-\ht\LT@foot
195a196,200
>   \ifvoid\LT@foot\else
>     \global\advance\vsize\ht\LT@foot
>     \global\advance\@colroom\ht\LT@foot
>     \dimen@\pagegoal\advance\dimen@\ht\LT@foot\pagegoal\dimen@
>   \fi
198d202
<   \pagegoal\vsize
394a399
>         \advance\dimen@\ht\LT@foot
399a405
>             \global\vsize\@colroom
403,406c409
<       \global\@colroom\@colht
<       \global\vsize\@colht
<       \vbox
<         {\unvbox\z@\box\ifvoid\LT@lastfoot\LT@foot\else\LT@lastfoot\fi}%
---
>       \unvbox\z@\ifvoid\LT@lastfoot\copy\LT@foot\else\box\LT@lastfoot\fi
1
  • When I say it fixed it I mean it fixed my issue where I had 1 float and 1 longtable, not 1 long table with a float before and after.
    – Dalupus
    Commented Oct 18, 2014 at 15:33

You must log in to answer this question.

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