127

Unlike in English, in German there are quite a few words that contain a hyphen, e.g., "Arbeiter-Unfallversicherung" (workers' accident insurance). By default, (La)TeX will only break such words after the existing hyphen and disregard all other breakpoints. This behaviour will often result in overfull hboxes for German texts.

There are at least three ways to achieve proper hyphenation, two of which use shorthands of the babel package and none of which I consider to be really satisfactory:

  1. The "= shorthand: Arbeiter"=Unfallversicherung. This allows every (otherwise legal) breakpoint and therefore may produce correct but unfavourable hyphenation (e.g. Arbeiter-Un-fallversicherung). This seems to be a method of last resort, suited for documents to be created with (almost) no manual intervention.

  2. The \- command: Ar\-beiter-Unfall\-ver\-si\-che\-rung. By manually setting allowed breakpoints, one can avoid unfavourable ones shortly before or after a present hyphen (I use a minimum of four characters as a rule of thumb). As a downside, one has to look up the correct breakpoints of the respective words. Also, the body of a LaTeX document may become quite cluttered.

  3. The "- shorthand: Ar"-beiter-Unfall"-versicherung. This method (the one I'm currently using) also avoids unfavourable breakpoints and allows for a tidier document body. But one still has to look up the correct breakpoints.

To cut a long story short: Is there a way to automatically allow hyphenation of words already containing a hyphen, while disregarding breakpoints less than, say, four characters before or after the existing hyphen?

3
  • 4
    Just a side note (I have no solution for the real problem): I would find “Arbeiterunfallversicherung” more natural looking in German. Duden even has the entry “Arbeiterunfallsversicherungsgesetz”, though in the section on adding hyphens it does concede that one could add a hyphen there. (The ÖWB doesn’t have a corresponding entry.)
    – Caramdir
    Commented Sep 4, 2010 at 7:48
  • 3
    Sometimes the hyphen in German words is sort of optional, sometimes it's mandatory, e.g. in "öffentlich-rechtlich" (public-law).
    – lockstep
    Commented Sep 4, 2010 at 13:01
  • Just using the "= command instead of the hyphen - totally works as this was recommended by Taco Hoekwater belwo the \hyp{} recommendation Commented Jul 29 at 19:50

6 Answers 6

23

No. You could possibly use an external parsing script to apply one of those options to a text, but writing that would still be a lot of work, so manually adding commands is probably less work in practice.

Future update: LuaTeX has rudimentary support for some special hyphenation cases, and in a future version (spring 2014, most likely) there will be core support for weighted hyphenation and multiple hyphenation passes.

3
  • 8
    Are there now some news about the special hyphenation in LuaTex? Commented Jun 1, 2014 at 22:22
  • 7
    What is the situation in 2018? Any news? Commented Jan 24, 2018 at 9:50
  • I'm just a beginner in using LuaTeX, but here's an example of allowing hyphenation within words already containing a hyphen. One could extend that with a pre- or post- pass that does more tweaking, e.g. not allow hyphenation “near” the hyphen, etc. Commented Mar 2, 2018 at 6:33
48

This seems to be what the hyphenat package is for. From the manual:

TeX does not want to hyphenate a word that appears in the source already hyphenated, such as electromagnetic-endioscopy.
The \hyp command is like the other \...hyp commands, only it typesets a hyphen and allows full automatic hyphenation of the other words forming the compound word. It is used like electromagnetic\hyp{}endioscopy.

I'm not sure about your last criterion, though it seems that if TeX applies its normal hyphenating rules then this would be unlikely to happen anyway since (I think) that what happens is that the word after the \hyp{} is treated (as far as hyphenation is concerned) as a new word and I guess that not many words get hyphenated in the first (or last) few characters.

6
  • 2
    It sounds like this does the same as babel's "= shorthand? Commented Sep 3, 2010 at 18:58
  • 1
    The effect of the \hyp{} command seems to be similar to that of the "= babel shorthand. As far as I understand, the text before and the one after these commands are treated as separate words. Unfortunately (regarding to my question), words that may be hyphenated with only two characters separated from the rest are quite common in German.
    – lockstep
    Commented Sep 3, 2010 at 19:08
  • @lockstep: I wondered about that, but figured that if you knew about hyphenat then you'd've explained why it didn't work so thought it worth at least mentioning. Commented Sep 3, 2010 at 19:21
  • Only electromagnetic\BreakableHyphen{}endioscopy works for me (KOMA-script book, babel frenchle, LyX). Of course, as I am under LyX, \BreakableHyphen{} is in a TeX box.
    – lalebarde
    Commented May 8, 2014 at 11:09
  • 3
    @TacoHoekwater The solution of \hyp{} is much more broad, for example it works with Polyglossia under XeLaTeX while the "= shorthand does not!
    – Paulo Ney
    Commented Apr 2, 2016 at 21:46
27

With LuaTeX, a simple solution is to enter explicit hyphens in the \hyphenation command as =.

\hyphenation{Ar-beiter=Unfall-ver-si-che-rung}
\showhyphens{Arbeiter-Unfallversicherung}
\bye

After compiling this document with LuaTeX, the .log file shows that hyphenation is possible

[][] \tenrm Ar-beiter-Unfall-ver-si-che-rung

with hyphenations Arbei-ter... and ...Un-fallversicherung omitted as requested by the \hyphenation command.

That way, no further mark-up is required in the document source for LuaTeX to handle (a selection of) words automatically. It's not a fully automatic solution, though, since an explicit list of words needs to be maintained. And all hyphens are hard-coded, i.e., changing inner word hyphen minima is tedious. Still room for improvements ...

The LuaTeX manual has some more information on hyphenation related differences to Knuth's TeX in section “Languages and characters, fonts and glyphs”.

3
17

You can set \lefthyphenmin=4 to ensure at least 4 characters after the explicit "= hyphen before any hyphens inserted by tex. (It really sets that there should be 4 characters after the beginning of any word, not only compound words with a "=.)

It's possible to make the change to \lefthyphenmin locally, but it is awkward. Tex only looks at the value of \lefthyphenmin at the beginning of paragraphs and at language changes, so you have to write something like: {\lefthyphenmin4\setlanguage\language ...}\setlanguage\language

0
4

See egreg’s answer to question Why can words with hyphen char not be hyphenated?

Indeed, if you try the following example, you'll see that TeX hyphenates the compound word:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\begin{document}
\hyphenchar\font=\string"7F

\parbox{1pt}{In Baden-W\"urttemberg}

\end{document}
-5

A simple solution is to use the -- character instead of a hyphen. This produces a wide hyphen (m-bar) and does not prevent the hyphenation of any of the joined words. An advantage of this approach is that it becomes graphically clear where the original hyphen was and where a hyphen was inserted. Of course, you only want to use this approach in words that need to be hyphenated.

6
  • 10
    Sorry, but using -- does prevent hyphenation in the joined words.
    – egreg
    Commented Nov 16, 2015 at 13:47
  • 15
    Besides @egreg's remark: this is typographically unacceptable.
    – cgnieder
    Commented Nov 16, 2015 at 13:47
  • @egreg, I use XeLaTex and it works fine.
    – Ariel
    Commented Nov 17, 2015 at 15:25
  • @clemens, I beg to disagree, this is typographically much better than having two identical hyphens in a composite word.
    – Ariel
    Commented Nov 17, 2015 at 15:26
  • 1
    @Ariel I know that typography is not a science so there is no absolute truth but I'm still curious: do you know of any typographer who supports your claim? Any typographic book which has the same advice?
    – cgnieder
    Commented Nov 17, 2015 at 15:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .