2

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.

4

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}
\usepackage[colorlinks]{hyperref}

\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}
\usepackage[colorlinks]{hyperref}

\makeatletter
\@addtoreset{section}{part}
\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

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.