9

I noticed that the tabu package seems to have problems with its longtabu environment, if it is placed on a page, where a float already is placed.

Consider the following MWE:

\documentclass[10pt]{article}
\usepackage{longtable,tabu}
\usepackage{lipsum}

\begin{document}

    \begin{table}
        \begin{tabular}{ccc}
            Row 1 & Row 1 & Row 1 \\
            Row 2 & Row 2 & Row 2 \\
            Row 3 & Row 3 & Row 3 \\
            Row 4 & Row 4 & Row 4 \\
            Row 5 & Row 5 & Row 5 \\
            Row 6 & Row 6 & Row 6 \\
            Row 7 & Row 7 & Row 7 \\
            Row 8 & Row 8 & Row 8 \\
            Row 9 & Row 9 & Row 9 \\
            Row 10 & Row 10 & Row 10 \\
        \end{tabular}
    \end{table}

    \lipsum[1-2]

    \begin{longtabu}{X[l]X[c]}
        Test & Test
    \end{longtabu}

    \lipsum[10]

    {
        \footnotesize
        \begin{longtabu}{|X[-4,l]|X[r]|X[r]|X[r]|}
            \hline
            Col 1 & Col 2 & Col 3 & Col 4 \\\hline
            Lorem ipsum dolor sit & 0.000019 & 0.000000 & 0.000000 \tabularnewline\hline
            Lorem ipsum dolor sit & 0.000012 & 0.000000 & 0.000000 \tabularnewline\hline
            Lorem ipsum dolor sit & 0.000173 & 0.000000 & 0.000000 \tabularnewline\hline
            Lorem ipsum dolor sit & 0.000011 & 0.000000 & 0.000000 \tabularnewline\hline
            Lorem ipsum dolor sit & 0.012992 & 0.000000 & 0.000000 \tabularnewline\hline
            Lorem ipsum dolor sit & 0.000031 & 0.000000 & 0.000000 \tabularnewline\hline
            Lorem ipsum dolor sit & 0.000068 & 0.000000 & 0.000000 \tabularnewline\hline
            Lorem ipsum dolor sit & 0.000018 & 0.000000 & 0.000000 \tabularnewline\hline
            Lorem ipsum dolor sit & 0.029689 & 0.000000 & 0.000000 \tabularnewline\hline
            Lorem ipsum dolor sit & 0.000055 & 0.000000 & 0.000000 \tabularnewline\hline
            Lorem ipsum dolor sit & 0.000004 & 0.000000 & 0.000000 \tabularnewline\hline
            Lorem ipsum dolor sit & 28.276892 & 0.405603 & 1.560010 \tabularnewline\hline
            Lorem ipsum dolor sit & 0.957158 & 0.234002 & 0.702005 \tabularnewline\hline
            Lorem ipsum dolor sit & 0.000011 & 0.000000 & 0.000000 \tabularnewline\hline
            Lorem ipsum dolor sit & 0.000002 & 0.000000 & 0.000000 \tabularnewline\hline
            Lorem ipsum dolor sit & 0.000013 & 0.000000 & 0.000000 \tabularnewline\hline
            Lorem ipsum dolor sit & 0.000336 & 0.000000 & 0.000000 \tabularnewline\hline
            Lorem ipsum dolor sit & 0.000004 & 0.000000 & 0.000000 \tabularnewline\hline
            Lorem ipsum dolor sit & 0.000003 & 0.000000 & 0.000000 \tabularnewline\hline
            Lorem ipsum dolor sit & 0.000003 & 0.000000 & 0.000000 \tabularnewline\hline
        \end{longtabu}
    }

\end{document}

Note that the last table is broken in a wrong way at the bottom of page 1. I guess that the wrong offset for the table break is exactly the vertical dimension of the first table, which is enclosed in a floating environment.

However, I don't know how to fix the wrong table break. I have many pages containing floating tables, but at some places I would like to have long tables with longtabu, as exactly as in the MWE.

Can anybody tell me how to fix the wrong table break?

2
  • What do you mean by "the last table is broken the wrong way"? by compiling your mwe with pdflatex I get 3 rows on page 2. What are you getting and what would you expect?
    – ArTourter
    Commented Mar 16, 2012 at 17:13
  • @ArTourter Notice row 7, column 2 on the last table on page 1. Do you see the "1" inside this cell? This is the page number. Hence, here's something wrong...
    – DigNative
    Commented Mar 16, 2012 at 19:05

1 Answer 1

9

There have been some bugs in that area, although I thought they were fixed. If its reproducible just using longtable rather than the tabu version, please

latex latexbug.tex

and follow the prompts to submit a bug (category tools) although no promises getting this right is hard and changing the code after all this time is hard even if it is "wrong". Putting \clearpage before the longtable will flush the float and ensure things are in sync, although can cause a premature page break of course, but if you need the document in a hurry that may be the best course of action.

Meanwhile I or someone else here may spot a fix directly in your example....

UPDATE: FIX

If you apply the changes suggested here

http://www.latex-project.org/cgi-bin/ltxbugs2html?pr=tools/3512

then your example works as expected.

I seem to recall there was a reason that change wasn't just immediately applied at the time, but I don't see anything in the log, I'd need to investigate, but hopefully this will get you working again.

4
  • 1
    Hello David, thank you really much for your quick answer. I have tried to patch longtable.sty and it works now. I couldn't determine any side effects, even in a larger document. Would you, as author and maintainer, include this patch in a new version of the longtable package?
    – DigNative
    Commented Mar 16, 2012 at 19:25
  • yes probably, as I say, I just want to spend a bit of time seeing if I can reconstruct why it didn't go in at the time, and also to set up some regression tests etc, but clearly the package needs patching. Commented Mar 16, 2012 at 19:33
  • 1
    @DavidCarlisle was this issue ever fixed? :)
    – Zero3
    Commented May 25, 2016 at 20:17
  • @Zero3 not really, you can find some longtable version 5 trials if you search around my github but some things get fixed, some things break and backward compatibility is tricky, so things are as they were for now. Commented May 25, 2016 at 21:14

You must log in to answer this question.

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