I know that there is the following post

but I could not find what I want.

What I want is to add in (almost) every page of my document (class book) a reference to the TOC page as below:

All the pages before the TOC would not contain a link. The same holds true for the first page of each chapter and the first page of the table of contents.

As a minimal working code

\documentclass[12pt]{book}
\usepackage[french]{babel}
\usepackage[utf8]{inputenc}

\usepackage[pdftex]{graphicx}

\usepackage{lipsum}

\usepackage[Lenny]{fncychap}

\usepackage{pdfpages}
\setlength{\oddsidemargin}{.5cm} \setlength{\evensidemargin}{.5cm}
\setlength{\textwidth}{15cm} \setlength{\textheight}{21.0cm}
\setlength{\topmargin}{0in}
\renewcommand\contentsname{Table des mati\eres}

\parindent 0ex

%\usepackage{hyperref}

urlcolor=blue,
pdftitle={Dossier de Candidature},
pdfauthor={Dimitrios S. Anagnostou}]{hyperref}

\usepackage[affil-it]{authblk}

\parindent0pt  \parskip10pt

\begin{document}

\title{DOSSIER DE CANDIDATURE}
\author{Dimitrios Papas\thanks{vbkvbkvbdkvbd}}

\affil{
Université\ldots}

\date{\begin{center}
Docteur en Mécanique
\end{center}}

\maketitle \thispagestyle{empty}

\frontmatter

\tableofcontents

\chapter*{Avant propos}
\lipsum

\mainmatter

\chapter{First}

\section{First section}
\lipsum

\chapter{Second}
\section{First section}
\lipsum

\end{document}

• Apparently you have forgotten to supply the magnifying glass together with your screen shot? And the starter code as well ;-) – user31729 Mar 6 '17 at 18:37
• You are right. I apologize. I will put a minimal example and a bigger picture. – Dimitris Mar 6 '17 at 18:37

The key is to place a \label at the start of the ToC. To achieve this, we force a new page (\clearpage) and place a hyperref marker \phantomsection. Now we can place a regular \label which we use as a hyperlink in the footer:

\documentclass{book}

\usepackage{fancyhdr,hyperref}
\usepackage{lipsum}

\fancypagestyle{mainmatter-pages}{%
\renewcommand{\footrulewidth}{0pt}% Remove footer rule
\fancyfoot[C]{\thepage}
}
\let\oldtableofcontents\tableofcontents
\renewcommand{\tableofcontents}{%
\cleardoublepage
\oldtableofcontents
}
\let\oldmainmatter\mainmatter
\renewcommand{\mainmatter}{%
\cleardoublepage
\oldmainmatter
\pagestyle{mainmatter-pages}%
}
\begin{document}

\frontmatter

\tableofcontents

\mainmatter

\chapter{First chapter}
\lipsum[1-50]
\chapter{Second chapter}
\lipsum[1-50]
\chapter{Third chapter}
\lipsum[1-50]
\chapter{Final chapter}
\lipsum[1-50]

\end{document}


The process is "automated" by replacing the \tableofcontents and \mainmatter macros to insert the appropriate links and settings (leaving the regular document code clean).

The footer can be modified to suit your needs.

• Thank you very much. But when I run the minimal example with your workaround I get error messages. – Dimitris Mar 6 '17 at 19:34
• @dimitris: Please see this paste which uses your minimal example with the additions I suggest. – Werner Mar 6 '17 at 19:42
• @Werner It seems not to be absolutely necessary the inclusion of a forced new page... As I'm still a newbie I would like to know if you liked that way for some reason. Thank you – Crparedes Sep 27 '19 at 22:49
• @Crparedes: The reason for that is a round-about way of latching on to \tableofcontents. Under book, it necessarily sets a \chapter*` which forces a new page anyway. – Werner Sep 27 '19 at 23:32