12

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.

Robinaut
  • 1,061
  • 1
  • 9
  • 16

3 Answers3

14

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}

enter image description here

egreg
  • 1,121,712
4

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   

% your desired result
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}

enter image description here

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.

enter image description here

LaRiFaRi
  • 43,807
3

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