How to prevent longtable to put header alone in one page like in image below. I used endhead to prevent this but this will print the header on each page.

enter image description here

Sorry I don't give MWE because I haven't succeeded to reproduce it with minimum data.

  • 1
    hard to say without an example (It should be easy to generate an example from your test document just by removing things that are not needed and using a \vspace*{5cm} or where to simulate the point where LT starts on the first page. If that definition line is not in a heading and is just a normal row you could end the row with \* to discourage a break (but that doesn't really work if you have \hline as that re-allows the break, or put that ro and a copule more rows in an \endfirsthead so they are never split, but not copied – David Carlisle Jul 1 '14 at 8:24
  • 1
    or just put \clearpage before the table (before the heading, probably) – David Carlisle Jul 1 '14 at 8:25
  • 1

As noted in

How to prevent page break between section title and table

You could use the needspace package to conditionally ad a \clearpage if the heading is near the bottom of the page. (The problem that is solving is slightly different, a page break happening before the table, after the heading, whereas you have a page break within the heading).

In general though, the simplest way in longtable to ensure that the first one or two lines of the table body stick to the first table head is to put the \endfirsthead line after those lines. You may think of them as part of the table body but if you want them always to stick with the head, putting them in the head works well. Similarly you can if needed put the last line or two into the top of the \endlastfoot so that they stay with the table footer at the end of the table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.