Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 11 down vote accepted

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.

share|improve this answer
    
Nailed! Thanks. –  Olivier Drolet Nov 23 '11 at 16:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.