toc 链接指向错误的页面

toc links point to wrong pages

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

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

这是我的代码:

\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}

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

提前致谢。

每当您重复使用可能进入 link 的 hyperref 计数器时,就会出现重复的 hyperlink。从视觉上看这很好,但在文档内部,跳转是不明确的。所以,你需要提供hyperref一些帮助。

避免此问题并提供hyperref一些帮助的最简单方法是添加到您的序言

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

加载后 hyperref。以上将 \thepart. 添加到 hyperref 相关的 \section link 之前。由于 \section 计数器的重复使用是基于您对 \part 的使用,因此此添加将形成一个独特的 link 并消除不明确的目的地。