Keep Constraints

Contact Us or call 1-877-932-8228
Keep Constraints

Keep Constraints

Often you will want to make sure that certain content is kept together. For example, a paragraph following a heading should stay with that heading. This type of thing is handled with the keep attributes described below.

keep-with-previous and keep-with-next

The keep-with-previous attribute instructs the processor to try to keep an FO on the same page, column and line as the previous FO. Similarly, the keep-with-next attribute instructs the processor to try to keep an FO on the same page, column and line as the following FO. You can be more specific by appending .within-line, .within-column, or .within-page to the attribute (e.g, keep-with-next.within-page). Possible values for these attributes are shown below:

  • An integer (e.g, 10) - specifies the strength of the constraint, so that the processor knows how to handle conflicting constraints. The higher the number, the stronger the constraint.
  • always - specifies a strength value of infinity (e.g., greater than any integer).
<fo:block font-weight="bold" keep-with-next="always"> Header </fo:block> <fo:block> Body </fo:block>

keep-together

The keep-together attribute is used to keep chunks of content together.

<fo:block keep-together="always"> <fo:block font-weight="bold"> Header </fo:block> <fo:block> Body </fo:block> </fo:block>

Note that breaks take precedence over keeps.

Next