# Hyphenation of words containing slash

How can I tell LaTeX to automatically split up the german word

Kontrast/Rausch-Verhältnis


into

Kontrast/Rausch-|Ver|hält|nis

LaTeX complains that "/" is not a letter.

-
Kontrast/Rausch-Ver\-hält\-nis –  Sigur Jul 28 at 12:54
Would you allow breaking at the slash? If not, use Kontrast/Rausch"=Verhältnis –  egreg Jul 28 at 12:59
please give us an MWE showing what you are trying to do. There was not one word about nomencl in your question. –  LaRiFaRi Jul 28 at 13:24

A hyphen allowing hyphenation in the following word is obtained in babel-german with "=; if you want also to allow breaking at /, use \slash for it:

Kontrast/Rausch"=Verhältnis}


with no break at /, or

Kontrast\slash Rausch"=Verhältnis


if breaking at / is allowed.

Here's a document showing the various possibilities; the narrow \parbox is just to force TeX into hyphenating as much as possible.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\begin{document}
\parbox{24pt}{\hspace{0pt}Kontrast/Rausch-Verhältnis}

\bigskip

\parbox{24pt}{\hspace{0pt}Kontrast/Rausch"=Verhältnis}

\bigskip

\parbox{24pt}{\hspace{0pt}Kontrast\slash Rausch"=Verhältnis}
\end{document}


-
How can I use this for defining global rules? \hyphenation{Kontrast/Rausch"=Verhältnis} gives LaTeX error "Not a letter"? –  Robinaut Jul 28 at 13:18
@Robinaut You can't. –  egreg Jul 28 at 13:19
My original problem is that using the nomencl package for creating a nomenclature the hyphenation rules above are completely ignored. –  Robinaut Jul 28 at 13:23

For hyphenation in German, I would recommend the shorthands of the babel package. I inserted your desired result (2.), the two versions mentioned in comments (3. and 4.) and the version, I would use (5.). This version forbids a hyphenation which is too close to the hyphen (one syllable to the left and right). In my opinion, such close consecutive hyphens make the word difficult to read. If you want to allow the hyphenation behind the slash as well, you can use the last (6.) version:

% arara: pdflatex
% arara: nomencl
% arara: pdflatex

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{nomencl}
\makenomenclature
\setlength{\parindent}{0ex}
\setlength{\textwidth}{0.3cm} % for testing
\begin{document}

% without treatment
1. Kontrast/Rausch-Verhältnis

2. \mbox{Kontrast}/Rausch-Ver"-hält"-nis

% egregs version from comment
3. Kontrast/Rausch"=Verhältnis

% Sigurs version from comment
4. Kontrast/Rausch-Ver\-hält\-nis

% my recommendation
5. Kon"-trast/Rausch-Verhält"-nis

% allowing hypenation after the slash
6. Kon"-trast/""Rausch-Verhält"-nis

\nomenclature[Strings]{KRV1}{Kontrast/Rausch-Verhältnis} % same as above
\nomenclature[Strings]{KRV2}{\mbox{Kontrast}/Rausch-Ver"-hält"-nis} % same as above
%\nomenclature[Strings]{KRV3}{Kontrast/Rausch"=Verhältnis} % not working. Replace with:
\nomenclature[Strings]{KRV3}{Kon"-trast/Rausch-Ver"-hält"-nis} or by:
%\nomenclature[Strings]{KRV3}{Kontrast/Rausch""=Verhältnis}
\nomenclature[Strings]{KRV4}{Kontrast/Rausch-Ver\-hält\-nis} % same as above
\nomenclature[Strings]{KRV5}{Kon"-trast/Rausch-Verhält"-nis} % same as above
%\nomenclature[Strings]{KRV6}{Kon"-trast\""Rausch-Verhält"-nis} % not working. Replace /"" by \slash{}
\nomenclature[Strings]{KRV6}{Kon"-trast\slash{}Rausch-Verhält"-nis}

\printnomenclature
\end{document}


Edit:

as requested, I inserted these versions into items of the nomencl package. Two of them did not work. See the comments in code. I replaced these two version by working ones.

-
Unfortunately this is not working with the nomecl package –  Robinaut Jul 28 at 13:33
@Robinaut Please see my update. All versions will now work and you just have to choose one. If this is not working, you will have to give us an MWE. –  LaRiFaRi Jul 28 at 13:48
Just for reference: Here is my Spickzettel for such things. –  LaRiFaRi Jul 28 at 13:55

Rethink the spelling: The recommended spelling is Kontrast-Rausch-Verhältnis with two hyphens. No need for a fancy slash here.

Then of course one of the following packages is indicated

\usepackage{ngerman}

or

\usepackage[ngerman]{babel}

Also do not forget the following package (otherwise Verhältnis will not hyphenate)

\usepackage[T1]{fontenc}

and finally write

Kontrast"=Rausch"=Verhältnis

-
That's a good point... –  Robinaut Jul 29 at 8:33