0

This is a follow up to "Table of Contents incorrect page numbering". The TOC comes out fine, but it is not properly reproduced in the Document Viewer's Index: the hierarchy is broken and page # are off slightly. Same problem with Evince (Index called Outline).

Platf: Linux Mint 19, AucteX v 11.91

CLI

$ 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

LaTeX:

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

display

1

There is no \chapter between \part and \section. So you get the warning:

Difference (2) between bookmark levels is greater than one, level fixed on input ...

and the wrong hierachy in the bookmarks.

You can load package bookmark to avoid this issue.

Example (assuming you really need/want 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}

Result:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.