![结合 amsmath、hyperref 和 makeidx 时页面链接出现问题](https://linux22.com/image/468140/%E7%BB%93%E5%90%88%20amsmath%E3%80%81hyperref%20%E5%92%8C%20makeidx%20%E6%97%B6%E9%A1%B5%E9%9D%A2%E9%93%BE%E6%8E%A5%E5%87%BA%E7%8E%B0%E9%97%AE%E9%A2%98.png)
我正在准备一本书,在合并每个部分的编号(使用 amsmath 包)、hyperref 和 imakeindex 时遇到了问题。
我已经为每个部分制作了索引。在这些索引中,打印的页码引用是正确的,但链接总是指向第一部分的相应页面。我找不到任何解决方案,所以请帮忙!
下面的 MWE 显示了这个问题。
\documentclass[12pt]{book}
% Make indices per part
\usepackage{imakeidx}
\indexsetup{level=\section*,toclevel=section,noclearpage,firstpagestyle=empty}
\makeindex[name=subjectsI,title=Subject index Part I,intoc,columns=3, program = truexindy]
\makeindex[name=subjectsII,title=Subject index Part II,intoc,columns=3, program=truexindy]
%
\DeclareRobustCommand{\idxs}[1]{{#1}\index[subjectsI]{#1}}
\DeclareRobustCommand{\idxsII}[1]{{#1}\index[subjectsII]{#1}}
%
%
% Set spaces for table of contents
\usepackage{tocloft,xcolor}
\setlength{\cftchapnumwidth}{2.3em}
\setlength{\cftsecnumwidth}{2.5em}
%
\usepackage[colorlinks=true, pdfstartview=FitV, linkcolor=blue, citecolor=red, urlcolor=black,pageanchor, plainpages=false
hypertexnames]{hyperref}
%
\usepackage{amsmath,amsbsy}
%
% numbering chapters and pages per part (uses amsmath)
\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 \idxs{technology} that keeps transforming our world over and again.
\\[2cm]
thepage = \thepage\\
theHpage = \theHpage
%
%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.
\\[2cm]
thepage = \thepage\\
theHpage = \theHpage
%
%INDICES PART II
%
\chapter*{Indices}
\addcontentsline{toc}{chapter}{Indices}
\printindex[subjectsII]
\clearpage
\end{document}