# Hyperref did not work properly when I reset the section-counter during the document

Hyperref from the TOC bring me to the wrong part of the document when I RESET the section counter in each PART. -- When I click in the TOC on section 1 in part II, the hyperref brings to section 1 in part I. -- Is there a whay to handle this problem?

part I section 1 section 2 section 3 part II section 1 section 2

etc.

Best regards.

The phenomenon you describe will be produced when using

\setcounter{section}{0}


to manually reset the counter. Here's a simple document reproducing the error:

\documentclass{article}

\begin{document}

\tableofcontents

\part{Test part one}
\setcounter{section}{0}
\clearpage
\section{First test section in part one}
\clearpage
\section{Second test section in part one}

\part{Test part two}
\setcounter{section}{0}
\clearpage
\section{First test section in part two}
\clearpage
\section{Second test section in part two}

\end{document}


Instead of manually resetting the counter for each part, do the resetting using \@addtoreset:

\documentclass{article}

\makeatletter
\makeatother

\begin{document}

\tableofcontents

\part{Test part one}
\clearpage
\section{First test section in part one}
\clearpage
\section{Second test section in part one}

\part{Test part two}
\clearpage
\section{First test section in part two}
\clearpage
\section{Second test section in part two}

\end{document}


\clearpage commands just for the example.

• Thanks a lot. -- the magic; "\makeatletter\@addtoreset{section}{part}\makeatother" solved my problem :) -- But in the meantime I also solved the problem myself with the "hypertexnames=false" in the "\usepackage{hyperref}" option-field. Again, thanks for your prompt answer! – khpe Mar 19 '14 at 1:20