1

When using the appendix package together with [ngerman]{babel} changing appendixautorefname or Appendixautorefname has no effect.

The error message No autoref name for 'Anhang' [...] persists.

How do I get this to work?

Thanks a lot in advance.

MWE:

\documentclass{book}
\usepackage[titletoc]{appendix}
\usepackage[ngerman]{babel}
\addto\extrasngerman{%
    \def\chapterautorefname{Kapitel}%
    \def\appendixautorefname{Anhang}%
    \def\Appendixautorefname{Anhang}%
}
\usepackage{hyperref}

\begin{document}
\chapter{a}\label{ch:a}
Reference to chapter: \autoref{ch:a}

Reference to appendix: \autoref{App}

\begin{appendices}
\chapter{Ein Anhang}\label{App}
\end{appendices}

\end{document}

enter image description here

PS: I already asked this question(s) in the comment section of No autoref name for `Appendix' but felt better opening a new Question for this.

3

The reason why \Appendixautorefname isn't working is that tocloft uses the \appendixname macro to create the anchor Anhang here, see the entry

\newlabel{App}{{A}{3}{Ein Anhang}{Anhang.a.A}{}}

in the .aux file. hyperref is looking then for a special \Anhangautorefname command, not \Appendixautorefname.

\documentclass{book}
\usepackage[titletoc]{appendix}
\usepackage[ngerman]{babel}

\makeatletter
\addto\extrasngerman{%
  \renewcommand{\chapterautorefname}{Kapitel}%
  \renewcommand{\appendixautorefname}{\appendixname}%
  \@ifundefined{Anhangautorefname}{%
    \newcommand{\Anhangautorefname}{\appendixname}%
  }{%
    \renewcommand{\Anhangautorefname}{\appendixname}%
  }
}
\makeatother

\usepackage{hyperref}

\begin{document}

\chapter{a}\label{ch:a}
Reference to chapter: \autoref{ch:a}

Reference to appendix: \autoref{App}

\begin{appendices}
\chapter{Ein Anhang}\label{App}
\end{appendices}

\end{document}

enter image description here

  • Awesome! Works like a charm. Thanks a lot!!! – Grodon Mar 18 '16 at 15:54
  • @Grodon: You're welcome. Happy TeXing! – user31729 Mar 18 '16 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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