Reputation: 167
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?
Upvotes: 5
Views: 6876
Reputation: 1005
This worked for me.
% Make the page number link back to the table of contents
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[C]{\hyperlink{toc}{\thepage}}
}
...
\hypertarget{toc}{} % anchor for page number to link to
\tableofcontents
Upvotes: 0
Reputation: 1574
Here is how I did it
% !TEX encoding = UTF-8 Unicode
% !TEX TS-program = xelatex
\documentclass[UTF8, english]{article}
\usepackage{lipsum} %% produce dummy texts
\usepackage{hyperref}
\usepackage[pagestyles]{titlesec}
\newpagestyle{article}{
\setfoot
%% even pages
[]
[\footnotesize \hyperlink{toc}{\thepage}]
[]
%% odd pages
{}
{\footnotesize \hyperlink{toc}{\thepage}}
{}
}
\begin{document}
\title{example}
\date{}
\author{author}
\maketitle
\pagenumbering{roman}
\setcounter{tocdepth}{2}
\addtocontents{toc}{\protect\hypertarget{toc}{}}
\tableofcontents
\newpage
\pagenumbering{arabic}
\pagestyle{article}
\section{A}
\lipsum[1]
\subsection{a}
\lipsum[2]
\subsection{b}
\lipsum[3]
\subsection{c}
\lipsum[4]
\section{B}
\lipsum[5]
\subsection{d}
\lipsum[6]
\subsection{e}
\lipsum[7]
\section{C}
\lipsum[8]
\subsection{f}
\lipsum[9]
\subsection{g}
\lipsum[10]
\subsection{h}
\lipsum[11]
\end{document}
you can of course customize the link text back to table of contents however you like in the preamble, please read documentation of titlesec
for more details.
Upvotes: 0
Reputation: 3620
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}
.
Upvotes: 2
Reputation: 4113
Have you tried defining the page numbering using this?
\pagestyle{myheadings}
\markright{ ... }
where \markright specifies the page number with a link to the content page.
Upvotes: 0