Hyphenation
Hyphenation specifies how words should be hyphenated when text wraps across multiple lines.
The transformation plugin uses the capabilities of the PDF Chemistry processor to perform hyphenation.
Hyphenation Dictionaries
| Code | Language |
|---|---|
| da | Danish |
| de | German |
| de_CH | German (Switzerland) |
| en | English |
| en-GB | English (Great Britain) |
| es | Spanish |
| fr | French |
| it | Italian |
| nb | Norwegian Bokmål |
| nl |
Dutch |
| ro | Romanian |
| ru | Russian |
| sv | Swedish |
| th | Thai |
| pt | Portuguese |
| da | Danish |
The built-in hyphenation pattern license terms are listed in the XML files in the [CHEMISTRY_INSTALL_DIR]/config/hyph folder. Most of them comply with the LaTex distribution policy.
Installing New Hyphenation Dictionaries
Oxygen XML Editor uses the TeX hyphenation dictionaries converted to XML by the OFFO project: https://sourceforge.net/projects/offo/.
The .xml files allow you to access the licensing terms and you can use them as a starting point to create customized dictionaries (see How to Alter a Hyphenation Dictionary).
The .hyp files are the compiled dictionaries that the Oxygen XML Editor actually uses.
- Download and extract the offo-hyphenation-compiled.zip file. This file is a bundle of many dictionary files.
- Copy the
fop-hyph.jarfile to the [OXYGEN_INSTALL_DIR]/lib directory. - If you
just need a single dictionary, place the
.hypor.xmlfile in the [OXYGEN_INSTALL_DIR]/config/hyph directory (create that directory if it is missing).
How to Alter a Hyphenation Dictionary
You can copy the dictionaries you need to change in another directory, then use the
-hyph-dir parameter to refer them inside your transformation.
Each file is named with the language code and has the following structure:
<hyphenation-info> <hyphen-min before="2" after="3"/> <exceptions> o-mni-bus ... </exceptions> <patterns> préémi3nent. proémi3nent. surémi3nent. .... </patterns> </hyphenation-info>
- exceptions
- Contains the list of words that are not processed using the patterns, each on a single
line. Each of the words should indicate the hyphenation points using the hyphen ("-")
character. If a word does not contain this character, it will not be hyphenated.
For example,
o-mni-buswill match theomnibusword and will indicate two possible hyphenation points.Note: Compound words (like "e-mail") cannot be controlled by exception words. - patterns
- Contains the list of patterns, each on a single line. A pattern is a word fragment,
not a word. The numbers from the patterns indicate how desirable a hyphen is at that
position.
For example,
tran3s2actindicates that the possible hyphenation points are "tran-s-act" and the preferable point is the first one, having the higher score of "3".
How to Enable Hyphenation for Entire Map
To enable hyphenation for your entire map:
- Make sure you set an
@xml:langattribute on the root of your map, or set thedefault.languageparameter in the transformation. - In your customization CSS,
add:
:root { hyphens: auto; } - To except certain elements from being hyphenated, use
hyphens:none. The following example excludes the<keyword>elements from being hyphenated:*[class ~= "topic/keyword"] { hyphens: none; }
How to Enable/Disable Hyphenation for Tables
To enable hyphenation for your entire map:
- Make sure you set an
@xml:langattribute on the root of your map or your table elements. - The built-in CSS already has the following rule defined that activates
hyphenation:
*[class ~= "topic/table"] { hyphens: auto; }Note: To disable table hyphenation, add the following in your customization CSS:*[class ~= "topic/table"] { hyphens: none; } - To prevent certain elements from being hyphenated, use
hyphens:none. The following example excludes the<keyword>elements from being hyphenated:*[class ~= "topic/keyword"] { hyphens: none; }
How to Disable Hyphenation for a Word
To disable hyphenation for a specific word, there are several possible approaches:
- If the word is a compound (like "T-shirt") and you want to keep it on the same line, you
have two options:
- Manual Approach
- Wrap the word in an inline element with the
@outputclassattribute set. In the CSS, change its style towhite-space:nowrap;. For example:.. <ph outputclass="no-hyphenation">T-shirt</ph>...
*[outputclass ~= "no-hyphenation"] { white-space: nowrap; } - Automatic Approach
- A better alternative to this is to write an XSLT extension that matches the text
nodes and performs automatic markup (to see an example, go to How to Wrap Words in Markup in the XSLT Extensions for PDF Transformations section). Then match the
compound-wordclass the same as in the previous example:*[outputclass ~= "compound-word"] { white-space: nowrap; } - Another Alternative
- In all the compound words from your documentation, replace the hyphen ("-") with a
non-breaking hyphen character
U+2011(or XML notationߛ).Then change the autocorrect settings to automatically replace the compound word with its equivalent. For example: "T-shirt" would be replaced with "T[\u2011]shirt".
- If the word is not a compound, you have two options:
- Use one of the approaches listed above.
- Alter the hyphenation dictionaries as explained in: How to Alter a Hyphenation Dictionary.