2

Just gonna ask a question from 4 years ago:

"I've seen a pdf LaTeX document where the page numbers at the bottom of the page are hyperref links, and clicking them causes you to jump to the contents table. I don't have the tex file and couldn't work out how it's done from the hyperref package. Can anyone help?" https://stackoverflow.com/questions/3393606/how-can-i-get-page-numbers-to-link-to-the-table-of-contents-in-latex

Exactly this is the thing I want. Unfortunely non of those answers work. Of course I could put a "\hyperref" at every page, but if I have a 100 site essay, that will take quite a long time.

EDIT:

\documentclass[10pt,a4paper,colorlinks]{article}
\usepackage[german]{babel} 
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry} 
\usepackage{hyperref} 
\usepackage{tocloft}
\usepackage{lipsum}
\begin{document}
\tableofcontents
\thispagestyle{empty} 
\setcounter{page}{0} 
\newpage
\section{Text 1}
\lipsum{1}
\newpage
\section{Text 2}
\lipsum{2}
\end{document}

Hopefully I didn´t deleted something related. Set

%\thispagestyle{empty} 
%\setcounter{page}{0} 

To be able to see the first page number on the first page.

  • Did you try \rfoot{\hyperref[TOC]{\thepage}} ? Assuming you're using the fancyhdr package. – user17424 Feb 9 '15 at 19:41
  • Please post a minimal working example (MWE) showing why the link answers don't work. – Andrew Swann Feb 9 '15 at 19:41
  • Doesn't my answer work for you? – karlkoeller Feb 9 '15 at 21:24
  • The solution you wrote (karlkoeller) unfortunately only works for the first site. "minimal working example" added. – Draco Lestrang Feb 9 '15 at 21:46
  • The solution \rfoot{\hyperref[TOC]{\thepage}} does compile, but does nothing with my dokumetn. – Draco Lestrang Feb 9 '15 at 21:55
3

This works:

\documentclass[10pt,a4paper,colorlinks]{article}
\usepackage[german]{babel}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{hyperref}
\usepackage{tocloft}
\usepackage{lipsum}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\ps@plain}{\thepage}{\hyperlink{contents}{\thepage}}{}{}
\makeatother
\addto\captionsgerman{\renewcommand*{\contentsname}{\hypertarget{contents}{Inhaltsverzeichnis}}}
\pagestyle{plain}
\begin{document}
\tableofcontents
\thispagestyle{empty}
\setcounter{page}{0}
\newpage
\section{Text 1}
\lipsum
\newpage
\section{Text 2}
\lipsum
\end{document} 
  • This solution only works for the first site. – Draco Lestrang Feb 9 '15 at 21:45
  • @DracoLestrang Edited according to your MWE. – karlkoeller Feb 9 '15 at 21:52
  • uhhh so what if I'm not using German? – gghuffer Sep 10 '15 at 21:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.