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.

After compiling my LaTeX document to PDF, I noticed that its internal bookmarks were using an incorrect hierarchy. Compare the bookmarks tree to the table of contents below:

TOC                   Bookmarks

How can this happen and how do I fix it? I never tinkered with the bookmarks system manually.


Here's a Minimal Working Example:

\documentclass[a4paper,oneside]{report}
\usepackage[a4paper]{geometry}
\usepackage[dutch,english]{babel}
\usepackage{subfigure}
\usepackage{graphicx}
\usepackage{lscape}
\usepackage[font={it,sf},labelfont=bf]{caption}
\usepackage[usenames,dvipsnames]{xcolor}

\usepackage[colorlinks=true,linkcolor=black,citecolor=red,urlcolor=red]{hyperref}
\title{AAA}
\author{AAA}
\date{AAA}

\begin{document}
\maketitle

\null
\vfill
\thispagestyle{empty}


\abstract

\chapter*{Introduction}
\addtolength{\parskip}{10px}
\setlength{\parindent}{0cm}
\pagenumbering{roman}

\newpage
\selectlanguage{english}
\addtolength{\parskip}{-10px}
\tableofcontents

\addtolength{\parskip}{10px}
\chapter{A}
\pagenumbering{arabic}

\section{AA}


\subsection{AAA}


\subsection{AAB}


\section{AB}


\section{AC}


\subsection{ACA}


\subsection{ACB}


\section{AD}


\newpage
\section{AE}


\chapter{B}

\section{BA}


\section{BB}


\subsection{BBA}


\section{BC}


\subsection{BCA}


\section{BD}


\subsection{BDA}


\subsection{BDB}


\subsection{BDC}


\section{BE}

\chapter{C}

\setcounter{chapter}{0}
\renewcommand{\thechapter}{\Alph{chapter}}
\chapter{D}
\selectlanguage{dutch}
\section{DA}

\subsection{DAA}


\subsection{DAB}


\subsection{DAC}


\subsection{DAD}


\subsection{DAE}


\subsection{DAF}


\subsection{DAG}

\newpage
\bibliographystyle{plain}

\end{document}

And here is the file list:

 *File List*
  report.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
geometry.sty    2010/09/12 v5.6 Page Geometry
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
  ifvtex.sty    2010/03/01 v1.5 Detect VTeX and its facilities (HO)
 ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
geometry.cfg
   babel.sty    2008/07/08 v3.8m The Babel package
 bblopts.cfg    2006/07/31 v1.0 MiKTeX 'babel' configuration
   dutch.ldf    2005/03/30 v3.8i Dutch support from the babel system
 english.ldf    2005/03/30 v3.3o English support from the babel system
subfigure.sty    2002/07/30 v2.1.4 subfigure package
subfigure.cfg
graphicx.sty    1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty    2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2007/01/18 v1.5 graphics configuration of teTeX/TeXLive
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
 ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
  lscape.sty    2000/10/22 v3.01 Landscape Pages (DPC)
 caption.sty    2012/02/19 v3.2f Customizing captions (AR)
caption3.sty    2012/01/12 v1.4b caption3 kernel (AR)
  xcolor.sty    2007/01/21 v2.11 LaTeX color extensions (UK)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
dvipsnam.def    1999/02/16 v3.0i Driver-dependant file (DPC,SPQR)
hyperref.sty    2012/05/13 v6.82q Hypertext links for LaTeX
hobsub-hyperref.sty    2012/04/25 v1.12 Bundle oberdiek, subset hyperref (HO)
hobsub-generic.sty    2012/04/25 v1.12 Bundle oberdiek, subset generic (HO)
  hobsub.sty    2012/04/25 v1.12 Construct package bundles (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
 intcalc.sty    2007/09/27 v1.1 Expandable calculations with integers (HO)
etexcmds.sty    2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
kvsetkeys.sty    2012/04/25 v1.16 Key value parser (HO)
kvdefinekeys.sty    2011/04/07 v1.3 Define keys (HO)
pdftexcmds.sty    2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
pdfescape.sty    2011/11/25 v1.13 Implements pdfTeX's escape features (HO)
bigintcalc.sty    2012/04/08 v1.3 Expandable calculations on big integers (HO)
  bitset.sty    2011/01/30 v1.1 Handle bit-vector datatype (HO)
uniquecounter.sty    2011/01/30 v1.2 Provide unlimited unique counter (HO)
letltxmacro.sty    2010/09/02 v1.4 Let assignment for LaTeX macros (HO)
 hopatch.sty    2011/06/24 v1.1 Wrapper for package hooks (HO)
xcolor-patch.sty    2011/01/30 xcolor patch
atveryend.sty    2011/06/30 v1.8 Hooks at the very end of document (HO)
atbegshi.sty    2011/10/05 v1.16 At begin shipout hook (HO)
refcount.sty    2011/10/16 v3.4 Data extraction from label references (HO)
 hycolor.sty    2011/01/30 v1.7 Color options for hyperref/bookmark (HO)
kvoptions.sty    2011/06/30 v3.11 Key value format for package options (HO)
  pd1enc.def    2012/05/13 v6.82q Hyperref: PDFDocEncoding definition (HO)
hyperref.cfg    2002/06/06 v1.2 hyperref configuration of TeXLive
     url.sty    2006/04/12  ver 3.3  Verb mode for urls, etc.
 hpdftex.def    2012/05/13 v6.82q Hyperref driver for pdfTeX
rerunfilecheck.sty    2011/04/15 v1.7 Rerun checks for auxiliary files (HO)
supp-pdf.tex
 nameref.sty    2010/04/30 v2.40 Cross-referencing by name of section
gettitlestring.sty    2010/12/03 v1.4 Cleanup title references (HO)
 problem.out
 problem.out
 ***********

It appears that these two lines are wreaking havoc:

\setcounter{chapter}{0}
\renewcommand{\thechapter}{\Alph{chapter}}
share|improve this question
3  
Please add a minimal working example (MWE) that illustrates your problem. –  Harish Kumar May 25 '12 at 9:51
    
I was hoping it didn't have to come to that, but I updated my original post with the MWE you requested. –  Pieter May 26 '12 at 9:54
2  
Note that we want minimal examples, i.e. remove gradually everything which doesn't influence the issue has described in the above linked MWE page. Also make sure to upload all images over the stackexchange imgur account (e.g. use CTRL+G) and not your own or using another way. Otherwise the images might not be available after a while. –  Martin Scharrer May 26 '12 at 15:20
    
I think I've narrowed it down to two lines that are somehow causing a disruption. See updated post. –  Pieter May 27 '12 at 9:42
add comment

1 Answer

up vote 11 down vote accepted

The package hyperref should be loaded as last package. See:

Which packages should be loaded after hyperref instead of before?

The package subfigure is obsolete, instead use subcaption or subfig.

How to keep up with packages and know which ones are obsolete?

With the following header I have no problems:

\documentclass[a4paper,oneside]{report}
\usepackage[a4paper]{geometry}
\usepackage[dutch,english]{babel}
\usepackage{subfigure}
\usepackage{graphicx}
\usepackage{lscape}
\usepackage[font={it,sf},labelfont=bf]{caption}
\usepackage[usenames,dvipsnames]{xcolor}

\usepackage[colorlinks=true,linkcolor=black,citecolor=red,urlcolor=red]{hyperref}

EDIT

After you add your file list and was able to compare the versions of hyperref.

I am using:

hyperref.sty    2012/05/13 v6.82q Hypertext links for LaTeX

and you are using:

hyperref.sty    2010/03/30 v6.80u Hypertext links for LaTeX

You can see you need an update of your LaTeX distribution.


EDIT 2

Based on the new information the problems based on the setting of:

\setcounter{chapter}{0}
\renewcommand{\thechapter}{\Alph{chapter}}

This isn't really unexpected. At this point hyperref finds every chapter twice and you get the warning:

pdfTeX warning (ext4): destination with the same identifier

To solve this you must redefine \theHchapter in a suitable way. Here a suggestion:

\setcounter{chapter}{0}
\renewcommand{\theHchapter}{\Alph{chapter}}
\renewcommand{\thechapter}{\Alph{chapter}}

An other hint: If you compile with XeLaTeX you can't work with the unit px.
I don't know why

Finally the complete example:

\documentclass[a4paper,oneside]{report}
\usepackage[a4paper]{geometry}
\usepackage[dutch,english]{babel}
\usepackage{subfigure}
\usepackage{graphicx}
\usepackage{lscape}
\usepackage[font={it,sf},labelfont=bf]{caption}
\usepackage[usenames,dvipsnames]{xcolor}

\usepackage[colorlinks=true,linkcolor=black,citecolor=red,urlcolor=red,plainpages=false,pdfpagelabels=true]{hyperref}
\title{AAA}
\author{AAA}
\date{AAA}

\begin{document}
\maketitle

\null
\vfill
\thispagestyle{empty}

\abstract

\chapter*{Introduction}
\addtolength{\parskip}{10pt}
\setlength{\parindent}{0cm}
\pagenumbering{roman}

\newpage
\selectlanguage{english}
\addtolength{\parskip}{-10pt}
\tableofcontents

\addtolength{\parskip}{10pt}
\chapter{A}
\pagenumbering{arabic}

\section{AA}


\subsection{AAA}


\subsection{AAB}


\section{AB}


\section{AC}


\subsection{ACA}


\subsection{ACB}


\section{AD}


\newpage
\section{AE}


\chapter{B}

\section{BA}


\section{BB}


\subsection{BBA}


\section{BC}


\subsection{BCA}


\section{BD}


\subsection{BDA}


\subsection{BDB}


\subsection{BDC}


\section{BE}

\chapter{C}

\setcounter{chapter}{0}
\renewcommand{\theHchapter}{\Alph{chapter}}
\renewcommand{\thechapter}{\Alph{chapter}}
\chapter{D}
\selectlanguage{dutch}
\section{DA}

\subsection{DAA}


\subsection{DAB}


\subsection{DAC}


\subsection{DAD}


\subsection{DAE}


\subsection{DAF}


\subsection{DAG}

\newpage
\bibliographystyle{plain}

\end{document}
share|improve this answer
1  
I had no idea that the package order mattered. Good to know! I'm still having the same issue though. I moved the hyperref import to the bottom of the list and I tried copying your header, but neither of the two fixes worked for me. I made sure to delete everything except the TEX file first. I tried both subfig and subfigure. I've updated my TEX file at the top. –  Pieter May 26 '12 at 13:57
    
@Pieter: I edited my answer -- and we can remove all unnecessary comments ;-) –  Marco Daniel May 27 '12 at 10:12
    
Hey thanks, that works! I don't know the ins and outs of LaTeX as well as you do and it can be a bit of a black box at times. –  Pieter May 27 '12 at 11:15
add comment

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.