# BibLaTeX langid with autolang=hyphen makes csquotes use localized quotation marks

## autolang=hyphen:

Enclose the entry in a hyphenrules environment. This will load hyphenation patterns for the language specified in the hyphenation field of the entry, if available.
(biblatex manual, section 3.1.1)

This seems like it should only affect hyphenation, not other language settings. Is this the case?

## langid:

The language id of the bibliography entry. The alias hyphenation is provided for backwards compatibility.
(biblatex manual, section 2.2.3)‏

## autostyle=true:

continuously adapts the quote style to the current document language
(csquotes manual, section 2.1)‏

Ideally, combining these would result in only the hyphenation rules changing for bibliography entries. Instead, it also results in the quotation marks changing to the langid value. Why does this happen and can it be worked around?

## Literatur

[1] Hannah Müller. „Wehklagen“. In: Einige Buch. Hrsg. von Tobias Schmidt. Ein Verlag, 2017.

[2] Hannah Müller. „Zitate“. In: Kühle Zeitschrift 17.4 (2031).

[3] Jane Smith. ‘Lamentations’. In: Some book. Hrsg. von Steven Smith. A Publisher, 1917.

[4] Jane Smith. ‘Quotations’. In: Cool Journal 13.7 (2019).

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[british,german]{babel}
\usepackage[autostyle=true]{csquotes}
\usepackage[autolang=hyphen]{biblatex}
\usepackage{filecontents}

\begin{filecontents*}{\jobname.bib}
@incollection{wehklagen,
author = {Müller, Hannah}, editor = {Schmidt, Tobias},
title = {Wehklagen},       booktitle = {Einige Buch},
year = {2017},             publisher = {Ein~Verlag},
langid = {german},
}
@article{zitate,
author = {Müller, Hannah}, title = {Zitate},
year = {2031},             journal = {Kühle Zeitschrift},
volume = {17},             number = {4},
langid = {german},
}
@incollection{lamentations,
author = {Smith, Jane},    editor = {Smith, Steven},
title = {Lamentations},    booktitle = {Some book},
year = {1917},             publisher = {A~Publisher},
langid = {british},
}
@article{quotations,
author = {Smith, Jane},    title = {Quotations},
year = {2019},             journal = {Cool Journal},
volume = {13},             number = {7},
langid = {british},
}
\end{filecontents*}

\begin{document}
\nocite{*}
\printbibliography
\end{document}

• csquotes already changes the quoting style in hyphenrules, unfortunately I did not find a reference in the csquotes manual that states which environments/commands exactly cause the quotation marks to change. – moewe Oct 17 '17 at 8:09
• I might be missing what you mean, but won't \usepackage[style=british]{csqutoes} give you what you want? That way quote style is always british and (I think) the hyphenations used will be german when langid={german}. This seems to be confirmed if I put \showhyphens{Wehklagen} into the title field and mess with the langid field of that entry, anyway. – David Purton Oct 17 '17 at 12:39
• The problem is that csquotes uses \langname to switch the quote style. And \langname is also changed in hyphenrules, even though the babel documentation says it should not. – moewe Oct 17 '17 at 12:46
• Oh! I see, the question suggests that it shouldn't change with autostyle=true in this case. But presumably the OP might still want to use \foreignquote (or some variant) elsewhere in the document with auto styling quote marks. – David Purton Oct 17 '17 at 12:52

csquotes uses the command \languagename provided by babel to find out about the current language.

Contrary to what the code explanation in the documentation currently claims (p. 102 of the babel documentation v. 3.14), the hyphenrules environment actually sets \languagename.

The babel maintainer has confirmed that the explanation is right and the code wrong. The problem will be fixed in the next babel release.

In the meantime you can use the following modified version of hyphenrules that does not set \languagename. It's simply a copy of the original with \languagename replaced by \bbl@hyph@languagename

\makeatletter
\def\hyphenrules#1{%
\edef\bbl@hyph@languagename{#1}%
\bbl@fixname\bbl@hyph@languagename
\bbl@iflanguage\bbl@hyph@languagename{%
\expandafter\bbl@patterns\expandafter{\bbl@hyph@languagename}%
\languageshorthands{none}%
\expandafter\ifx\csname\bbl@hyph@languagename hyphenmins\endcsname\relax
\set@hyphenmins\tw@\thr@@\relax
\else
\expandafter\expandafter\expandafter\set@hyphenmins
\csname\bbl@hyph@languagename hyphenmins\endcsname\relax
\fi}}
\let\endhyphenrules\@empty
\makeatother


With this redefinition your MWE works as expected

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[british,german]{babel}
\usepackage[autostyle=true]{csquotes}
\usepackage[autolang=hyphen]{biblatex}
\usepackage{filecontents}

\begin{filecontents*}{\jobname.bib}
@incollection{wehklagen,
author = {Müller, Hannah}, editor = {Schmidt, Tobias},
title = {Wehklagen},       booktitle = {Einige Buch},
year = {2017},             publisher = {Ein~Verlag},
langid = {german},
}
@article{zitate,
author = {Müller, Hannah}, title = {Zitate},
year = {2031},             journal = {Kühle Zeitschrift},
volume = {17},             number = {4},
langid = {german},
}
@incollection{lamentations,
author = {Smith, Jane},    editor = {Smith, Steven},
title = {Lamentations},    booktitle = {Some book},
year = {1917},             publisher = {A~Publisher},
langid = {british},
}
@article{quotations,
author = {Smith, Jane},    title = {Quotations},
year = {2019},             journal = {Cool Journal},
volume = {13},             number = {7},
langid = {british},
}
\end{filecontents*}

\makeatletter
\def\hyphenrules#1{%
\edef\bbl@hyph@languagename{#1}%
\bbl@fixname\bbl@hyph@languagename
\bbl@iflanguage\bbl@hyph@languagename{%
\expandafter\bbl@patterns\expandafter{\bbl@hyph@languagename}%
\languageshorthands{none}%
\expandafter\ifx\csname\bbl@hyph@languagename hyphenmins\endcsname\relax
\set@hyphenmins\tw@\thr@@\relax
\else
\expandafter\expandafter\expandafter\set@hyphenmins
\csname\bbl@hyph@languagename hyphenmins\endcsname\relax
\fi}}
\let\endhyphenrules\@empty
\makeatother

\begin{document}
\nocite{*}
\printbibliography
\end{document}


• I'm not sure if this a babel or csquotes problem. Anyway, the csquotes developer should know about this github.com/josephwright/csquotes/issues/17 – moewe Oct 17 '17 at 13:50
• The code in babel is wrong. The explanation is correct. I'll fix it in the next release. – Javier Bezos Oct 18 '17 at 14:35
• @JavierBezos This is what I hoped. Thank you for having a look at this. I'll update the answer accordingly. – moewe Oct 18 '17 at 14:42
• @JavierBezos is it fixed in babel-3.16 from 2018-01-04? – Jonas Stein Jan 22 '18 at 22:31
• @JonasStein it appears that babel-3.18 has now, in fact, fixed this. (see change log). – maxheld Apr 7 '18 at 19:25