【问题标题】:toc links point to wrong pagestoc 链接指向错误的页面
【发布时间】:2015-04-04 10:55:55
【问题描述】:

我有一个简单的 tex 文件。当我用$ pdflatex test.tex 编译它时,它会生成一个pdf。目录有可点击的链接,但它们不起作用! 页码是正确的,但是当我单击一行时,它会将我引导到错误的页面。

有人知道我该如何解决吗?

这是我的代码:

\documentclass[12pt,titlepage]{scrartcl}

\usepackage[nottoc,numbib]{tocbibind}
\usepackage{graphicx}
\usepackage[section]{placeins}
\usepackage{float}
\usepackage{amsmath}
\usepackage[autostyle=false,german=quotes]{csquotes}  %% for \enquote{}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\usepackage[]{hyperref}
\title{test}
\author{me}
\date{\today}

\begin{document}
\pagenumbering{roman}
\begin{titlepage}
\maketitle
\end{titlepage}
\setcounter{section}{-1}
\section[]{Abstract}
blabla bla
\newpage
\tableofcontents
\newpage
\pagenumbering{arabic}
\part{part1}
\setcounter{section}{-1}
\section[]{Abstract}
\section{sec a 1}
bla bla
\subsection{sec a 1.1}
bla blub
\section{sec a 2}
\newpage
\part{part2}
\setcounter{section}{-1}
\section[]{Abstract}
\section{sec b 1} % the toc entry for this section points to page 1 but it is on page 2
blub blub
\section{sec b 2}  % the toc entry for this section points to page 1 but it is on page 2
blub blub
\subsection{sec b 2.1} % the subsection in the toc points to the right 2nd page!

\end{document}

在这里您可以看到目录。如您所见,鼠标悬停提示表示链接指向第 1 页,但右侧的数字表示它位于第 2 页。

提前致谢。

【问题讨论】:

    标签: latex tex pdflatex tableofcontents


    【解决方案1】:

    每当您重复使用可能进入链接的hyperref 计数器时,就会出现重复的超链接。视觉上这很好,但在文档内部,跳转是模棱两可的。所以,你需要给hyperref一些帮助。

    绕过这个问题并提供hyperref 一些帮助的最简单方法是添加到您的序言中

    \renewcommand{\theHsection}{\thepart.section.\thesection}
    

    加载hyperref 后。以上将\thepart. 附加到hyperref 相关的\section 链接。由于 \section 计数器的重复使用是基于您对 \parts 的使用,因此此添加将创建一个唯一的链接并删除不明确的目标。

    【讨论】:

    • 谢谢,听起来不错。我会在今天晚上回家的时候尝试一下,如果它对我有用,我会接受答案。
    猜你喜欢
    • 2019-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-19
    • 1970-01-01
    • 2013-01-27
    • 2015-03-15
    • 1970-01-01
    相关资源
    最近更新 更多