The quasi-MWE below uses the memoir class and works fine. It produces a document with the following structure:
- ToC
- Book
- Part1
- Chapter1
- Part2
- Chapter2
- Index
Here, cross-references in the ToC and in the Index all work correctly. But I want to reset Chapter numbers back to "1" in each Part (and ultimately, in each Book, if there are many books). To do so, I uncomment the \counterwithin instructions in the preamble.
Now, depending on the value assigned to hyperref's hypertexnames option, I get the following behaviour:
if
true, the ToC link to Chapter "2" in Part 2 (which is now renumbered to "1") does not works, but the Index link to AAAAA on page "5" does;if
false, the ToC link to Chapter "2" in Part 2 (which is now renumbered to "1") works, but the Index link to AAAAA on page "5" does not.
Am I doing something wrong?
\documentclass[a4paper,12pt]{memoir}
%\counterwithin*{chapter}{part} % Restarts chapter count within Part.
\usepackage{hyperref}
\hypersetup{
hypertexnames=true,
linktocpage=false,
colorlinks=true,
}
\indexintoc
\makeindex[main]
\begin{document}
\frontmatter{}
\tableofcontents*
\mainmatter{}
\book{BookTitleA}
\part{PartTitleA}
\chapter{TitleA}
AAAAA\index[main]{AAAAA}.\\
\part{PartTitleB}
\chapter{TitleB}
BBBBB.
\backmatter
\clearpage
\printindex[main]
\end{document}
%\counterwithin*{chapter}{part} % Restarts chapter count within Part.
\usepackage{hyperref} \hypersetup{ hypertexnames=true, linktocpage=false, colorlinks=true, } \indexintoc \makeindex[main]
\begin{document} \frontmatter{} \tableofcontents* \mainmatter{} \book{BookTitleA} \part{PartTitleA} \chapter{TitleA} AAAAA\index[main]{AAAAA}. \part{PartTitleB} \chapter{TitleB} BBBBB. \backmatter \clearpage \printindex[main] \end{document}`
– Olivier Drolet Oct 19 '11 at 19:45editand add the relevant code, rather than posting uncommented code in a comment. Once you're done, clean up the comments section be removing the non-relevant ones. – Werner Oct 19 '11 at 20:03