8

I have already asked a similar question here:

Incorrect ToC/Index cross-references when resetting memoir class counters

and received a satisfactory answer. Now, I wish to apply the chapter counter reset (using \counterwithin*) to a more complex document, but this seems to fail. I simply wish to restart the chapter counter within each Part of a Book, and within each Book of my document structure, which goes like this:

  • Book1

    • Part1
      • Chapter1
      • ...
    • Part2
      • Chapter1
      • ...
    • ...
  • Book2

    • Chapter1
    • ...
  • Book3

    • Chapter1
    • ...

I currently have the following MWE:

\documentclass[a4paper,12pt]{memoir}

\usepackage{hyperref}             
\hypersetup{
    hypertexnames=true,                
    linktocpage=false,
    colorlinks=true,                                        
}

\counterwithin*{chapter}{book}
\counterwithin*{chapter}{part}

\begin{document}

\tableofcontents*

\book{Book1}
 \part{Part1}
  \chapter{Chapter1}
 \part{Part2}
  \chapter{Chapter1}

\book{Book2}
  \chapter{Chapter1}

\book{Book3}
  \chapter{Chapter1}

\end{document}

I can't seem to get proper cross-referencing in my ToC for chapters in Book2 and Book3. Should I splice the \counterwithin* commands somehow throughout the sections?

1 Answer 1

15

Because you have duplicate chapter numbers, you need to tell hyperref to use a unique number for the links. You can add the following to your preamble:

\renewcommand*{\theHchapter}{\thepart.\thebook.\thechapter}

You can see the warnings in the log file when this arises.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .