我有一本包含不同部分的书。我使用 命令对每个部分的章节和页面进行编号。我使用和\numberwithin
为每个部分定义了一个索引。索引列出了该部分中的正确页码,但超链接始终指向第一部分。{imakeidx}
{hyperref}
看来我必须重新定义目标页面来解决页码歧义问题。我无法让它工作,就像使用{hyperref}
一样\theHpage
。
下面我附上了一个可以演示这个问题的工作示例。
\documentclass[12pt]{book}
\usepackage{imakeidx}
\indexsetup{level=\section*,toclevel=section,noclearpage,firstpagestyle=empty}
\makeindex[name=subjectsI,title=Subject index Part I,intoc,columns=3]
\makeindex[name=subjectsII,title=Subject index Part II,intoc,columns=3]
%
\DeclareRobustCommand{\idxs}[1]{{#1}\index[subjectsI]{#1}}
\DeclareRobustCommand{\idxsII}[1]{{#1}\index[subjectsII]{#1}}
%
\usepackage{amsmath,amsbsy}
%
\usepackage[colorlinks=true, pdfstartview=FitV, linkcolor=black, citecolor=black, urlcolor=black,pageanchor,
hypertexnames]{hyperref}
%
% numbering chapters and pages per part
\numberwithin{chapter}{part}
\numberwithin{page}{part}
\numberwithin{equation}{chapter}
\numberwithin{table}{chapter}
%
% BOOK
%
\begin{document}
\pagenumbering{gobble}
\tableofcontents
\cleardoublepage
%
%PART I
%
\setcounter{page}{1}
\part{This is Part I}
\pagenumbering{arabic}
%
\chapter{ Chapter one-one}
\section{Section one-one-one}
All of us have witnessed how science has profoundly affected the human condition and transformed society, and how in many instances it managed to transcend man's painful political, ethnic, and \idxs{religious differences}. As such it is a true \idxs{cornerstone} of civilization.
%
\chapter{Chapter one-two}
\section{Section one-two-one}
It expresses the \idxs{collective curiosity} of mankind and has resulted in a double helix of science and technology that keeps transforming our world over and again.
%
%INDICES PART I
%
\chapter*{Indices}
\addcontentsline{toc}{chapter}{Indices}
\printindex[subjectsI]
\cleardoublepage
%
%PART II
%
\pagenumbering{gobble}
\part{This is Part II}
\pagenumbering{arabic}
%
\chapter{Chapter two-one}
\section{Section two-one-one}
I go deeper and deeper, as I concentrate on writing, into a kind of \idxsII{underground}. While I'm there, I encounter strange things.
%
\chapter{Chapter two-two}
\section{Section two-two-one}
So I look around that world and I describe what I see, and then I come back. Coming back is important. If you cannot come back, it's scary. But I'm a \idxsII{professional}, so I can come back.
%
%INDICES PART II
%
\chapter*{Indices}
\addcontentsline{toc}{chapter}{Indices}
\printindex[subjectsII]
\clearpage
\end{document}