0

I have the following issue with minitoc:

I have a first numbered chapter with sections 1 and 2 and a second unnumbered chapter with sections 1 and 2 (sections reset with \setcounter{section}{0}). As the second chapter is unnumbered if I do not reset the section number, they are numbered 3 and 4 which is not what I want.

When I generate the minitoc they generate correctly but the hyperlinks are wrong: clicking on the minitoc of the unnumbered chapter leads to the corresponding section of the previous numbered chapter.

Does anyone have an idea on how to solve this issue?

Here is a minimimum working example:

\documentclass{book}
\usepackage{minitoc}
\usepackage{hyperref}

\dominitoc
\begin{document}
\tableofcontents
\chapter{foo}
\minitoc
\section{a}
\section{b}

\chapter*{foo foo}
\setcounter{section}{0}
\addstarredchapter{foo foo}
\markboth{foo foo}{}
\minitoc

\section{c}
\section{d}

\end{document}
2
  • Add something like this to your preamble \renewcommand\theHsection{\thesection.\thepage}. Without it you will see warnings in the log about targets being duplicates. In short hyperref does not like it when there are two sections with the same number. The suggestion above then makes the section counter (seen from hyperref a bit more unique)
    – daleif
    Sep 16 '21 at 9:52
  • Thanks, this solved issue. Sep 16 '21 at 10:37
1

In general hyperref assumes that all sections have distinct numbers. So when you have two sections numbered 1.1, hyperref complains in the log:

pdfTeX warning (ext4): destination with the sa
me identifier (name{section.1.1}) has been already used, duplicate ignored
<to be read again> 
                   \relax 
l.22 \section{c}

one solution here is to define an internal hyperref counter representation which is always unique.

Here you can probably use

\renewcommand\theHsection{\thesection.\thepage}

provided you never have two setions with the same number on the same page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.