fmarotta/kaobook

Sections appearing twice in PDF ToC

davidwlindholm opened this issue · 4 comments

Description

Sections are added twice to the PDF table of contents, and subsections appear superior to sections (That is, sections are folded into subsections).

Minimal Working Example

Compile the Machine Learning Project example, and look at the table of contents in any PDF viewer (the embedded ToC).

Expected behavior:
PDF ToC is similar to the ToC section of the document.

Actual behavior:
See description. Tested with TeX 3.141592653 (TeX Live 2021/Arch Linux).
Possibly caused by changes in the etoc package?

Additional Information

Commenting out lines 901 and 921 of kao.sty fixes the problem. No idea why or what those lines are supposed to do as I can barely read the code, and the comments aren't much clearer. So it's entirely possible this creates some twisted issue somewhere else, but for now I'm just happy it works.

I found the later twisted issue is that it breaks margintoc, so beware of that anyone using this solution.

In a project that uses kaobook I fixed a compilation warning that seems related1. Can you try adding the following lines to your document? If that fixes it I'll try to make a pull request.

% Tell hyperref at which level should it define the PDF bookmarks associated with margin tocs (kaobook doesn't
% define that level, I set it one level deeper than sections).
\makeatletter
  \providecommand*{\toclevel@mtocsection}{0}
  \edef\toclevel@authorch{\the\numexpr\toclevel@section+1}
\makeatother

Footnotes

  1. https://github.com/Dettorer/synva-dissertation/commit/eb70c180ec079bbc093186c5e93fd6c101810b3f

Wait, now I see that it doesn't fix your issue, it just sets a (incorrect even?) level for the margin toc sections, but doesn't prevent them from appearing twice.

Ok so after a more careful inspection of this issue, it seems that my fix is completely misguided and we're simply both using an old version of kaobook. This issue seems to be a duplicate of #155, which was fixed in 80621c5.

Does using the latest kao.sty from master fix your issue? It did for me.