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
2010-08-03 09:01:56
+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
2010-08-03 10:58:04
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
2010-08-03 13:51:03
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
2010-08-03 14:15:36
Do you use babel? See my last remark then.
Stefan
2010-08-04 00:29:00
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
2010-08-04 20:22:03