# Minitoc with hyperref and \sectounter{section}{0} leads to wrong section

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}
\markboth{foo foo}{}
\minitoc

\section{c}
\section{d}

\end{document}

• 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) Sep 16 '21 at 9:52
• Thanks, this solved issue. Sep 16 '21 at 10:37

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

one solution here is to define an internal hyperref counter representation which is always unique.
\renewcommand\theHsection{\thesection.\thepage}