Forum How do I...?

Widows + Orphans in UL's...?

mike.bds
Hello,

I've been working with the latest version of PrinceXML and have run into a formatting issue. Basically, the Table of Contents I'm generating (in a series of nested ULs/LIs) is fairly long, and can't quite fit onto two pages. So a third page is generated - but only one line is needed.

What I'd like is for it to try to compensate by using the orphans/widows properties to try to steal some lines from the second page and 'bulk up' the third. However, 'widows' and 'orphans' only seems to apply to P tags, not ULs or LIs (as far as I can tell, unless I'm doing something wrong? I even tried putting the initial UL inside a P tag with those properties...)

(Here's an example of what's happening)

I can probably adjust my page margins slightly to accommodate for now, but should the number of pages change slightly as different content is added, the problem may happen again. So... if anyone can help, I'd appreciate it!

(NB: I've also had a similar issue with TABLES and TRs... where I'd like more than one row to appear on the next page/column if the table needs split...)

(EDIT: maybe widows/orphans just aren't working in the latest release? I found elsewhere in the output where a regular P doesn't seem to be treating it correctly...? But whether those properties work in ULs and TABLEs is another question)

Thanks!
Mike.
EM
Would something like li:last-child {page-break-before: avoid} work?
mikeday
The widows and orphans properties only apply to lines of text, so they won't move entire list items back and forth. However, they are supposed to move text within list items; I couldn't quite tell from your description which case you are referring to.
mike.bds
mikeday wrote:
The widows and orphans properties only apply to lines of text, so they won't move entire list items back and forth. However, they are supposed to move text within list items; I couldn't quite tell from your description which case you are referring to.


Well, in the example each line is its own LI. I was hoping that "widows" and "orphans" could be applied to the parent UL to keep the items together, at least so we didn't get a case of just one LI on the next page.

Similarly, with TRs, it'd be useful to have similar functionality with TABLES, so a lone row of a table isn't moved to a page on its own.

(EM: "li:last-child {page-break-before: avoid}" might work - thanks for the suggestion - but still, two lines on their own is still something I'd rather avoid. I usually like widows/orphans to be about 4 or 5... looks more substantial then... 8) )

Thanks,
Mike.
mikeday
Right, generalising the widows and orphans properties to apply to list items and table rows sounds like a sensible step to take, or perhaps we need to introduce a new mechanism to achieve this result. I've added this issue to the roadmap.
EM
mike.bds wrote:
EM: "li:last-child {page-break-before: avoid}" might work - thanks for the suggestion - but still, two lines on their own is still something I'd rather avoid. I usually like widows/orphans to be about 4 or 5... looks more substantial then... 8)
li:last-child {page-break-before: avoid}
li:nth-last-child(2) {page-break-before: avoid}
li:nth-last-child(3) {page-break-before: avoid}
li:nth-last-child(4) {page-break-before: avoid}

Just a suggestion; I haven't tried it myself.