Hey fellow LaTeX users.
Is there any way to make the page numbers in a document hyperrefback to the header of the TOC?
It would be very useful in my document so I quickly could jump back and forth to the ToC.
Hey fellow LaTeX users.
Is there any way to make the page numbers in a document hyperrefback to the header of the TOC?
It would be very useful in my document so I quickly could jump back and forth to the ToC.
You could add a \label just before \tableofcontents which could be indexed and linked to by hyperref. Here’s a minimal example:
\documentclass{report}
\usepackage{hyperref}
% Set up the header and footer
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[CO]{\thepage}
\renewcommand{\headrulewidth}{0pt}
% Put the link in the header
\fancyhead[RO]{This is a link to the~\hyperref[toc-contents]{\textbf{Table of Contents}}}
% This fills the document with dummy text
\usepackage{blindtext}
\begin{document}
\label{toc-contents}
\tableofcontents
\blinddocument
\end{document}
and the top of a page looks something like:

Clicking the bold text would take you to the table of contents.
Of course, you could use something other than fancyhdr to set up the link in the header if you have a different package that you prefer or are already using.
ETA: I should really have read the question more carefully. If you want the page numbers to link to the table of contents, then you replace the header/footer code above by
% Set up the header and footer
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
% Put the link in the footer
\fancyfoot[CO]{\hyperref[toc-contents]{\thepage}}
\fancyhead[RO]{\hyperref[toc-contents]{\thepage}} instead of the fancyfoot[…]{…}.
– alexwlchan
Nov 07 '13 at 09:49
\newpage, the links back to TOC actually link back to the first page instead of TOC. What do I need to change?
– Erik Vesterlund
Sep 05 '17 at 17:46