hyperref
hyperref copied to clipboard
Respect babel's named option 'main'
Hyperref uses the language set by babel, but does not know about the named option main
.
MWE:
\documentclass{article}
\usepackage{acronym}
\usepackage[english,main=ngerman]{babel}
\usepackage{hyperref}
\begin{document}
\section{Test}\label{foo}\autoref{foo}
\end{document}
This outputs section 1
, but should output Abschnitt 1
.
A workaround is to simply leave out main=
(babel uses the last language as main, I think). But when using the scrreprt
class and switching languages in the document, babel shows a warning that you should be using main=
. Plus, \selectlanguage
stops working for references, perhaps more.
Also see here for a proposed fix.
The language support in hyperref for \autoref is clearly quite restricted (and old): It knows a few babel languages, but ignores e.g. polyglossia and newer options offered by babel.
But I don't think that it would be sensible to extend it. In my opinion autoref and its language definitions doesn't really belong into hyperref. It is only there as it uses the trick to look at the destination name to guess the counter it refers too. It should be moved in some external package and based on e.g. zref-counter instead. (There is a branch where I made first tries, and with it you get german with your example).
Thanks for your insight. We're considering switching to cleveref
until a suitable replacement to \autoref
lands in texlive.
For anybody who stumbles on this issue, this workaround seems to do the trick:
\usepackage[english,ngerman,main=ngerman]{babel}
@u-fischer have you worked on your branch since then or can recommend a more featureful solution (/package)?