hyperref 链接到错误的图表列表和表格列表页面。所有其他链接似乎都没有问题

hyperref 链接到错误的图表列表和表格列表页面。所有其他链接似乎都没有问题
\documentclass{article}
\usepackage{amsmath}
\usepackage[format=hang,labelsep=period,font={footnotesize},textfont={footnotesize},justification=justified]{caption}
\usepackage[bookmarks=false,pdftex,colorlinks=true,linkcolor=blue,pdfnewwindow=true]{hyperref}
\usepackage{parskip}

\title{Title of Document}
\author{Author's Name}
\date{\today}

\begin{document}

\begin{titlepage}
\maketitle
\end{titlepage}

\tableofcontents
\newpage

\addcontentsline{toc}{section}{\listfigurename}
\listoffigures
\newpage

\addcontentsline{toc}{section}{\listtablename}
\listoftables
\newpage

\section{Introduction}

This is the introduction.

\subsection{Subsection}

Here is table 1.

\begin{center}
\begin{tabular}{| c |}
\hline
item1 \\
item2 \\
\hline
\end{tabular}
\captionof{table}{This is the caption for the first table.}
\end{center}

Discussion of table 1.

Here is the first figure.

\begin{center}
$$\boxed{i^2 = j^2 = k^2 = i j k = -1}$$
\captionof{figure}{My first figure}
\end{center}
\newpage

\section{Discussion}

Here is table 2.

\begin{center}
\begin{tabular}{| c | c |}
\hline
cell1 & cell2 \\
cell3 & cell4 \\
\hline
\end{tabular}
\captionof{table}{This is the caption for the second table.}
\end{center}

Now let's discuss this table.

Here is figure 2.

\begin{center}
$$\boxed{e^{i \pi} + 1 = 0}$$
\captionof{figure}{My second figure}
\end{center}

\end{document}

答案1

如果两个列表都不大于一页,一个非常快速的解决方法是将其放在\addcontentsline调用\listoffigures/之后\listoftables而不是之前。

\documentclass{article}
\usepackage{amsmath}
\usepackage[format=hang,labelsep=period,font={footnotesize},textfont={footnotesize},justification=justified]{caption}
\usepackage[bookmarks=false,pdftex,colorlinks=true,linkcolor=blue,pdfnewwindow=true]{hyperref}
\usepackage{parskip}

\title{Title of Document}
\author{Author's Name}
\date{\today}

\begin{document}

\begin{titlepage}
\maketitle
\end{titlepage}

\tableofcontents
\newpage

\listoffigures %<--- SWAPPED
\addcontentsline{toc}{section}{\listfigurename} %<--- SWAPPED
\newpage

\listoftables %<--- SWAPPED
\addcontentsline{toc}{section}{\listtablename} %<--- SWAPPED
\newpage

\section{Introduction}

This is the introduction.

\subsection{Subsection}

Here is table 1.

\begin{center}
\begin{tabular}{| c |}
\hline
item1 \\
item2 \\
\hline
\end{tabular}
\captionof{table}{This is the caption for the first table.}
\end{center}

Discussion of table 1.

Here is the first figure.

\begin{center}
$$\boxed{i^2 = j^2 = k^2 = i j k = -1}$$
\captionof{figure}{My first figure}
\end{center}
\newpage

\section{Discussion}

Here is table 2.

\begin{center}
\begin{tabular}{| c | c |}
\hline
cell1 & cell2 \\
cell3 & cell4 \\
\hline
\end{tabular}
\captionof{table}{This is the caption for the second table.}
\end{center}

Now let's discuss this table.

Here is figure 2.

\begin{center}
$$\boxed{e^{i \pi} + 1 = 0}$$
\captionof{figure}{My second figure}
\end{center}

\end{document}

编辑:正如@Ulrike Fischer 评论的那样,更好的方法是使用\phantomsection无论列表的页面长度如何都有效的方法。

\documentclass{article}
\usepackage{amsmath}
\usepackage[format=hang,labelsep=period,font={footnotesize},textfont={footnotesize},justification=justified]{caption}
\usepackage[bookmarks=false,pdftex,colorlinks=true,linkcolor=blue,pdfnewwindow=true]{hyperref}
\usepackage{parskip}

\title{Title of Document}
\author{Author's Name}
\date{\today}

\begin{document}

\begin{titlepage}
\maketitle
\end{titlepage}

\tableofcontents
\newpage

\phantomsection%<---
\addcontentsline{toc}{section}{\listfigurename}  
\listoffigures 

\newpage

\phantomsection%<---
\addcontentsline{toc}{section}{\listtablename} 
\listoftables 
\newpage

\section{Introduction}

This is the introduction.

\subsection{Subsection}

Here is table 1.

\begin{center}
\begin{tabular}{| c |}
\hline
item1 \\
item2 \\
\hline
\end{tabular}
\captionof{table}{This is the caption for the first table.}
\end{center}

Discussion of table 1.

Here is the first figure.

\begin{center}
$$\boxed{i^2 = j^2 = k^2 = i j k = -1}$$
\captionof{figure}{My first figure}
\end{center}
\newpage

\section{Discussion}

Here is table 2.

\begin{center}
\begin{tabular}{| c | c |}
\hline
cell1 & cell2 \\
cell3 & cell4 \\
\hline
\end{tabular}
\captionof{table}{This is the caption for the second table.}
\end{center}

Now let's discuss this table.

Here is figure 2.

\begin{center}
$$\boxed{e^{i \pi} + 1 = 0}$$
\captionof{figure}{My second figure}
\end{center}

\end{document}

相关内容