Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get page numbers to link to the table of contents in latex?

Tags:

latex

hyperref

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?

like image 866
qaz Avatar asked Nov 05 '22 10:11

qaz


1 Answers

You could set an anchor at the toc and redefine \thepage to link to it. Here's an example:

\documentclass{report}
\usepackage[colorlinks]{hyperref}
\renewcommand*{\contentsname}{\hyperlink{contents}{Contents}}
\renewcommand*{\thepage}{\hyperref[contents]{\arabic{page}}}
\begin{document}
\tableofcontents
\chapter{One}
Text
\end{document}

If you use babel and wish to redefine \contentsname, use the \addto command of babel or redefine \contentsname after \begin{document}.

like image 139
Stefan Avatar answered Dec 02 '22 05:12

Stefan