With a single paragraph layout, the sequence of elements contains only boxes and zero-length penalties. Multi-layout sequences will contain glues too, so they will be able to stretch and shrink.


The parameters involved are:

Possible situations

A line layout allows the paragraph to be split between consecutive pages only if it has more than (w + o) lines.

According to the relative position of the value (w + o) and min, opt and max, we can have four different situations:

  1. (w + o) <= min

  2. min < (w + o) <= opt

  3. opt < (w + o) <= max

  4. max < (w + o)

         min   opt        max
     ^          ^     ^          ^
     |          |     |          |
    w+o        w+o   w+o        w+o
    (1)        (2)   (3)        (4)

(w + o) <= min

This is a simple case: even the layout with fewest lines allows the paragraph to be split.

The first o lines and the last w lines cannot be parted because of the orphans and widows properties; between these two groups there are other opt-o-w(-m,+p) lines, and each one can be preceded or followed by a page break. These lines can be divided into three categories:

Note that, when we have more than a single layout, the elements in the sequence will not represent a "real" line (for example, the line starting at the 12th word and ending after the 16th one): they are only "place holders". So, adding or omitting a line does not mean that we are adding or omitting some content; it means that we have to increase or reduce text spacing so that the same content will generate more or fewer lines.

In particular, there are:

The mapping between lines and elements is quite simple:

min < (w + o) <= opt

This is a more complex situation: with the optimal quantity of lines (or with a greater one) the paragraph can be parted, while the minimal quantity of lines does not allow a break.

In other words, the whole sequence will have an overall shrink of opt - min, but a break will reduce the total shrink to opt - (o + w).

There is a new category of lines, "conditional eliminable lines": they can be omitted, but only if the paragraph is not parted.

There are:

The mapping between lines and elements is exactly like before, with two changes:

The overall effect of the glue elements in the breaker is glue(0, 0, 0): if the paragraph is not parted, they don't modify the available shrink; if the paragraph is parted, the first glue "cancels" the one in the first lines, while the second one is suppressed.

opt < (w + o) <= max

The optimal quantity of lines (and obviously a smaller one) does not allow the paragraph to be parted, while the maximal one does.

In other words, parting the paragraph involves an increase in the quantity of lines.

There is a new category of lines, "conditional optional lines": they can be used if the paragraph is not parted, while they must be used if the paragraph is parted.

There are:

The mapping between lines and elements is almost like before, with two changes:

max < (w + o)

This is the simplest case: the lines can never be parted, regardless of the line layout.

The whole paragraph is represented by the sequence box(opt) penalty(0, inf) glue(0, max - opt, opt - min) box(0).


The sequence created is correct if every line has the same height, which is undoubtedly the most common situation. Note that it is likely that a document with lots of inline content with different font sizes will not have display-align="fill", and anyway the filling could be achieved modifying other properties, for example spaces between blocks.

The algorithm could be easily modified in order to recognize and handle correctly even multi-layout paragraphs with lines having a different height (for example, because of inline content with a bigger font size), if these abnormal lines are always in the group of the first (or last) ones. For example, paragraphs starting with a big letter does not create serious problems, as it is enough to set the right height in the first box of the sequence.

Some more thought is needed in order to handle correctly a multi-layout paragraph with abnormal inline content in its middle, whose position depends on the line layout (for example, the inline object could be in the 4th or in the 5th line, according to the text spacing).

Note that these problematic situations can be easily recognized, and normally handled choosing the best layout: i.e. we can always, as a fallback, ignore alternative layouts with fewer or more lines.

MultiLayoutSequence (last edited 2009-09-20 23:52:32 by localhost)