# Incorrect Linking with minitoc and hyperref

MWE:

\documentclass{article}

%font
\usepackage{mathpazo}

\usepackage[english]{babel}

\addto\captionsenglish{% Replace "english" with the language you use
\renewcommand{\contentsname}%
}

%remove numbering from TOC
\setcounter{secnumdepth}{0}

%omit subsections and lower levels from base TOC
\setcounter{tocdepth}{1}

\usepackage[bookmarks,bookmarksopen,bookmarksdepth=2]{hyperref}
\hypersetup{
citecolor=black,
filecolor=black,
urlcolor=blue
}

%mini TOCs in each section
\usepackage{minitoc}

\begin{document}
\begin{center}
\textbf{Title}
\end{center}
\dosecttoc
\tableofcontents
\newpage

\section{Sect1}
\secttoc
\subsection{Sub1}
Stuff
\newpage
\section{Sect2}
\secttoc
\subsection{Sub2}
Stuff2
\newpage
\section{Test}
\end{document}


This gives me the following .pdf's first page:

If you were to try to click the links, you'll notice that none of them go to the intended pages. Why is this?

Another point of concern is the bookmark structure it has:

So, for some reason, it thinks that Sect2 is a subsubsection of Sect1, which is obviously not the case.

Use \usepackage{minitoc} before \usepackage{hyperref}, which should be the last package in almost any case (Exceptions are cleveref and glossaries), but it's no particular minitoc related issue -- it's valid for many packages dealing with ToC and counters.

minitoc does some changes to ToC and counters which must be made known to hyperref.

\documentclass{article}

%font
\usepackage{mathpazo}

\usepackage[english]{babel}

\addto\captionsenglish{% Replace "english" with the language you use
\renewcommand{\contentsname}%
}

%remove numbering from TOC
\setcounter{secnumdepth}{0}

%omit subsections and lower levels from base TOC
\setcounter{tocdepth}{1}
%mini TOCs in each section
\usepackage{minitoc}

\usepackage[bookmarks,bookmarksopen,bookmarksdepth=2]{hyperref}
\hypersetup{
citecolor=black,
filecolor=black,
urlcolor=blue
}

\begin{document}
\begin{center}
\textbf{Title}
\end{center}
\dosecttoc
\tableofcontents
\newpage

\section{Sect1}
\secttoc
\subsection{Sub1}
Stuff
\newpage
\section{Sect2}
\secttoc
\subsection{Sub2}
Stuff2
\newpage
\section{Test}
\end{document}


• @Clarinetist: It's a common 'error' ;-) – user31729 Nov 17 '15 at 21:34