I'm using the hyperref package to create hyperlinks in my document. The links from the TOC->chapters/sections work great, but I was wondering if there was a way to automatically insert hyperlinks from section titles BACK to the TOC (section->TOC). For easier two-way navigation (especially when clicking on an incorrect link in the TOC).

In case it matters I'm working in the report class, and this is a (minimized) version of what I have now.

\documentclass[11pt,a4paper]{report}
\usepackage{hyperref}

\begin{document}
First page

\clearpage
\tableofcontents
\clearpage

Blank page

\clearpage
\chapter{First chapter}
\end{document}


Thanks for any help!

-

## marked as duplicate by krlmlr, Papiro, Ruben, Svend Tveskæg, JesseJul 30 at 10:39

Here's one possible solution using the \hyperlink, \hypertarget mechanism; \hyperlinks are conveniently added using a redefinition of \@makechapterhead and a redefinition of \@chapter was used to place the corresponding \hypertargets:

\documentclass{report}
\usepackage{hyperref}

\makeatletter
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
{\protect\numberline{\thechapter}\string\hypertarget{chap\thechapter}{#1}}%
\else
\fi
\chaptermark{#1}%
\if@twocolumn
\else
\fi}
\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\huge\bfseries \@chapapp\space \thechapter
\par\nobreak
\vskip 20\p@
\fi
\interlinepenalty\@M
\vskip 40\p@
}}
\makeatother

\begin{document}

\tableofcontents
\chapter{Test Chapter One}
\chapter{Test Chapter Two}
\chapter{Test Chapter Three}

\end{document}


Here's the same idea using this time the titlesec package with its explicit option to place the \hyperlinks:

\documentclass{report}
\usepackage[explicit]{titlesec}
\usepackage{hyperref}

\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}
\titleformat{name=\chapter,numberless}[display]
{\normalfont\huge\bfseries}{}{-22pt}
{\Huge#1}

\makeatletter
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
{\protect\numberline{\thechapter}\string\hypertarget{chap\thechapter}{#1}}%
\else
\fi
\chaptermark{#1}%
\if@twocolumn
\else
\fi}
\makeatother

\begin{document}

\tableofcontents
\chapter{Test Chapter One}
\chapter{Test Chapter Two}
\chapter{Test Chapter Three}

\end{document}

-

use \hypertarget

\documentclass{book}
\usepackage{hyperref}

\begin{document}
\tableofcontents