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.

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

2 Answers 2

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} 
3
  • This solution only works for the first site. Commented Feb 9, 2015 at 21:45
  • @DracoLestrang Edited according to your MWE. Commented Feb 9, 2015 at 21:52
  • uhhh so what if I'm not using German?
    – gghuffer
    Commented Sep 10, 2015 at 21:36
1

This worked for me.

% Make the page number link back to the table of contents
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[C]{\hyperlink{toc}{\thepage}}
\fancypagestyle{plain}{
    \fancyhf{}
    \fancyfoot[C]{\hyperlink{toc}{\thepage}}
}
...

\hypertarget{toc}{} % anchor for page number to link to
\tableofcontents

See also: https://stackoverflow.com/questions/3393606/how-can-i-get-page-numbers-to-link-to-the-table-of-contents-in-latex

1
  • \pagestyle{fancy} \fancyfoot[C]{\hyperlink{toc}{\thepage}} \fancypagestyle{plain}{ \fancyhf{} \renewcommand{\headrulewidth}{0pt} \fancyfoot[C]{\hyperlink{toc}{\thepage}} } removes the line under the header for new chapters
    – user631874
    Commented Apr 1 at 8:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .