Forum Bugs

orphans/widows leading to unexpected page break behaviour

isa
I tried to generate a pdf using a stylesheet in css and also a stylesheet from mediawiki in php, but which also was written in css. The combination of these two led to some unexpected behaviour concerning page breaks.

So headings were alone at the end of the page while the rest of the section was on the next page and also sometimes just one word stood alone at the beginning of a new page while the rest was on the page before. Reason therefor were not the page break commands but the orphans and widows command in the php file.

First try was to reset the values to default or a lower value but only if I commented these two lines out the problem was fixed.

Here are two pdfs to show this problem.
  1. test_correct_style.pdf29.9 kB
  2. test_wrong_style.pdf29.9 kB
mikeday
You can also try applying "page-break-after: avoid" to the heading elements.
isa
I attached now the php file. There it can be seen that for all headings there is a page-break-after: avoid command but this does not have any effect.

Look at line 2187. Only taking out the commands orphans/widows in line 2193/2194 affected the behaviour.
  1. load.php55.2 kB
mikeday
What does the markup for the headings look like? Are they wrapped up inside other block elements?
isa
Maybe the html helps here. I don't know whether I used markups...
  1. test_debug.html1.7 kB
mikeday
These are h2 and h3 elements not h6, also the CSS rules inside "@media screen" blocks will not apply, but I am not sure if that is sufficient to explain it yet as it is a big style sheet with many rules.
isa
But the rules are for all h elements from h1 until h6 all set in the same way
mikeday
It turns out to be because of this rule:
    p:before {
        content: "";
        display: block;
        width: 120pt;
        overflow: hidden; 
    }

This empty invisible block is being placed after the heading, then the rest of the paragraph is placed on the next page. You can fix the layout by removing this (unnecessary?) block, or by adding "page-break-after: avoid" to it.
pjrm
I attach the stylesheet that I'm currently using for wikipedia, which addresses a couple of other such issues.

(It does also include setting font-family and some widths, so you might want to comment out or remove some of that.)
  1. wp.css7.9 kB
    A user stylesheet for use on Wikipedia
RBK
This is a trove of workarounds for some really weird MediaWiki CSS settings!

Could you, please, report the findings as MediaWiki bugs? Let's hope they will improve things.