0

Longtable has wonderful logic that allows it to continue to the next page. However, if you have one longtable after another it can be jarring to the reader to follow a complex heading from the previous page - or have to re-read the heading. I have a situation where I would like to suppress this behavior and instead have a pagebreak after the first table, pushing the header to the next page:

Let's say you have two longtables, L1 and L2 and two pages, P1 and P2:

This is a psuedocode illustration of the current functionality.

P1 - L1
P1 - L2
P2 - ...L2

However, what I want is that if L2 would cross pages that it instead gets pushed to the next page.

P1 - L1
P2 - L2
6
  • just use \clearpage before the second table Feb 21, 2022 at 19:36
  • Thank you David, the issue is that I don't know "when" to add the \clearpage. This problem is simplified from a much larger automated system that may generate hundreds of pages making hand-edits untenable. Is there a way to get feedback from longtable on when it will cross a page boundary? I was previously using this solution (tex.stackexchange.com/questions/94699/…) but it doesn't seem to work anymore. Instead giving off a dimension error. Feb 21, 2022 at 19:43
  • you could set labels at the first and last page and then use some logic on the next run to compare the pageref, you can't do it on one run as the start of the table is already shipped to the pdf by the time you get to the end, there is no possibility to go back. Feb 21, 2022 at 19:55
  • I think I landed on the desired effect by using \\* at the end of every row. Are there any caveats that you can think of with that? Feb 21, 2022 at 20:04
  • I'd assumed that you had the possibility of table 2 being more than a page otherwise why not use a normal tabular if you never want it to break at all, then the behaviour would be as you say. Feb 21, 2022 at 20:14

1 Answer 1

0

In the longtable documentation, David Carlisle notes that one can use a \\* to end a row and signify that a break should not occur at the next row. If all of the rows have this ending, there never appears to be a break mid-table and the desired behavior is achieved.

longtable documentation

You must log in to answer this question.

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