Conflict between babel, hyperref and appendix package
Bug report
It is a bug in package appendix. The bug is triggered if babel
is loaded with language option dutch
. From my bug report to the package maintainer:
The following document breaks in the second run:
\documentclass{book}
\usepackage[dutch]{babel}
\usepackage{hyperref}
\usepackage[titletoc]{appendix}
\begin{document}
\tableofcontents
\chapter{First chapter}
\section{Chapter section}
\chapter{Second chapter}
\begin{appendices}
\chapter{First appendix}
\section{Appendix section}
\end{appendices}
\end{document}
The .out file contains:
\BOOKMARK [0][-]{B\penalty \@M \hskip \z@skip i\kern -0.02em j\penalty \@M
\hskip \z@skip {}lage.1.A}{B\377lage First appendix}{}% 4
The counter name that is used for the destination name is broken,
because of language dependend string: B"ylage
.
The reason is:
\newcommand{\@resets@pp}{\par
\@ppsavesec
\stepcounter{@pps}
\setcounter{section}{0}%
\if@chapter@pp
\setcounter{chapter}{0}%
\renewcommand\@chapapp{\appendixname}%
\renewcommand\thechapter{\@Alph\c@chapter}%
\else
\setcounter{subsection}{0}%
\renewcommand\thesection{\@Alph\c@section}%
\fi
\if@pphyper
\if@chapter@pp
\renewcommand{\theHchapter}{\theH@pps.\Alph{chapter}}%
\else
\renewcommand{\theHsection}{\theH@pps.\Alph{section}}%
\fi
\def\Hy@chapapp{\appendixname}%
\fi
\restoreapp
}
\Hy@chapapp
is redefined as \appendixname
and this is language dependent
that breaks in case of Dutch because of the shorthand expansion. But \Hy@chapapp
is used
in destination names, it is "chapter" (from counter chapter) usually,
only after \appendix
the name chapter
is changed to appendix
to get better unique destination names. There is no need to make this
language dependent. Just use:
\def\Hy@chapapp{appendix}
or
\def\Hy@chapapp{\Hy@appendixstring}
Also the other occurence in \@resets@ppsub
needs to be fixed.
Workaround/solution
There is also a workaround independent from the bug fixing in package appendix
.
Just load package bookmark
after hyperref
. It has a much more robust algorithm
for the bookmarks and deals with the broken B"ylage
in the .aux
file by using
hex
encoding (base16
). Also the bookmarks are updated earlier.
\documentclass{book}
\usepackage[dutch]{babel}
\usepackage{hyperref}
\usepackage{bookmark}
\usepackage[titletoc]{appendix}
Also hyperref
v6.83b will deactivate shorthands in destination names
(\hypercurrent and destination name in \contentsline).
"IJ" and "ij" in bookmarks
These characters, ligatures of upper-/lowercase i and j, are not available in PDFDocEncoding. But they are accessible by Unicode bookmarks, that means
hyperref
option pdfencoding=auto
or unicode
.
The replacement with "ÿ" in hyperref
's PD1
encoding is a bug and
will be fixed in v6.83b.
BTW, redefinitions of macros for the bookmarks can be limited to bookmarks (pdf strings)
by putting them in \pdfstringdefDisableCommands
:
\pdfstringdefDisableCommands{%
\renewcommand*{\appendixname}{Bookmark-Appendix}%
}
A complete solution compiled from all the comments.
\documentclass{book}
\usepackage[dutch]{babel}
\usepackage[titletoc]{appendix}
\usepackage{hyperref}
\usepackage{bookmark} % handles the encoding in the .out file
\addto\captionsdutch{\renewcommand{\appendixname}{Bijlage}} % changes 'Bÿlage' to 'Bijlage' for the bookmarks
\begin{document}
\tableofcontents
\chapter{First chapter}
\section{Chapter section}
\chapter{Second chapter}
\begin{appendices}
\input{extra}
\end{appendices}
\end{document}
Greetings,
Sander