Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
2  
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 Sep 4 '10 at 7:48
    
Sometimes the hyphen in German words is sort of optional, sometimes it's mandatory, e.g. in "öffentlich-rechtlich" (public-law). –  lockstep Sep 4 '10 at 13:01
add comment

5 Answers

up vote 15 down vote accepted

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.

share|improve this answer
add comment

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

share|improve this answer
add comment

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.

share|improve this answer
    
It sounds like this does the same as babel's "= shorthand? –  Taco Hoekwater Sep 3 '10 at 18:58
    
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 Sep 3 '10 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. –  Andrew Stacey Sep 3 '10 at 19:21
add comment

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”.

share|improve this answer
2  
+1 -- now switching to LuaTeX really becomes tempting. –  lockstep Feb 28 at 18:38
add comment

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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.