6

It turned out for my document that LaTeX likes to hyphenate the German "Farbraum" (color space) as "Far-braum" (instead of "Farb-raum").

So I added \hyphenation{Farb-raum} and things looked good. However when realizing that composites like "Ausgabefarbraum" (output color space) is also hyphenated as "Ausgabefar-braum", I wonder whether there is a generic mechanism that would allow something like \hyphenation{*-farb-raum}? Or do I have to list all variants explicitly?

Test document:

\documentclass[a4paper,twoside]{report}
\usepackage[german]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
%\usepackage[pdftex,colorlinks]{hyperref}
\usepackage{makeidx}
\usepackage{showidx}
\makeindex
\begin{document}
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
Farbraum, Eingabefarbraum und Ausgabefarbraum
%
\end{document}
Werner
  • 603,163
U. Windl
  • 519

3 Answers3

6

The basic hyphenation algorithm uses rules based on patterns but in classic tex (including pdftex and xetex) hyphenation patterns may only be loaded into the format so to use a non standard pattern set you would have to rebuild the latex format (and make your format somewhat incompatible with other sites.

Hyphenation exceptions are designed to add additional words with explicit hyphenation points to help or over-rule the hyphens that are inferred by the patterns for the specified language. But as yo see you need to give essentially each word in that case.

Luatex drops this distinction and can load patterns in a "normal" run so if you want to experiment with \patterns then it can be easier to use luatex, even if finally you are going to use a pdflatex format with a custom set of patterns.

David Carlisle
  • 757,742
  • Unfortunately I know nothing about luatex and the differences from "normal" TeX. Are there any compatibility issues? – U. Windl Nov 17 '19 at 17:39
  • 1
    @U.Windl https://tex.stackexchange.com/questions/13593/the-differences-between-tex-engines/13601#13601 – David Carlisle Nov 17 '19 at 17:45
  • Unfortunately there are compatibility issues when using lualatex instead of pdflatex, like (inputenc) only UTF-8 supported.. – U. Windl Nov 17 '19 at 17:52
  • @U.Windl sure, but it is still much easier to test hyphenation patterns using luatex even if you finally use them with pdftex, as with pdftex you would have to build a new format to test any edit. there are almost no good reasons for not using UTF-8 in any document written this century, what encoding are you using? – David Carlisle Nov 17 '19 at 17:55
  • The encoding I'm using (for some obscure reason) is ISO Latin 1, i.e.: ISO Latin 15. – U. Windl Nov 17 '19 at 17:58
  • @U.Windl This site for example only supports UTF-8 so if you took your example code using [latin1] from your question and saved it to a new document, the new one would be utf-8 (and the inputenc declaration would be wrong) your example here only has ascii characters so it works but any accented characters or s-z ligatures copied from this site require utf-8 (unless you re-encode them back to the legacy encoding) – David Carlisle Nov 17 '19 at 18:01
5

Complementing David's answer, babel provides a higher interface to add patterns in luatex. For example:

\babelpatterns{gabefar4b3raum}

Unlike \patterns, this command can be used to modify existing patterns, too. For the meaning of the numbers, see How does TeX's hyphenation algorithm work?

Oddly enough, these words are hyphenated differently in pdftex (Eingabefar-braum) and luatex(Eingabefarb-raum).

Javier Bezos
  • 10,003
4

This may be too high a price to pay, but if you are willing to sacrifice a character in text mode (here I do with |), you can use it as a delimiter to trigger a hyphenation-algorithm reset. That way, once you define the hyphenation of the root word farb-raum, any occurrence in the document in which it appears as part of a larger compound word can be offset with | to properly reset the hyphenation.

\documentclass[a4paper,twoside]{report}
\usepackage[german]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
%\usepackage[pdftex,colorlinks]{hyperref}
\usepackage{makeidx}
\usepackage{showidx}
\makeindex
\let\svvert|
\catcode`|=\active
\def|{\ifmmode\expandafter\svvert\else\nobreak\hspace{0pt}\-\nobreak\hspace{0pt}\fi}
\hyphenation{farb-raum}
\textwidth 0pt
\begin{document}
\parbox{3in}{
Begin:
Farbraum, Eingabe|farbraum, Ausgabe|farbraum,
und Voll|farbraum|zentrum
}
Begin:
Farbraum, Eingabe|farbraum, Ausgabe|farbraum,
und Voll|farbraum|zentrum
$a|b$
\end{document}

enter image description here

  • If I understood that correctly, I'll have to insert "soft-hyphens" for each occurrence then. If so that's not what I've been asking for (Still the idea is interesting). – U. Windl Nov 17 '19 at 17:42