5

TeX trys to hypehnate my word "universeller" in a totally wrong way. It makes it to "Üniverseller" and removes the quotation marks in the front before.

When I use \mbox it writes the word over the margin break point and if i write the word in \hyphenation{universeller} it doesn't even show the word. Any idea why?\hyphenation{uni-ver-sel-ler} also doesnt work

If I write it normally Tex makes the two words "Fabian" universeller to Fabianüni-:

enter image description here

4
  • 2
    Are you loading babel? How about giving us a minimal working example (MWE)?
    – Werner
    Apr 10, 2014 at 17:35
  • 3
    You shouldn't be using " for the quotes, but rather `` and '' (opening and closing). Consult the documentation of German babel for more about quotes.
    – egreg
    Apr 10, 2014 at 17:42
  • 2
    Or even better, use the wonderful csquotes package and its \enquote{foo} command.
    – moewe
    Apr 10, 2014 at 17:59
  • Hi, thanks for the answers. I already used babel german and csquotes but didn't knew the \enquote command. with \enquote it works perfect without \mbox or \hypehnation. Thanks Apr 10, 2014 at 18:11

2 Answers 2

4

If you load the babel package with the [ngerman] option -- I'm taking a wild guess here that your document's language is German... -- LaTeX should have no problem hyphenating the word "universeller". See the MWE (minimum working example) below, which uses the LuaLaTeX format just to be able to use the nifty showhyphens package to indicate all hyphenation points with thin red vertical bars.

For sure do not place the word universeller into an \mbox unless you want to disable hyphenation. And don't provide the instruction \hyphenation{universeller} unless you, again, want to disable its hyphenation.

Furthermore, don't write "universeller" since with the ngerman option set, babel will interpret "u as a shortcut command for \"{u} and therefore typeset ü rather than "u. For the automatic use of language-appropriate quotation marks, do consider using the csquote package and its \enquote command, i.e., start writing \enquote{universeller}. (As @Dan has pointed out in a comment, the babel shortcut " gobbles up space after it. This explains why it's necessary to write ...seller" \ --- in the MWE to get a space between the end of the word and the em-dash. It also explains what you get the decidedly incorrect ”Fabianüniverseller...)

enter image description here

\documentclass[ngerman]{article}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{Latin Modern Roman}
\usepackage{showhyphens,csquotes,babel}
\begin{document}
universeller

"universeller" \ --- This is a mistake!

``universeller'' --- U.S.-style quotation marks

\enquote{universeller} --- German-style quotation marks
\end{document}
2
  • 2
    Your answer came just before I completed mine. I would only add the observation that macros ignore spaces when looking for arguments. That is why the space in the supplied code: "Fabian" universeller disappears.
    – Dan
    Apr 10, 2014 at 18:30
  • @Dan -- Thanks for this. I've incorporated you comment about " gobbling trailing whitespace into the answer.
    – Mico
    Apr 10, 2014 at 18:40
2

The other answer shows how to get the output you need so I'll just answer your question about \hyphenation

An instruction such as

\hyphenation{uni-ver-sel-ler}

Never typesets anything, it is a declaration (normally in the document preamble) that tells TeX how to hyphenate that word, so that when you use universeller in the document hyphenation and line breaks are allowed at the indicated places. However you should not need that as (if typesetting German) they are in fact the default hyphenation positions.

\documentclass{article}

\usepackage[english,ngerman]{babel}

\showhyphens{universeller}

\selectlanguage{english}

\showhyphens{universeller}

\end{document}

Produces log lines showing how this word is hyphenated in German:

[] \OT1/cmr/m/n/10 uni-ver-sel-ler

and in English:

[] \OT1/cmr/m/n/10 uni-verseller

If you add

\hyphenation{universeller}

as shown here

\documentclass{article}

\usepackage[english,ngerman]{babel}

\hyphenation{universeller}
\showhyphens{universeller}

\selectlanguage{english}
\hyphenation{universeller}
\showhyphens{universeller}

\end{document}

Then the log shows

[] \OT1/cmr/m/n/10 universeller


[] \OT1/cmr/m/n/10 universeller

Showing how the hypheation has now been disabled for the word in German and English.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .