# PDF bookmarks for references and index appear as contained in the appendix. Wrong hierarchy

I am writing my B.A.'s thesis, this is the last part of the code:

\part*{Apéndices}
% ------     Anexos bloque 1  ---------- %
\subfile{anexos.tex}
% ------    Espacios Polacos   ---------- %
\subfile{polish.tex}
\backmatter
% ------     Referencias  ---------- %
% ------     Índice  ---------- %
\phantomsection
\printindex
\end{document}


I like it this way because I get this effect in the Table of Contents (that is, References and Index are not numbered and doesn't seem to belong to the Appendix (Apéndices)):

However what I find really annoying is that the output PDF has the wrong hierarchy in bookmarks since References and Index appear as belonging to the Appendix:

If I use \part{References} then I get a whole page saying "References" with huge letters and I really don't want that. I would like the References and the Index to look in the Table of Contents just as "Apéndices" looks like but being independent sections in bookmarks.

EDIT: This is the essential part of what precedes the last part of my code in case it helps.

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[spanish,mexico]{babel}
\usepackage{subfiles}
\usepackage{appendix}
\usepackage{makeidx}
\makeindex
% ----------     BibLaTex     ------------ %
\usepackage[style=american]{csquotes}
\usepackage[backend=bibtex, citestyle=numeric,bibstyle=authoryear,url=true,firstinits=true]{biblatex}
\usepackage{tocloft}
\renewcommand{\cftchapdotsep}{\cftdotsep}
\usepackage[nottoc,numbib]{tocbibind}
\DefineBibliographyStrings{spanish}{%
bibliography = {Referencias},
}
% ----------      Hyperref    ------------ %
\usepackage{hyperref}
\hypersetup{%
citecolor=blue,
urlcolor=black}
% ---------    Cuerpo del documento  -------------- %
\begin{document}
\maketitle
\frontmatter
\tableofcontents
\mainmatter
\part{Medida y Categoría}
\appendix

• By the way, you do know that nobody will ever care what the pdf-bookmark-hierarchy of the appendix of your Thesis looks like, don't you? ;-) – Vincent Sep 6 '13 at 23:12

Add the bookmark package to your preamble repertoir (after loading hyperref) and issue \bookmarksetup{startatroot} immediately after \backmatter.

According to the bookmark documentation (section 1.2.5 Level options, p 5):

The order of the bookmark entries are defined by the appearance order of \bookmark commands. The tree structure is constructed by the property level of the bookmark nodes. The values of level are integers. If the level of a bookmark entry has a higher value than the previous node, then the entry becomes a child of the previous node. The absolute value of the difference does not matter.

Package bookmark remembers the level of the previous bookmark entry in a global property ‘current level’.

The behaviour of the level system can be configured by following options:

level: Sets the level, see the description above. If option level is given without value, then the default behaviour is restored, that the ‘current level’ is used as level value. Since version 2010/10/19 v1.16 package bookmark also supports names part, section and other, if the macros \toclevel@part, \toclevel@section are defined (done by package hyperref, see option bookmarkdepth).

rellevel: Sets the level relative to the previous level. A positive value means that the bookmark entry become a child of the previous one.

keeplevel: Use the level, set by level or rellevel, but do not change the global property ‘current level’. The option can be disabled by setting to false.

startatroot: At this time the bookmark tree starts at the top level again. The next bookmark entry is not sorted as child to a previous entry. Example scenario: A document uses part. However there are last chapters that should not be put below the last part:

\documentclass{book}
[...]
\begin{document}
\part{First part}
\chapter{First chapter in first part}
[...]
\part{Second part}
\chapter{First chapter in second part}
[...]
\bookmarksetup{startatroot}
\chapter{Index}% does not belong to second part
\end{document}

• When I click on for instance an appendix content which is in an appendices environment, It goes to cover page instead. Is there any further option needed here? I use \bookmarksetup{startaroot} before \begin{appendices} but nothing happens. – Enthusiastic Engineer Nov 11 '14 at 16:14
• @EnthusiasticStudent: That typically means that you're resetting counters which creates duplicate PDF destinations references. There must be some reference to that in your .log. It would require more for me to gauge on how to fix that... – Werner Nov 11 '14 at 18:24
• I solved my problem by adding \appendix after \begin{appendices} with aid of \bookmarksetup{startatroot} – Enthusiastic Engineer Nov 12 '14 at 8:53

One quick way to fix this might be telling hyperref to insert an additional bookmark:

% ------     Referencias  ---------- %
\pdfbookmark[-1]{Referencias y Indices}{BM-Referencias}

• [-1]: indicate what level (relative to the current) to put the bookmark.
• {Referencias y Indices}: text to print into the hierarchy
• {BM-Referencias}: something like a label, needs to be unique.