Prince for Books

Prince for Books is a project that allows us to spend more time on features particularly sought by publishers.

The initial focus of work is on features common to all books: making the page-breaking and line-breaking choices expected of books.

Read more in the Prince for Books documentation section of the User Guide.

N.B. In order to benefit from the improved pagination (i.e. page makeup, where page breaks fall), you must specify what the pagination goals are, and what flexibility there is for achieving them.

As at the 20240704 release, Prince for Books offers the following types of flexibility for pagination:

  • -prince-change-line-breaks-for-pagination: yes’.

    This allows Prince to adapt line breaks to pagination goals, either to change the number of lines occupied by a paragraph (“make a line” or “save a line”, in the language of proofreaders), or to avoid hyphenating a word across a page boundary.

    This property inherits by default, so would usually be used in a rule for the root element.

  • -prince-resize-options: <length>#’, e.g. ‘blockquote { -prince-resize-options: 1rlh; }’, ‘h2 { -prince-resize-options: 1rlh, 2rlh; -prince-resize-adjust: padding-start; }’.

    This property allows Prince to add (or remove) space around an element or @footnotes region.

    The initial value of -prince-resize-adjust is ‘margin’ (i.e. dividing the requested adjustment equally between top & bottom margin). However, for @footnotes region, Prince by default sets -prince-resize-adjust to margin-top.

    Note that each element is considered more or less independently of the others: Prince does not yet allow coordinating changes within a page or spread, so be careful about applying this to headings if some pages have multiple headings.

  • -prince-spread-length-options (in @page): shorten | lengthen

    This property allows Prince to “run a spread short” (or long), i.e. leave less or more space for content on a page and its facing page.

Mechanisms that are not yet available (but which we hope to provide in future) include changing line height on a page (“feathering”, “carding”); changing paragraph spacing throughout a page; and pushing a heading etc. to the next page even when there's space for it and a couple of body lines at the end of the previous page (a valuable technique for some types of instructional material).

Pagination goals can be given by specifying where page breaks should be avoided, using the properties ‘widows’, ‘orphans’, ‘break-before/-after/-inside’.

(In the next release, there will also be -prince-min-start-length and -prince-min-end-length, which are somewhat like orphans and widows but for divs.)

For each of these properties, the value can optionally be preceded by the keyword ‘-prince-prefer’, which turns the requirement into a mere preference, which means that Prince will never add an obvious gap at the end of a page to satisfy that request. So either include or leave out -prince-prefer according to whether the request is important enough to leave a gap at the end of the page if necessary to satisfy the request.

See the sample stylesheet for the novel sample for how one might combine these properties to style a novel.

N.B. Starting from the 20240704 release, Prince for Books defaults to “galley layout” of paragraphs: it no longer avoids hyphenating across a page boundary (or makes any other pagination-directed change) unless -prince-change-line-breaks-for-pagination for that paragraph is set to yes. This property inherits by default, so it suffices to add “:root { -prince-change-line-breaks-for-pagination: yes; }” to the stylesheet.

Downloads

Changes

2024-07

Synchronised with Prince latest build 2022-07-04. Provided pagination optimization. Use a small amount of letter-spacing to justify lines where there is insufficient other justification opportunity.

2022-08

Synchronised with Prince latest build 2022-07-01.

2021-04

Synchronised with Prince 14.1.

2019-11

Synchronised with Prince 13.

2018-10

MacOS X

  • Fixed bug affecting fonts on MacOS 10.14 (Mojave).

Line breaking

  • Better handling of paragraphs containing a float, including the case of a drop cap.

    (The line breaking will still be non-optimal around where each float starts and ends, where the line width changes, but most of the paragraph will now be more consistent with the rest of the document.)

  • Line breaking in multi-line headings now uses lookahead by default.

2018-09

Spread balancing

  • Change the balancedness criterion to include bottom margin, allowing that margin to be truncated for purposes of deciding whether the two pages can be considered to have the same length.

  • New @page property prince-page-fill to allow suppressing spread balancing.

    Note that in this initial release, the value to suppress spread balancing is called auto, whereas in future releases the value will instead be called prefer-fill. CSS error-handling rules allow giving one declaration with each value for now.

Line breaking

  • Make spacing in justified paragraphs less dependent on the width of the font's space glyph.

  • Minor other line-breaking tweaks, including reducing degree of insistence on the last line being a fair proportion of the measure; and slight increase in insistence of being at least as long as the text indent.

2018-06

Based on Prince 12.

Line breaking

  • Try harder to avoid violating a requested prince-hyphenate-lines limit.
  • German:
    • Use different line-breaking trade-offs for paragraphs marked up as being in German (as judged by the same rules as for :lang(de)).
    • Hyphenation changes.
  • Minor other line-breaking changes.

Ragged line breaking

  • Change canonical property name from prince-text-wrap to prince-line-break-choices, but retain prince-text-wrap as alias.
  • Renamed initial value from css-text-4–style wrap to body.
  • New values 'body-lookahead', 'heading-lookahead', 'title-lookahead', to enable paragraph-at-a-time line breaking for non-justified text: that is, to allow revisiting an earlier line to improve a later line, rather than deciding line ends one at a time before seeing what problems arise in the rest of the paragraph. The *-lookahead values will usually improve line-breaking choices in ragged paragraphs (at the cost of using more time and memory), and we expect them to become the default in future releases once we've had more experience that they don't cause significant regression; please let us know if you find they make anything worse.
  • New value fast, for quick web-browser–style line breaking: useful for testing the effect of styling changes that don't depend on good line breaking.

2018-04

Hyphenation

  • Reduce aversion to hyphenation at end of a page, especially on verso pages, or if the hyphenation is at a natural break in the word, or if the paragraph is marked as being in German.
  • More aversion to dividing the first word in a hyphenated phrase.
  • Fix a problem in German hyphenation inference (wrongly breaking mid-word after ‘sch’).

2018-02

  • Hyphenation updates, mainly for chemistry terms
  • New property prince-text-wrap: wrap | heading | title. [Renamed to prince-line-break-choices in 2018-04.]
  • Penalize breaking before a dash or ellipsis
  • Allow breaking before or after dash
  • Penalize word division within hyphenated phrase
  • Fix division by zero bug

2017-07

Hyphenation

  • Better treatment of English compound words.
  • English dictionary based hyphenation.

2017-03

Pagination

  • Reduce number of uneven spreads.

Hyphenation

  • Don't hyphenate as often for ragged text.

2015-05

Line breaking

2015-04

Pagination/hyphenation

  • Try harder to avoid a hyphen at the end of a page.

Line breaking

  • Try to avoid a short last line, especially if shorter than text-indent.
  • Weakly try to avoid a hyphen at the end of the last full line.
  • Be more willing to have a loose line for the first line of a paragraph.

Command-line

  • No longer need --books flag. Add --web-layout flag.

German language

  • Significantly improve choice of where to hyphenate a word. (Please let us know of cases we still get wrong!)

Short-term Roadmap

  • Pagination: Treat pagination as an optimization problem, and adjust line-breaking decisions to improve pagination.
  • Line breaking: Improve line breaking of ragged text (such as headings and table cells).
  • Pagination: Some mechanism to allow a widow line if it is at least k% full.
  • Baseline grid: Initial simple mechanisms for a baseline grid.
  • Hyphenation: Improved hyphenation choices for English, especially in compound words (“handwritten”).