Open staerz opened 4 years ago
Thank you for your report. To be honest, I don't know what's happening, because some time ago it worked. Maybe a change in hyperref
or something I've accidentally broken, but after a few tests I'd say there are two separate problems: (1) bookmarks are messed up when \part
is ‘re-classed’, and (2) subchapters are treated like chapters.
As hyperref
is involved, which does a lot of tricky things (like titlesec
), I think it may take some time to figure out where both problems are.
The first problem seems to be related directly to hyperref
. The following example works:
\documentclass{book}
\usepackage{titlesec}
\usepackage[linktocpage]{hyperref}
\titleformat{\part}[display]
{\normalfont\Huge}{\centering\thepart}{1em}{\centering}%
% [\setcounter{chapter}{0}]
\begin{document}
\part{Island}
\chapter{Desert}
\section{Shelter}
\part{Water}
\chapter{Ice}
\section{Snow}
\end{document}
But if you uncomment [\setcounter{chapter}{0}]
it fails (tested also with your MWE). It seems hyperref
needs some additional setup if chapter numbers are duplicated.
Now I have to investigate the second issue (\subchapter
).
Hi Javier,
I'm happy to see that you immediately jumped onto that issue :wink:
And I'm also happy that you can reproduce the issue on your side which is the first necessary step in understanding what is going wrong and finally finding a fix.
I had a similar issue with sections and fixed it with the following statements in the document header.
\newcommand{\sectionbreak}{\phantomsection}
\newcommand{\subsectionbreak}{\phantomsection}
\newcommand{\subsubsectionbreak}{\phantomsection}
First of all, thanks for that package!
When using it in a rather largely structured document, I think to have identified a minor, but annoying bug:
The contents on the bookmarks panel of the document is corrupted: When adding a new titleclass i.e. exactly following the example in the manual:
(and defining the corresponding \titleformat and \titlespacing, of course), in the bookmark view the newly defined titleclass seems to originate from the wrong hierarchical item, and may even affect other items.
Here is a MWE:
The resulting bookmark and ToC I get is this one:
I can see a similar behaviour when defining a
\subsubsubsection
: There the bookmark is originating from the root of the document and consecutive sections (but higher in the hierarchy) are shown as sub-items:I'm not a LaTeX expert and have no idea how bookmarks are generated at all but I would assume this to be something that the titlesec/titletoc would be responsible for - or I'm not using it correctly, i.e. miss a setting or definition somewhere.
In any case, feedback is welcome.