toc 和 pdf 索引不匹配

toc 和 pdf 索引不匹配

這是一個跟進“目錄頁碼不正確”。目錄顯示正常,但在文件檢視器索引中未正確重現:層次結構已損壞,第 # 頁略有偏離。 Evince 也有同樣的問題(索引稱為 Outline)。

平台: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) 大於 1,等級固定於輸入...

以及書籤中的錯誤層次結構。

您可以載入套件bookmark來避免此問題。

範例(假設您確實需要/想要 package 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}

結果:

在此輸入影像描述

相關內容