# hyperlink to the ToC page

I want to have hyperlinks pointing to the ToC page. (In my MWE, the links are situated in the section titles, but it makes no difference for the discussion here). My MWE:

\documentclass{article}
\usepackage{hyperref}
\usepackage{blindtext}

\let\oldtableofcontents\tableofcontents
\renewcommand{\tableofcontents}[0]{\label{toc}\oldtableofcontents}

\begin{document}
First page\newpage
\tableofcontents\newpage

\section{Premier. Go to \hyperref[toc]{toc}}
\blindtext  \blindtext
\section{deuxieme. Go to \hyperref[toc]{toc}}
\blindtext  \blindtext
\section{Troisieme. Go to \hyperref[toc]{toc}}
\blindtext  \blindtext
\end{document}


It works only partially: the links are there, but if I click on them, it goes to the "first page", instead of the ToC page. I redefined \tableofcontents, in order to put a label juste before \tableofcontents, but I guess this is the problem. In the original command \tableofcontents, the must be at the beginning some initialisation, like \newpage or similar, which makes the problem.

-
You need a reference point. Therefore you can use \phantomsection or hyperrlink. Use \phantomsection\label{toc}. –  Marco Daniel Feb 24 '12 at 9:52
ok, i think i understand. I thought \label create a reference point, but actually, it can only refer to a section, and not to any point in the text, am i right ? –  nicolas roy Feb 24 '12 at 10:12
linking-the-section-text-to-the-toc –  cmhughes Feb 24 '12 at 17:07

Use \hypertarget and \hyperlink for placing targets and linking to them. You can use \addtocontents to write the \hypertarget into the .toc file.

\documentclass{article}
\usepackage{hyperref}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
First page\newpage
\tableofcontents\newpage
\section[Premier]{Premier. Go to \hyperlink{toc}{toc}}
\blindtext  \blindtext
\section[Deuxieme]{Deuxieme. Go to \hyperlink{toc}{toc}}
\blindtext  \blindtext
\section[Troisieme]{Troisieme. Go to \hyperlink{toc}{toc}}
\blindtext  \blindtext
\end{document}


Or, even better, place \hypertarget directly before \tableofcontents, but make \clearpage before.

\clearpage
\hypertarget{toc}{}
\tableofcontents


This ensures to link above the contents heading. The \addtocontents way places the target below the heading.

-