anthe.sevenants

Fix: \sectionautorefname and others ignored in LaTeX

2024-11-07

I came across an issue in LaTeX where I used the following commands to ensure that my section references from the \autoref command used capitals:

\renewcommand\sectionautorefname{Section}
\renewcommand\subsectionautorefname{Section}
\renewcommand\appendixautorefname{Appendix}

However, it seemed as if these commands were being ignored:

For this section, we follow the example of (Bloem 2021: 132–133), discussed in subsubsection 3.2.5.

I found that the problem would go away if I removed the following package definition:

\usepackage[english]{babel}

It seems, then, that Babel is interfering with the names defined for \autoref. To solve this issue, wrap your commands in \addto\extrasenglish{}:

\addto\extrasenglish{
    \renewcommand\sectionautorefname{Section}
    \renewcommand\subsectionautorefname{Section}
    \renewcommand\appendixautorefname{Appendix}
}

That fixes it:

For this section, we follow the example of (Bloem 2021: 132–133), discussed in Section 3.2.5.

I presume that, for different languages, you can subsitute english in \extrasenglish for the language you have defined. However, I have not tested this.