# hyphenation not working

I really searched a lot and tried a lot of hints (also from this site), but I cannot get the global hyphenation command working.

In my text, I can set the correct hyphernation like this:

LensKit"=Frame"-work


but if I try to set it globally it's not working:

\hyphenation{LensKit-Frame-work}


What am I doing wrong?

Here is a small example of my code:

\documentclass[a4paper,twoside,11pt,ngerman]{book}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{ae,aecompl}
\usepackage{bibgerm}

\hyphenation{LensKit-Frame-work}

\clubpenalty = 10000
% Keine einzelnen Zeilen am Ende eines Abschnitts (Hurenkinder)
\widowpenalty = 10000 \displaywidowpenalty = 10000
% EOF

\begin{document}

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.   LensKit"=Frame\-work LensKit"=Frame\-work LensKit"=Frame\-work LensKit"=Frame\-work LensKit"=Frame\-work  LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework LensKit-Framework

\end{document}

-
A minimal example is needed. A possibility is that you're using babel and set the \hyphenation command at the wrong place. – egreg Jun 20 '12 at 9:10
sorry I posted this by mistake, I'm currently working on a minimal example – elton Jun 20 '12 at 9:12

There are a number of problems.

1. You're not loading babel, so the ngerman option doesn't do anything. Actually the bibgerm package loads the obsolete german package.

2. Your \hyphenation instruction refers to the word "LensKitFramework" without explicit hyphens. TeX never hyphenates a word with an explicit hyphen, unless the user authorizes it to do, for instance with the "- shorthand.

3. The packages ae and aecompl are obsolete.

4. The instruction \clubpenalty = 10000 *doesn't do what you're expecting.

Of course points 3. and 4. are not connected with the problem at hand, which you can solve by defining a macro:

\newcommand\LensKitFramework{LensKit"-Framework}
\hyphenation{frame-work}


Let's see the complete preamble:

\documentclass[a4paper,twoside,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{bibgerm}

\hyphenation{frame-work}

\clubpenalty = 10000
\makeatletter
\@clubpenalty = 10000 % LaTeX uses \@clubpenalty to restore the value of \clubpenalty
\makeatother
% Keine einzelnen Zeilen am Ende eines Abschnitts (Hurenkinder)
\widowpenalty = 10000 \displaywidowpenalty = 10000
% EOF

\begin{document}
\newcommand{\LensKitFramework}{LensKit-""Framework}

Here we use \LensKitFramework{} and it will hyphenate correctly.


The definition should go after \begin{document}, because it's only then that shorthands are activated.

-
Thanks to all these hints. I'm using a template for my diploma thesis. Seems it's a bit outdated :D – elton Jun 20 '12 at 9:59
@egreg Does it really matter where you put \newcommand? I thought it's excecuted at the place of usage, not definition... – yo' Jun 20 '12 at 10:16
@tohecz The problem of putting it into the preamble is that there the category code of " is 12, not 13. – egreg Jun 20 '12 at 10:22
Oh ok, I forgot that they get changed only afterwards. Thanks. – yo' Jun 20 '12 at 10:27

The following solution may be of relevance for people who don't use babel and hence can't use the methods proposed in the answers provided by @egreg and @DavidCarlisle.

Because the word "LensKit-Framework" already contains one explicit hyphen, TeX will not hyphenate the second (or, for that matter, the first) part of the long word. You can override this behavior either by writing

LensKit-\hspace{0pt}Framework


whenever this word crops up (TeX knows how to hyphenate Framework) or, more efficiently, define a macro such as

\newcommand{\LKF}{LensKit-\hspace{0pt}Frame\-work}


in the document's preamble and then use \LKF in the body of the document itself. With this setup, TeX will now break the word at the end of the line either after "LensKit-" or after "Frame".

Of course, if you wanted to let TeX choose a line break after "Lens" as well, you'd change the macro to

\newcommand{\LKF}{Lens\-Kit-\hspace{0pt}Frame\-work}

-

TeX does not automatically hyphenate explicitly hyphenated words. Your command

\hyphenation{LensKit-Frame-work}


tells TeX two possible optional hyphenation points in LensKitFramework but your document does not have that it has LensKit-Framework. In a word with explicit hyphen TeX only considers the explicit hyphen as a possible break point. (The babel "- shorthand essentially makes the construct look like two words to TeX so it does consider each part of the compound separately.)

It is possible to set the lccode of - (so the hyphenation algorithm considers it part of a word), but as the standard hyphenation tables don't include this "letter" it would have to be done with care and generally I think most people recommend using the explicit "-` construct or other explicit markup .

-