11

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.

3
  • 1
    Kontrast/Rausch-Ver\-hält\-nis
    – Sigur
    Jul 28, 2014 at 12:54
  • 1
    Would you allow breaking at the slash? If not, use Kontrast/Rausch"=Verhältnis
    – egreg
    Jul 28, 2014 at 12:59
  • 1
    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, 2014 at 13:24

3 Answers 3

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

5
  • 1
    How can I use this for defining global rules? \hyphenation{Kontrast/Rausch"=Verhältnis} gives LaTeX error "Not a letter"?
    – Robinaut
    Jul 28, 2014 at 13:18
  • 1
    @Robinaut You can't.
    – egreg
    Jul 28, 2014 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, 2014 at 13:23
  • Can you also write Kontrast\slash{}Rausch\hyp{}Verhältnis?
    – user
    Apr 8, 2019 at 3:17
  • @user Yes, if \hyp does the same as "=
    – egreg
    Apr 8, 2019 at 6:18
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

3
  • Unfortunately this is not working with the nomecl package
    – Robinaut
    Jul 28, 2014 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, 2014 at 13:48
  • Just for reference: Here is my Spickzettel for such things.
    – LaRiFaRi
    Jul 28, 2014 at 13:55
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

1
  • That's a good point...
    – Robinaut
    Jul 29, 2014 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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