fmarotta / kaobook

A LaTeX class for books, reports or theses based on https://github.com/kenohori/thesis and https://github.com/Tufte-LaTeX/tufte-latex.
https://github.com/fmarotta/kaobook
LaTeX Project Public License v1.3c
861 stars 185 forks source link

Sections appearing twice in PDF ToC #214

Closed davidwlindholm closed 2 years ago

davidwlindholm commented 2 years ago

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.

davidwlindholm commented 2 years ago

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

Dettorer commented 2 years ago

In a project that uses kaobook I fixed a compilation warning that seems related^1. 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
Dettorer commented 2 years ago

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.

Dettorer commented 2 years ago

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 https://github.com/fmarotta/kaobook/issues/155, which was fixed in https://github.com/fmarotta/kaobook/commit/80621c55a725cad60a4b67344c88499cbd6351f9.

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