Hyphenation

There are various techniques for managing hyphenation in PDF output.

You can change the basic hyphenation settings (variables) in your book’s print-pdf.scss or screen-pdf.scss files. Our default stylesheets can ask Prince to hyphenate paragraphs and lists (p, ul, ol, dl), with a few exceptions (such as text on the title and contents pages). Prince includes a range of hyphenation dictionaries for major languages by default, which do a good job. However, you might need to add dictionaries or lists of specific words that Prince doesn’t support.

You can find .dic files online for various languages and specialities, or you can compile your own.

A .dic file is a plain-text file with one word or word-fragment on each line. Each one is called a pattern.

To show where a word or word-fragment can hyphenate, you add digits (1 to 9) to the pattern. The digits have special meanings:

For user discussion, see the Prince forums here: If you need to hack Prince’s built-in hyphenation dictionaries more deeply, see this forum post.

Use a custom dictionary

To use a custom dictionary, save the dictionary file to your styles folder, and insert its filename in your book’s print-pdf.scss and/or screen-pdf.scss files as the value of the $hyphenation-dictionary variable. For example:

$hyphenation-dictionary: "hyphenation.dic";

In hyphenation.dic, you can add patterns as described above. If your hyphenation.doc starts with YAML between three hyphens, Jekyll will process it, and you can use Liquid tags for extra power. For example, you can include other hyphenation pattern files saved alongside hyphenation.dic:

---
# This YAML makes Jekyll process this file.
# So you can use Liquid tags to include files
# such as other hyphenation dictionaries, e.g.
# `{% include_relative hyph-en-gb.pat %}`
# or to use hyphenation in certain cases, e.g. variants.
---

{% include_relative hyph-en-gb.pat %}

Or you can use custom hyphenation only in specific variants of your book:

{% if variant == "fantabulous" %}
.fan3tab5ulous.
{% endif %}

Also see the guidance on styles in translations.