1

I used the advice in How to split a latex document using parts and chapters to section my book in to parts and chapters. However, the table of contents has links to chapter n in part 1, for chapter n in any part.

I used \counterwithin* {chapter}{part} to get around this. Is this the right solution?

1 Answers1

3

Package hyperref needs unique anchor names. The anchor names are mostly using the counter values. To support non-unique counter values, package hyperref uses a companion form of the counter theHcounter, which is not used for typesetting but for the anchor names. Thus you would need, e.g.:

 \renewcommand*{\theHchapter}{\theHpart.\thechapter).

Package hyperref adds support for \@addtoreset or \counterwithin, but this will only work, when they are used after hyperref is loaded.

Example:

\documentclass{book}
\usepackage{chngcntr}
\usepackage{hyperref}

\counterwithin*{chapter}{part}

\begin{document}
\tableofcontents
\part{One}\label{part:one}
\chapter{First}\label{chapter:first}
\part{Two}\label{part:two}
\chapter{Second}\label{chapter:second}
\end{document}
Heiko Oberdiek
  • 271,626