Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

While writing my thesis I use the hyperref and appendix packages like in the little example below.

test.tex

\documentclass{book}
\usepackage{hyperref}
\usepackage[titletoc]{appendix}

\begin{document}

\tableofcontents

\chapter{First chapter}
\section{Chapter section}
\chapter{Second chapter}

\begin{appendices}
\input{extra}
\end{appendices}

\end{document}

extra.tex

\chapter{First appendix}
\section{Appendix section}

This example produces no errors. The end result is a content table with clickable links to all the chapters (including those in the appendices) and formatted the way I want it.

While compiling (pdfLaTeX) the following file is produced:

test.out

\BOOKMARK [0][-]{chapter.1}{First chapter}{}% 1
\BOOKMARK [1][-]{section.1.1}{Chapter section}{chapter.1}% 2
\BOOKMARK [0][-]{chapter.2}{Second chapter}{}% 3
\BOOKMARK [0][-]{Appendix.1.A}{Appendix First appendix}{}% 4
\BOOKMARK [1][-]{section.1.A.1}{Appendix section}{Appendix.1.A}% 5

My thesis is, of course, much larger (more chapters and more appendices). Although the structure is similar, compiling my thesis results in numerous cryptic errors (meaning I don't understand them). I've listed a few below. Commenting the hyperref package allows me to compile, but also disables the links and the bookmarks in the PDF document.

! Missing \endcsname inserted.
<to be read again> 
                   \penalty 
l.46 ...@skip {}lage.1.D}{B\377lage Afkortingen}{}
                                                  % 46
The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Missing number, treated as zero.
<to be read again> 
                   {
l.46 ...@skip {}lage.1.D}{B\377lage Afkortingen}{}
                                                  % 46
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Extra \endcsname.
\check@bm@number ...0\else \csname B_#1\endcsname 
                                                  \fi 
l.46 ...@skip {}lage.1.D}{B\377lage Afkortingen}{}
                                                  % 46
I'm ignoring this, since I wasn't doing a \csname.

)
! Missing $ inserted.
<inserted text> 
                $
l.154 \begin{document}

The .out file of my thesis looks fine until you arrive at the appendix bookmarks.

...
\BOOKMARK [1][-]{section.5.4}{Optimalisatie}{chapter.5}% 32
\BOOKMARK [0][-]{chapter.6}{Conclusie}{}% 33
\BOOKMARK [0][-]{chapter*.28}{Bibliografie}{}% 34
\BOOKMARK [0][-]{B\penalty \@M \hskip \z@skip i\kern -0.02em j\penalty \@M \hskip \z@skip {}lage.1.A}{B\377lage Stopwoordlijsten}{}% 35
\BOOKMARK [1][-]{section.1.A.1}{Nederlandse stopwoorden}{B\penalty \@M \hskip \z@skip i\kern -0.02em j\penalty \@M \hskip \z@skip {}lage.1.A}% 36
\BOOKMARK [1][-]{section.1.A.2}{Engelse stopwoorden}{B\penalty \@M \hskip \z@skip i\kern -0.02em j\penalty \@M \hskip \z@skip {}lage.1.A}% 37
 ...

I believe this post is related to my problem, but I can't make head or tails of it (I'm still relatively new to LaTeX). Can anyone help me enable the links and bookmarks in my thesis?

Greetings,

Sander

EDIT

Adding the babel package to the example reproduces the problem.

\usepackage[dutch]{babel}
share|improve this question
1  
Please try if loading hyperref after appendix helps. It is generally a good practice to load hyperref as the very last package. –  tohecz Aug 17 '12 at 21:03
    
and have a look at which-packages-should-be-loaded-after-hyperref-instead-of-before for future reference –  cmhughes Aug 17 '12 at 21:06
    
@tohecz : loading hyperref last makes no difference –  Sander Aug 17 '12 at 21:08
    
@cmhughes : I use the float and algorithm packages as well but they're in the proper order –  Sander Aug 17 '12 at 21:11
1  
Loading bookmark after hyperref seems to overcome the problem. However, you should try and show an example that produces the problem (yours doesn't). –  egreg Aug 17 '12 at 21:43

2 Answers 2

up vote 11 down vote accepted

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}%
} 
share|improve this answer
    
There is a related problem with babel for Russian, see tex.stackexchange.com/a/41658/4427. Can you check whether the fix you're preparing is valid also for that case? –  egreg Aug 17 '12 at 23:19
    
@Heiko Oberdiek : your workaround still has the 'Bÿlage' bookmarks in the pdf document. \addto\captionsdutch{\renewcommand{\appendixname}{Bijlage}} fixes this. –  Sander Aug 18 '12 at 8:13
    
On the other hand, babel captions should not include shorthands and should be defined using the LICR. –  Javier Bezos Aug 18 '12 at 18:24
    
When using Spanish instead of Dutch, the problem is also present, but when I use your workaround I get ! Undefined control sequence. \GenericError ... –  Bruno Stonek Apr 17 '13 at 12:41
    
@BrunoStonek I cannot reproduce your problem by adding \usepackage[spanish]{babel} and \usepackage{bookmark}. –  Heiko Oberdiek Apr 17 '13 at 12:50

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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