2

The bookmark/link in PDF to the second part ("Quels impacts ?") leads to the wrong page (one early). This is also true for the ToC in the PDF (the page number here is correct, just the hyperlink is wrong).

For example:

\documentclass[french,a4paper,12pt,twoside]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{lmodern}
\usepackage{float}
\usepackage{graphicx}
\usepackage{numprint}
\usepackage{eurosym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{listings}
\usepackage{wrapfig}
\usepackage[top=3cm, bottom=3cm, left=2cm, right=2cm]{geometry}
\usepackage{framed}
\usepackage{fancyhdr}
\usepackage{listings}
\usepackage{url}
\usepackage{csquotes}
\usepackage{lettrine}
\usepackage{chngcntr}
\usepackage[table]{xcolor}
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\counterwithout{footnote}{chapter}
%\counterwithin*{chapter}{part}
\makeatletter\@addtoreset{chapter}{part}\makeatother%

\newcounter{intext}

\usepackage[autolang=hyphen,backend=biber,
style=numeric,pagetracker=false,
ibidtracker=true,
citetracker=context]{biblatex}

\usepackage[tight]{shorttoc} 
\addtocontents{toc}{\protect\thispagestyle{empty}}

\usepackage{lastpage}
\usepackage{color}
\usepackage[
bookmarks,
colorlinks=true,
]{hyperref}


\setcounter{tocdepth}{6}
\setcounter{secnumdepth}{6}

%voir aussi le fichier report.cls
%car j'ai modifié 2 ou 3 trucs
\renewcommand{\thepart}{Partie \Roman{part}}
\renewcommand{\thechapter}{\arabic{chapter}}
\renewcommand{\thesection}{\Roman{section}}
\renewcommand{\thesubsection}{\Alph{subsection})}
\renewcommand{\thesubsubsection}{\arabic{subsubsection}.}
\renewcommand{\theparagraph}{\alph{paragraph})}

\patchcmd{\footnotemark}{\stepcounter{footnote}}{\refstepcounter{footnote}}{}{}

\newcommand{\npshorttableofcontents}[2]{%
  \begingroup
  \let\aslsavedcontentsline\contentsline
  \renewcommand{\contentsline}[3]{%
    \aslsavedcontentsline{##1}{##2}{}%
  }%
  \shorttableofcontents{#1}{#2}
  \endgroup
}

\usepackage{bookmark}

\setlength\parskip{1.5pt plus 1.0pt}
\begin{document}
\clearpage
\chapter*{Remerciements}
\chapter*{Introduction.\label{introduction}}
\addcontentsline{toc}{part}{Introduction.}
\npshorttableofcontents{Sommaire.}{0}
\thispagestyle{plain}

\clearpage
\part{concept et réglementation.}
\chapter{Caractéristiques et composantes.}
\section{Caractéristiques.}
\subsection{Le mouvement }
\chapter{Régime juridique.}
\clearpage
\part{Quels impacts ?}
\chapter{amélioration du service public}
\section{Amélioration.}
\subsection{Améliorer la gouvernance}


\clearpage
\phantomsection 
\addcontentsline{toc}{chapter}{Bibliographie.}
\printbibliography

\clearpage
\phantomsection 
\addcontentsline{toc}{chapter}{\listfigurename.}
\listoffigures

\clearpage
\phantomsection 
\addcontentsline{toc}{chapter}{\listtablename.}
\listoftables

\clearpage

\protect\thispagestyle{fancy}
\tableofcontents
\end{document}

The result is: Result with wrong link

The link leads to the page 5 and not the page 8.

What is wrong ?

2 Answers 2

3

Just move \@addtoreset or \counterwithin after hyperref is loaded, because hyperref redefines them to adjust the additional counter theHchapter, which is used for the anchor (destination) names. These names need to be unique. Since chapter numbers aren't unique any more, the part number is added to the chapter number in theHchapter.

2

Since you redefine the chapter counter to be subordinate to part, the bookmarks in the second part will refer to the sections numbered alike in the first part. You see this from the warnings of the form

pdfTeX warning (ext4): destination with the same identifier (name{chapte
r.1}) has been already used, duplicate ignored
<to be read again> 
                   \relax 
l.90 \chapter{amélioration du service public}

Workaround: define \theHchapter, so hyperref will use it instead of \thechapter.

\counterwithin*{chapter}{part}
\newcommand{\theHchapter}{\thepart\arabic{chapter}}

By the way, doing

\makeatletter\@addtoreset{chapter}{part}\makeatother

is just a complicated form of \counterwithin*{chapter}{part}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .