tags:

views:

49

answers:

2

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?

A: 

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.

Sentry
+1  A: 

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}.

Stefan
Almost worked. The page numbers are links as I wanted, but unfortunately the linking mechanism fails, and ends up linking to the first page instead of the anchor on the contents page. It says 'contents' is undefined.
qaz
If you replace [contents] with a label to an equation it works. However the command \hyperref[label]{text} does not work when label is a reference to an anchor.
qaz
Do you use babel? See my last remark then.
Stefan
I haven't explicitly added the babel package. I moved the renewcommands to after the \begin{document} command anyway. I still get the same problem.
qaz