1

I'm using 'und/oder' (German for 'and/or') in one of my texts (I know it's not nice :)). Latex separates it 'und/o-der' which is not nice. Using \mbox fixes that problem.

Trying to find a general solution like

\hyphenation{und/oder}

does not work though: 'Improper \hyphenation will be flushed. \hyphenation{und/'.

What would be the correct way to archive this?


Related to this, but somewhat different.

2 Answers2

1

Two suggestions:

  • Don't write und/oder; instead, write und\slash oder. This will allow TeX to insert a line break (without hyphenation character, of course) after "und/".

  • Do insert the instruction

    \hyphenation{oder}
    

    in the preamble of your document. This will prevent the highly questionable o-der hyphenation from happening in the first place.

A separate remark: Your document appears to be (mainly?) in German. If so, are you loading the babel package with the option ngerman (or german, if you adhere to older rules of orthography)? Enabling babel in this manner will inform TeX that the applicable hyphenation rules are for German, not English.

Mico
  • 506,678
  • If you have a custom hyphenation pattern for the first word, you have to include the slash as well: \hyphenation{Clang} \hyphenation{Clang/}. – corvus_192 Apr 10 '20 at 11:48
  • @corvus_192 - I'm afraid I don't understand your comment. – Mico Apr 10 '20 at 13:36
  • In my case, the first part of the word (before the slash) is "Clang" (the C compiler). Latex by default hyphenates this as "Clan-g", which is wrong. So I added a custom rule hyphenation{Clang}. I ran into the problem that before a slash, "Clang" was hyphenated as "Clan-g", even though I had specified the custom hyphenation pattern. The problem is that the pattern "Clang" is not applied to "Clang/", so I had to add the rule hyphenation{Clang/}, so that the word is correctly hyphenated before a slash. I was commenting here in case someone else has this issue. – corvus_192 Apr 11 '20 at 14:36
  • @corvus_192 - Thanks for providing this piece of follow-up information. You've now made me curious, though: have you set \righthyphenmin=1 by ahy chance? If not, TeX should never even contemplate hyphenating the word "clang" as "clan-g". (For reference: For English language hyphenation rules, one usually sets \righthyphenmin=3 and \lefthyphenmin=2.) – Mico Apr 11 '20 at 15:10
  • I can't figure out how I got "Clan-g", maybe I'm misremembering. However "Clan-g/" definitely occurs. I'm using babel with the ngerman options. Babel sets righthyphenmin to 2 for german (see here). I think latex is counting the slash as a character, so "g/" can be on a new line. – corvus_192 Apr 12 '20 at 16:22
1

I suggest you \usepackage[ngerman]{babel} and use the "" shorthand. From ngermanb.pdf:

2 Shorthands

"" a breakpoint that does not output a hyphen sign if the line break is performed (useful for compound words with hyphen, e.g. (Un-)""Sinn).

Code borrowed from this answer:

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

\begin{document}
\fbox{\parbox{24pt}{\hspace{0pt}und/oder}} \par\bigskip
\fbox{\parbox{24pt}{\hspace{0pt}und/""oder}} \par\bigskip
\fbox{\parbox{24pt}{\hspace{0pt}Kontrast/""RauschVerhältnis}}
\end{document}

enter image description here

Arash Esbati
  • 7,416