6

我想问一下如何使用 \hyperref,因为我已经用谷歌搜索了很多答案,但我找不到。我创建了自己的目录。然后我包括 \hyperref 包。然后内容自动成为超链接,这很好。但后来它去了错误的页面。我用谷歌搜索了很多,但我找不到答案。我点击的内容进入了错误的页面。

\documentclass[10pt,a4paper]{report}

\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{enumerate}

\usepackage{hyperref}
% %\usepackage[colorlinks]{hyperref}


% %\renewcommand*{\contentsname}{\hyperlink{contents}{Contents}}
% %\renewcommand*{\contentsname}{\hyperref[contents]{\arabic{page}}}

\begin{document}

\input{coverPage}
\maketitle

\tableofcontents
\addcontentsline{toc}{chapter}{Table of Contents}
\pagebreak

\addcontentsline{toc}{chapter}{List of Figures}
\listoffigures
\pagebreak

% % (1) ==============================================
\setcounter{chapter}{1}
\addcontentsline{toc}{chapter}{1. Introduction}
\input{introduction}
\pagebreak

\addcontentsline{toc}{chapter}{2. References}
\input{references}
\pagebreak

\addcontentsline{toc}{chapter}{3. Glossary}
\input{glossary}
\pagebreak

\end{document}
4

1 回答 1

4

这里的问题是\chapter将自己设置在新页面上,因此\addcontentsline{toc}{chapter}{<chapter title>} 之前 \chapter发布可能指向错误的页面。

此外,您\tableofcontents可能不止一个页面。因此,在 -a -\addcontentsline{toc}{chapter}{Table of Contents} 之后 发出可能会再次指向错误的页面。\tableofcontents\chapter*

最好的解决方案是使用以下设置:

\cleardoublepage
\addcontentsline{toc}{chapter}{<chapter title>}
% <your \chapter or \chapter*>

这将确保在与或\addcontentsline相同的页面上发布。\chapter\chapter*

于 2018-08-30T00:26:44.860 回答