PDF 查看器显示的轮廓不正确

PDF 查看器显示的轮廓不正确

我尝试按照下面的目录结构来组织我的书。但是,正如您在下面的屏幕截图中看到的那样,PDF 查看器中的大纲不正确。

在此处输入图片描述

我使用的底层 LaTeX 代码是:

\documentclass{book}
\usepackage{hyperref}

\begin{document}

\tableofcontents

\part{First part}

This is the first part.

\chapter{First chapter in first part}

This is the first chapter in the first part.

\section{Section in first chapter}

\part{Second part}

This is the second part.

\chapter{First chapter in second part}

This is the first chapter in the second part.

\part*{Appendix}
\addcontentsline{toc}{part}{Appendix}
\setcounter{chapter}{0} % Reset numbering for chapter

\chapter{First chapter in appendix}

This is the first chapter in the appendix.

\section{Section in appendix}

\end{document}

我很高兴收到任何指点。:-)

答案1

您会在日志中收到警告:

pdfTeX warning (ext4): destination with the same identifier (name{ch
apter.1}) has been already used, duplicate ignored
<to be read again> 
                   \relax 
l.46 \chapter{First chapter in appendix}

此类警告应引起重视。它们通常意味着内部链接结构存在混乱。

您可以通过重新定义 \theHchapter 来使目的地的名称变得唯一:

\documentclass{book}
\usepackage{hyperref}

\begin{document}

\tableofcontents

\part{First part}

This is the first part.

\chapter{First chapter in first part}

This is the first chapter in the first part.

\section{Section in first chapter}

\part{Second part}

This is the second part.

\chapter{First chapter in second part}

This is the first chapter in the second part.

\part*{Appendix}
\addcontentsline{toc}{part}{Appendix}
\renewcommand\theHchapter{Appendix.\thechapter}
\setcounter{chapter}{0} % Reset numbering for chapter

\chapter{First chapter in appendix}

This is the first chapter in the appendix.

\section{Section in appendix}

\end{document}

然后书签也将正确:

在此处输入图片描述

相关内容