答案1
您可以使用包imakeidx
和hyperref
自动获取页面链接:
\begin{filecontents}[force]{\jobname.ist}
headings_flag 1
heading_prefix "\\par\\penalty-50\\textbf{"
heading_suffix "}\\par\\nobreak"
\end{filecontents}
\documentclass{article}
\usepackage{imakeidx}
\makeindex[options={-s \jobname.ist}]
\usepackage{hyperref}
\begin{document}
\setcounter{page}{5}
Parity\index{Parity}
\newpage\mbox{}\newpage\mbox{}\newpage
Acquaintances\index{Acquaintances}
Coprime\index{Coprime}
lattice\index{lattice}
\printindex
\end{document}
注意:红色框架仅显示在 PDF 查看器中,不会打印。hyperref
还提供使用下划线或彩色链接代替框架或不显示链接的选项。有关更多信息,请参阅手册。
编辑:通过您在编辑的问题中显示的设置,您也已经在索引中获得链接:
\documentclass{article}
\usepackage[xindy]{imakeidx}% Note: With xindy you have to run pdflatex with option --shell-escape. See section 4 of the imakeidx manual.
\makeindex
\usepackage[hidelinks]{hyperref}% Option hidelinks does not make much sense, because the options set by \hyperset below will overwrite it.
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=blue,
urlcolor=blue,
citecolor=blue,
pdftitle={Alessandro Lin}
}
\hypersetup{linktocpage}
\begin{document}
\setcounter{page}{5}
Parity\index{Parity}
\newpage\mbox{}\newpage\mbox{}\newpage
Acquaintances\index{Acquaintances}
Coprime\index{Coprime}
lattice\index{lattice}
\printindex
\end{document}