Forum › How do I...?

Title: Uneven column balancing with column-span: all and mixed content (Prince 16.2)

Striped Elephant
Hi,

We're evaluating Prince XML 16.2 for generating professionally typeset, two-column A4 annual reports from HTML/CSS.

We have run into a column-balancing issue that we haven't been able to resolve, despite several controlled experiments.

Expected behavior

We want text to flow automatically from the left column to the right column and continue onto subsequent pages.

On the final page of a chapter, we would expect column-fill: balance to distribute the remaining content so that both columns end at approximately the same vertical position, subject to normal widow/orphan and keep-together constraints.

Actual behavior

With a long chapter containing only paragraphs, Prince balances the final page quite well: the two columns finish within approximately one text line (14pt).

However, when the document contains a full-width figure (column-span: all), a metrics block and a blockquote, the final page has a significantly uneven column ending.

In our attached example, the right column ends 73.5pt (more than five body-text lines) below the left column.

Our main CSS settings are:

.flow {
column-count: 2;
column-gap: 7mm;
column-fill: balance;
font-size: 10pt;
line-height: 14pt;
}

p {
font: 10pt/14pt Arial, sans-serif;
margin: 0 0 14pt;
orphans: 3;
widows: 3;
hyphens: auto;
}

.wide {
column-span: all;
break-inside: avoid;
}

What we've already tested

column-fill: auto versus balance.

A full-width figure using column-span: all.

Splitting the multicolumn container into separate containers before and after the figure. In our particular example, this produced an identical PDF.

Using -prince-float: page top. This improved the final column balance somewhat, but moved the figure above the chapter heading, which is not acceptable for our layout.

Changing the line-height on the multicolumn container while keeping paragraph line-height fixed. No observable change.

Testing whether an explicitly multicolumn footer could affect pagination. No observable change in our setup, which uses @page margin boxes rather than an HTML footer.

Our questions

Is this expected behavior when balancing columns containing mixed content and a column-span: all element?

Is there a recommended HTML/CSS structure for achieving more consistent column balancing across pages, while preserving automatic text flow?

Can Prince balance the final columns more accurately without manually assigning text to individual columns or introducing explicit column breaks?

Is this behavior different in Prince 17 or Prince for Books?

We are not looking for perfectly equal columns at the expense of good typography. A difference of one line can be reasonable. However, differences of five or more lines are difficult to accept for professional typesetting when the content appears to offer opportunities for better balancing.

I've attached the HTML test case and resulting PDF so the issue can be reproduced.

Any advice from the Prince team would be greatly appreciated.

Thanks!
  1. prince-diagnostic-control.html‎ 7.4 kB
  2. prince-diagnostic-control.pdf‎ 76.2 kB
pjrm
Thank you for writing this up and attaching the CSS & HTML.

This apparent unbalance arises simply because there aren't many places in the vicinity where it is permitted to end the first column: the blockquote has break-inside:avoid and is in-flow, the paragraphs have orphans:3 and widows:3, and the heading has break-after:avoid. Even if the blockquote were made into a column float, you wouldn't be able to push that heading into the first column without dragging the whole of the following paragraph with it, due to the break-after:avoid and orphans:3 and widows:3 (and the fact that the paragraph is only 5 lines long, so these orphans & widows constraints become essentially equivalent to break-inside:avoid). This would make it even less balanced.

So the expected behaviour, "both columns end at approximately the same vertical position, subject to normal widow/orphan and keep-together constraints" is the actual behaviour: i.e. if the only thing you can control is where in the content to end the first column and start filling the second column, then the two columns are already as close as possible in length subject to the widow/orphan and keep-together constraints.

If you are to make the second page more balanced, then you'd have to move content to or from the previous page, by things such as changing the size or padding around illustrations (such as the column-spanning element in this example), adding space around headings, changing space between paragraphs, or pushing a heading from near the bottom of one column to the top of the next.

E.g. in this case, merely pushing the Samenwerking heading to the next column is enough to make the two columns on page 3 be approximately level. (If you took this option then you might then want to adjust the styling of the ‘In één oogopslag’ block to make it fill the space better.)

I usually put these sort of adjustments into separate stylesheet (‘typeset.css’), to keep them separate from the main styling: if the content or main styling subsequently changes, then some or all of the adjustments might no longer be appropriate, and the file can be either discarded entirely or reviewed to see which adjustments are still appropriate.

Relatedly, I'd suggest that pushing the heading to the next column might be better accomplished by extending the keep-together constraints (e.g. #samen+p { orphans:4 }) rather than the more obvious ‘#samen { break-before: column }’, just to make it less likely that this rule becomes harmful to the layout if the content or main styling subsequently changes.
Striped Elephant
Hi,

Thank you for your detailed explanation and practical suggestions. This confirms our understanding of the column-balancing constraints.

The suggestion to keep typesetting adjustments in a separate stylesheet, and to prefer flexible constraints over explicit column breaks, is particularly helpful.

Thanks again for taking the time to look into this!

Best regards,
René