I'm writing a German document, where I frequently cite works in English and other languages. Used to babel
’s shorthands in ngerman
for easily modifying hyphenation symbols in compound words or names (for example "=
for an additional hyphen that should always be printed, and ""
for a possible line break without a hyphen), I also activated those shorthands for english
using the \addto\extrasenglish
commands.
Inside otherlanguage
environments in the main document’s text, everything works as expected.
biblatex
, which I use for managing my bibliographies, offers the autolang
option and the langid
field for switching hyphenation rules for each bibliographic entry. When I set autolang
to other
, it puts an otherlanguage
environment around the citations and bibliography entries, and therefore uses the shorthands. But it then also prints terms like and
in English, which is not desireable in an overall German document. biblatex
therefore offers the autolang=hyphen
option to only activate the hyphenation rules for the language specified in the langid
field, while falling back to the main document language for all other terms.
However, then the shorthands do not work anymore. How do I get them to work?
Here's an MWE:
\documentclass{scrartcl}
\usepackage{fontspec}
\usepackage[english,ngerman]{babel}
\addto\extrasenglish{\useshorthands{"}\languageshorthands{ngerman}}
\usepackage{csquotes}
\usepackage[backend=biber,autolang=hyphen,style=verbose]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{bibliography.bib}
@collection{NMR,
editor = {Wardrip"=Fruin, Noah and Montfort, Nick},
title = {The New Media Reader},
location = {Cambridge/""MA and London},
publisher = {MIT Press},
year = 2003,
langid = {english}
}
\end{filecontents}
\addbibresource{bibliography.bib}
\begin{document}
\begin{otherlanguage}{english}
Manually using babel shorthands inside an \texttt{otherlanguage}
environment, everything works as expected: Wardrip"=Fruin.
Cambridge/""MA.
\end{otherlanguage}
Yet, citing the work from the bibliography, where it was given a
\texttt{langid} field, the shorthands do not work.\autocite{NMR}
Neither do they work in the bibliography:
\printbibliography
\end{document}
autolang=other
package option. Using the package optionautolang=hyphen
is exactly for using foreign hyphenrules for the actual field contents, but keeping terms like "and" or date formats in the main document language (i.e. don't translate them).