Advanced Styling
Hyphenation
The CSS hyphens property specifies how the words should be hyphenated when
the paragraph text wraps on multiple lines.
- manual
- Words are only hyphenated when there are characters inside the word that explicitly
suggest hyphenation opportunities. Those characters are:
- U+2010 (HYPHEN) -
- The "hard" hyphen character indicates a visible line break opportunity. The hyphen is always shown in the output.
- U+00AD (SHY)
- An invisible, "soft" hyphen. This character is not rendered visibly. It
marks a breaking place for the word if hyphenation is necessary. You can use
­in XML or­in HTML.
- auto
- Words are hyphenated automatically according to an algorithm driven by a hyphenation
dictionary. Also, Oxygen PDF Chemistry uses an aggressive technique to create
hyphenation points at underscores, dots, and case changes. This is useful when your
publication contains snippets of code (Java, etc). To disable this functionality, you
can use the
-no-aggressive-hyphenationparameter.Note: The element, or one of its parents, must have alangorxml:langattribute present for the processor to identify the hyphenation dictionary. If this is missing, themanualhyphenation is performed.<table lang="en"> ... </table>
- none
- Currently not supported by Oxygen PDF Chemistry and it falls back to
manual. If your document does not use theHYPHENorSHYcharacters, no hyphenation is done.
Example: Hyphenation
p {
hyphens: auto;
}table {
hyphens: auto;
}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
The hyphenation dictionaries are located in: [CHEMISTRY_INSTALL_DIR]/config/hyph. The .xml files allow you to read the licensing terms. The .hyp files are the compiled dictionaries that Oxygen PDF Chemistry actually uses.
Oxygen PDF Chemistry uses the TeX hyphenation dictionaries converted to XML by the
OFFO project: https://sourceforge.net/projects/offo/.
- Download and extract the offo-hyphenation-compiled.zip file.
- Copy the
fop-hyph.jarfile to the [CHEMISTRY_INSTALL_DIR]/lib directory. - If you just need a single dictionary, extract the corresponding
.hypfile from that jar file and place it in the [CHEMISTRY_INSTALL_DIR]config/hyph directory.
How to Hide Hyphens
-oxy-hyphenation-character
property:pre {
-oxy-hyphenation-character:" ";
}Using XPath in CSS
You can collect and process the document contents using XPath, directly from CSS. The following example counts the words from a section and shows it in a static text after the section:
section:after {
contents: "Number of words: "
oxy_xpath("count(tokenize(normalize-space(string-join(text(), '')), ' '))";
}
All the standard XPath 2.0 functions are supported.
Multiple :before and :after Pseudo Elements
Although not standard, this extension may come in very handy if you want to style sections
from static content. To add static content to an element, you would normally use a
:before or :after pseudo element.
This example adds static text before the title ("Chapter 1", "Chapter 2", etc.):
h1:before {
content: "Chapter " counter(chapter) ".";
color: blue;
}
All of this is styled with the same color, blue in this example. Using standard CSS, it is
impossible to style just the chapter number with a larger font and with red, for example.
However, you can do it using multiple before pseudo elements:
h1:before(3) { content: "Chapter "; color: blue; } h1:before(2) { content: counter(chapter); color: red; font-size: large; } h1:before(1) { content: "."; color: blue; }
:before or
:after.