I'm trying to tell longtable
to only issue a page break at one specific point (by using \\*
. Putting a \midrule
anywhere near that point causes a page break after the midrule, and not where I want it to be.
Consider this MWE:
\documentclass[12pt,a4paper]{article}
\usepackage{longtable,booktabs}
\begin{document}
\begin{longtable}{c}
bla \\* bla \\* bla \\* bla \\* bla \\* bla \\* bla \\*
bla \\* bla \\* bla \\* bla \\* bla \\* bla \\* bla \\*
bla \\* bla \\* bla \\* bla \\* bla \\* bla \\* bla \\*
bla \\* bla \\* bla \\* bla \\* bla \\* bla \\* bla \\*
bla \\* bla \\* bla \\* bla \\* bla \\*
bla \\*
Last line on this page \\
bla \\*%\midrule
bla \\*
bla \\* bla \\* bla \\* bla \\* bla \\* bla \\* bla \\*
\end{longtable}
\end{document}
It produces the correct result:
My problem comes up after uncommenting the \midrule
:
I tried preventing the page break after the \midrule
by inserting \nopagebreak
before and/or after it, but to no avail.
P.S.: I know that right fter a rule would usually be a desired point for a page break in a table. However, I am using rules before and after certain lines to create some kind of seperator between blocks of rows. Thus, the rule must stay on top of the following line and the page brak should occur right after the last \\*
before the rule.
Best Answer
The problem is not confined to booktabs: Also with a standard
\hline
you would get a break. longtable redefines\hline
so that it actually inserts two lines with a break point between them. This way a line at the bottom of a page is repeated on the top of the next page. You could define you a command which changes the penalty used by the\hline
and the width temporarly: