I've have created a LaTeX document to merge several pdf files and to create a ToC of it for easy navigation.

However I have an annoying issue with the pdf Bookmark hierarchy not showing correctly for chapters when opening the pdf file.

For some reason, the next chapter ends up as a subsection under the last section of the previous chapter as shown on the images below: PDF Bookmark issue for chapters Below is a minimal working example (excl. pdf files):



% ¤¤ Table of content ¤¤ %

% ¤¤ Visual references ¤¤ %
\hypersetup{colorlinks = true,
    linkcolor = black,
    citecolor = black,
    urlcolor = black



%%%%%%%%%%%%%% KAPITEL 1 %%%%%%%%%%%%%%
\addcontentsline{toc}{chapter}{Kapitel 1 \hspace{1pt} Beton - verdens vigtigste byggemateriale}
    2,subsection,2,Beton i arkitekturen,1.3.1,
    23,subsection,2,Betonoverfladens udtryk,1.3.2,
    36,subsection,2,Produktionsmæssige præmisser,1.3.3,
    40,subsection,2,Ældning og patinering,1.3.4,

%%%%%%%%%%%%%% KAPITEL 2 %%%%%%%%%%%%%%
\addcontentsline{toc}{chapter}{Kapitel 2 \hspace{1pt} Krav til beton}
    5,section,1,Krav til beton i tørt miljø,2.2,
    6,section,1,Eksponerings- og miljøklasser,2.3,
    9,subsection,2,Velkendt teknologi,2.5.1,
    11,subsection,2,Foreskreven beton eller designet beton,2.5.2,
    17,section,1,Litteratur liste,2.8,


This happens for every new chapter and so the pdf bookmark hierarchy just gets deeper and deeper, which kinda makes the bookmark hierarchy useless...

It kinda seems to be related to ToC Depth command \settocdepth{subsection}.

If I comment or remove it, the Bookmark Hierarchy show fine, but doesn't go deeper than section as shown on image below: PDF Bookmark for chapters working, but with depth is only to section

Also tried replacing \settocdepth{subsection} with \setcounter{tocdepth}{3} but it yields same result/issue.

  • Could you try to offer a more minimal example? I don't think hypersetup plays any role in your problem, or that you need 9 sections for your problem to show up: write an example as minimal as posible, to make it easier to understand (both for you and the people willing to help you).
    – Clément
    Commented Sep 18, 2017 at 16:39
  • I choose just to include two of my chapters from the big document as an example for illustration. I could of course include fewer section, if that is better, but thought the code matched the screenshot better with all the sections as they only fill 1 line each.
    – Marius
    Commented Sep 18, 2017 at 20:31

1 Answer 1


Don't use \setcounter but \refstepcounter{chapter}:

\addcontentsline{toc}{chapter}{Kapitel 1 \hspace{1pt} Beton - verdens vigtigste byggemateriale}

\addcontentsline{toc}{chapter}{Kapitel 2 \hspace{1pt} Krav til beton}

Then hyperref can correctly setup the anchors and levels.

enter image description here


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .