This question is a refinement of ConTeXt: avoid enumeration items across pages.
Given an itemgroup, each \item
contains one or more paragraphs or itemgroups, possibly mixed. I only want pagebreaks between paragraphs or itemgroups, with several exceptions:
- Never page break after the first paragraph, as it is somewhat of a heading
- Only break a paragraph or itemgroup (into pieces) if it is longer than some arbitrary number
X
. - When breaking a paragraph or itemgroup, ensure that each the length of each portion
Y
isY>X/Z
for some arbitrary numberZ
. The idea is to minimize orphans and widows especially for the second paragraph which is the main paragraph.
The example below demonstrates the types of paragraphs I'm dealing with.
- Rirst paragraph is always a single line.
- Other paragraphs or nested items are short, 1-5(+?) lines.
- Few paragraphs per item or items per nested itemgroups.
My last two points I considered to be more like guidelines. These are the problems I've been fighting:
- Page break after the first paragraph.
- Poor breaking of the second paragraph. If it's four lines then it is broken 2-2. I don't know if it could be broken 1-3/3-1 and 3-line paragraphs broken 1-2/2-1, or if the widow and club penalties prevent this. I'm not even sure I'd be comfortable having a 5-6 line paragraph broken up at all either. But yeah there's some arbitrary point (8?) were I would want paragraphs split, because horrible page breaks are horrible (and footer spill infinitely worse). When I say second I mean all remaining paragraphs... and that I care about the appearance of the second paragraph more than others. I've been fortunate to not have page breaks across itemgroups, but same guidelines should apply.
- Not comfortable with setting
\widowpenalty
or\clubpenalty
for the entire document.
\setupwhitespace[medium]
\starttext
\startitemize
\sym{>}\bold{Heading One}\hfill1
\samplefile{ward}
\sym{>}\bold{Heading Two}\hfill2
\samplefile{ward}
\samplefile{ward}
\sym{>}\bold{Heading Three}\hfill3
\samplefile{knuth}
\sym{>}\bold{Heading Four}\hfill4
\startitemize[joinedup,nowhite,after]
\item Some important point.
\item \samplefile{jojomayer}
\item Hmm shouldn't there be whitespace below?
\stopitemize
\samplefile{ward}
\sym{>}\bold{Heading Five}\hfill5
\samplefile{ward}
\startitemize[joinedup,nowhite,after]
\item Some important point.
\item \samplefile{jojomayer}
\item Hmm shouldn't there be whitespace below?
\stopitemize
\stopitemize
\stoptext
(page breaks may occur anywhere)
\vbox
would prevent the second paragraph from breaking even when necessary - assuming you could vbox each individual paragraph or itemgroup. And that\keeplinestogether
doesn't prevent a break after the first paragraph, and can cause nasty orphans/widows when a break is necessary.\starthead{<first par>} <other pars> \stophead
comes to my mind but that does not prevent pagebreaks within<first par>
. It could be modified though. For (2), what if the remaining space on the page is less thanX
? You will either get a horrible page break or spilling into the footer. For (3) this is a lot of work to implement. Basically you'd reimplement TeX's paragraph builder. To minimize widows and orphans it's easier to tune\widowpenalty
and\clubpenalty
.