当我点击那里的内容时,LaTeX hyperref 链接会转到错误的页面

标签 latex tex tableofcontents hyperref

我想问一下如何使用\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}

最佳答案

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

另外,您的 \tableofcontents可能不止一页。所以,发出 \addcontentsline{toc}{chapter}{Table of Contents}之后 \tableofcontents - 一个 \chapter* - 可能再次指向不正确的页面。

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

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

这将确保 \addcontentsline\chapter同页发布或 \chapter* .

关于当我点击那里的内容时,LaTeX hyperref 链接会转到错误的页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27765482/

相关文章:

latex - LaTeX 中缩略语的使用

vim - 为标签和围兜项目的 latex 创建标签文件

bash - 内联 LaTeX\input 命令

rtf - 将目录添加到 RTF 文档

r - 如何更改knitr中的目录标题?

automation - LibreOffice Automation - 全部更新

emacs - 在 AucTeX 中按\section 折叠 LaTeX 文档?

latex - 狮身人面像到 latex 人物放置

latex - 我可以将LaTeX宏 'return'设为文件名吗?

latex - 转换tex源,以便所有宏都被其定义替换