Forum How do I...?

Controlling page breaks in tables


I am using the following rules to stop page breaks in the first two or last two rows of a table in order to prevent orphan rows.

table tr:nth-of-type(1),
table tr:nth-of-type(2) {
page-break-after: avoid;
page-break-inside: avoid;

table tr:nth-last-of-type(1),
table tr:nth-last-of-type(2) {
page-break-before: avoid;
page-break-inside: avoid;

It seems to work fine with long tables, but if I have a table with only 2 rows, the above rules always trigger a page break before my table even though it is not needed.

Any ideas?


That looks like a bug in Prince, we'll try to fix it for the next maintenance release. Thanks for letting us know! :)
The bug has been fixed, and Prince 6.0 rev 6 is now available for download. Thanks again! :)