# Appendices in PDF Outline appear as childs of last section

I'm using the following general outline in `book` class:

``````\mainmatter
\include{introduction}

\part{...}
\include{chapter1}
...

\part{...}
...
\include{conclusions}

\appendixpage
\appendix
\include{...}

\backmatter
% Glossary
\cleardoublepage
\markboth{Nomenclature}{Nomenclature}
\makenomenclature
\input{nomenclature}
\printnomenclature[4.5cm]

% Bibliography / References
\cleardoublepage
\bibliographystyle{amsalpha}
\renewcommand{\bibname}{References}
\bibliography{thesis}
``````

But a lot of things comes wrong in the final PDF, among them:

1. Appendices appear as childs of last section in the last chapter.
2. Clicking on Nomenclature and References bookmarks sends to the wrong page.
3. Despite these problems, the page numbers in TOC are right.

Help?

-
Can you make a minimal working example? No one can compile what you have there. –  TH. Sep 4 '10 at 20:15

I guess you're using hyperref. If you would modify your question and extend your code to show a compilable minimal example, it would make helping easier.

Sectioning commands cause hyperref to create bookmarks. However, if you use starred sectioning commands like `nomencl` and `\bibliography` implicitely do (`\chapter*` or `section*`), and create the bookmarks by `\addcontentsline`, you have to set an anchor for hyperref. The needed command is `\phantomsection`. The anchor must fall onto the correct page, so use it after `\cleardoublepage` like this:

``````\cleardoublepage
\phantomsection
\bibliographystyle{amsalpha}
\renewcommand{\bibname}{References}
\bibliography{thesis}
``````

Do it similar each time you call `\addcontentsline` followed by a non-numbered chapter or section.

For the nesting issue, to put the bookmarks to the root level, frabjous provided the correct solution in his answer.

-

Another thing to try is the `\bookmarksetup{startatroot}` command from the bookmark package to make the next entry go back to the root rather than act as a child of the previous one. The package has some other options that might interest you. I agree that `\phantomsection` is the answer to the links going to the wrong page.

-
Is there a way to accept two answers? :-) Yours solved my problem of "nesting". Stefan's solved my problem of wrong link. –  Hugo S Ferreira Sep 4 '10 at 21:46
@Hugo: perhaps post two separate questions next time ;-) if you have got two problems which might be different even if they were related. Btw. I will edit my answer to point to frabjous answer so that his solution to the nesting issue could be found easily. –  Stefan Kottwitz Sep 5 '10 at 7:34

Something must have gone wrong in the class you are using. Under the appendix definition you should have this:

``````\renewcommand\appendix{\par
\setcounter{chapter}{0}%
\setcounter{section}{0}%
\setcounter{subsection}{0}%
\gdef\@chapapp{\appendixname}%
\gdef\thechapter{\@Alph\c@chapter}
\renewcommand{\chaptertitlename}{\appendixstring}
``````

The code resets the chapter and section and subsection counters to represent an Appendix. What class are you using?

-