Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Why doesn't the hyphenation work with multiple languages? See code:

\documentclass[a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[english,ngerman]{babel}

\begin{document}
Mein deutscher Bindestrich"=Test.

\selectlanguage{english}
My english Hyphon"=Test. <--- Here should be a - and not "=
\selectlanguage{ngerman}
\end{document}
share|improve this question

3 Answers 3

up vote 10 down vote accepted
\documentclass[a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[english,ngerman]{babel}
\useshorthands{"}
\addto\extrasenglish{\languageshorthands{ngerman}}
\begin{document}
Mein deutscher Bindestrich"=Test.

\foreignlanguage{english}{%
My english Hyphon"=Test. <--- Here should be a - and not "=}

\end{document}

By the way: using \selectlanguage makes sense only when you want to switch completely to the other language (date, titles, ...)

share|improve this answer

The "= shorthand is part of babels language definition files for german and ngerman. The definition file for english does not contain any shorthands. As shorthands are switched on and off with the language, by default "= doesn't work for english text parts even if one has loaded the german/ngerman definitions. Possible solutions are described in babel: Adding `ngerman`s language shorthands to `english` as the main document language.

share|improve this answer

The answer why this doesn't work out of the box is due to the history of the multilingual support in LaTeX.

Initially LaTeX (just like plain TeX) had no (or only minimal) support for languages other than English. As a result, users in Europe started to build language support packages for their own languages. Some of the early ones here were german, french, and a couple of others. They all work as standalone packages without any support from the LaTeX format.

Another development that happened, was to replace the hardwired strings (such as the string "Table of Contents") in LaTeX by calls to macros, so that it would be easiers to customize them without rewriting the functional code in LaTeX. This version of LaTeX was called "iLaTeX" (for International LaTeX) and was one of the many incompatible variants that floated around prior to LaTeX2e.

So when Johannes worked on Babel, he had a good number of "national" language support packages already out in the field, and so what he did, was to provide a common framework to allow the LUGs (local user groups) to drive the development for their language.

Thus you ended up with some languages using many shorthands (like German) while others didn't, and sometimes the used shorthands had different meanings in different languages.

Not an extremely satisfying situation, but again one needs to look at the compatibility situation: the basic idea was that, for example, the standalone package german could be replaced by \usepackage[german]{babel} without breaking existing documents, and something like this also requires not to extend the interface without need, as that could invalidate documents, too.

The way out is to explicitly enable additional shorthands in the preamble of the document if one wants to make use of them, and how to do this is explained in the Babel documentation and also shown in the answer given by Herbert.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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