toc 和 pdf 的索引不匹配

toc 和 pdf 的索引不匹配

这是一个跟进“目录页码不正确”。目录显示正常,但无法在文档查看器的索引中正确再现:层次结构被破坏,页码略有偏差。Evince(索引称为大纲)也存在同样的问题。

平台:Linux Mint 19,AucteX v 11.91

命令行界面

$ evince --version
GNOME Document Viewer 3.28.4
$ latex --version
pdfTeX 3.14159265-2.6-1.40.19 (TeX Live 2018)
kpathsea version 6.3.0
Copyright 2018 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.34; using libpng 1.6.34
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 4.00

乳胶:

\documentclass[
french,
%draft,
%  paper=A4,
%  version=last,
%  NF,
  12pt
 % ,
 % toc=bibnumbered
]{scrreprt}%artcl}
% \usepackage{adjustbox}
\usepackage[french]{babel}
\usepackage{fancyhdr}
\usepackage[T1]{fontenc}
%\usepackage{fontspec}
\usepackage{keyfloat}
\usepackage{lastpage}
\usepackage{mwe}
\usepackage{pdfpages}
\usepackage{refcount}
%%\usepackage{scrpage2}
%\usepackage{scrlayer-scrpage}
\usepackage{textcomp}
\usepackage{tocloft}
\usepackage{ulem}
\usepackage{xparse}
\usepackage{xwatermark}
\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref}

%must come last
\usepackage{hyperref}


%\AtEndDocument{\label{LastPage}}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[c]{\thepage/\pageref{LastPage}}
\pagestyle{fancy}


\begin{document}


  \begin{titlepage}


TITRE

\end{titlepage}

\tableofcontents

\part{A}



  \section{my section}

\clearpage
\phantomsection
\addcontentsline{toc}{subsection}{Foo}
\label{foo}
\includepdf[pages={1}]{example-image-plain.pdf}

\clearpage
\csname phantomsection \endcsname
\addcontentsline{toc}{subsection}{Bar}
\label{bar}
\includepdf[pages={1}]{example-image-plain.pdf}


\clearpage
\csname phantomsection \endcsname
\addcontentsline{toc}{subsection}{Baz}
\label{baz}
\includepdf[pages={1}]{example-image-plain.pdf}


\part{B}

\end{document}

展示

答案1

没有和\chapter之间。因此您会收到警告:\part\section

书签级别之间的差异(2)大于一,级别固定在输入上......

以及书签中的错误层次结构。

您可以加载包bookmark以避免此问题。

示例(假设您确实需要/想要包xwatermark):

\documentclass[
  french,
  12pt
]{scrreprt}
\usepackage[french]{babel}

\usepackage[T1]{fontenc}
\usepackage{lastpage}
\usepackage{mwe}
\usepackage{pdfpages}

\usepackage{xwatermark}% loads fancyhdr

%must come last
\PassOptionsToPackage{hyphens}{url}
\usepackage{hyperref}
\usepackage{bookmark}% <- added

\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[c]{\thepage/\pageref{LastPage}}
\pagestyle{fancy}
\begin{document}
\tableofcontents
\part{A}
\section{my section}
\includepdf[pages={1},addtotoc={1,subsection,\subsectionnumdepth,Foo,foo}]{example-image-plain.pdf}
\includepdf[pages={1},addtotoc={1,subsection,\subsectionnumdepth,Bar,bar}]{example-image-plain.pdf}
\includepdf[pages={1},addtotoc={1,subsection,\subsectionnumdepth,Baz,baz}]{example-image-plain.pdf}
\part{B}
\end{document}

结果:

在此处输入图片描述

相关内容