11

I want the reader of output of a PDFLaTeX be able to go back to the table of content or first page. What is a good way of doing this?

Most PDF readers provide a TOC and navigation system but I was looking for something noticeable within the document and at the same time not obtrusive!

Maesumi
  • 9,059

1 Answers1

16

Here's one possibility: I used the background package to place a Return button on every page of the document; the button is placed centered at the bottom of each page (the position of the button can be freely and easily changed). The button is a hyperlink to the ToC; this was created using the \hyperlink, \hypertarget mechanism provided by hyperref. For the "Return" button symbol I used \Return from the keystroke package, but you can use the symbol that better suits your needs:

\documentclass{article}
\usepackage[a6paper]{geometry}% just for the example
\usepackage{background}
\usepackage{etoolbox}
\usepackage{keystroke}
\usepackage{lipsum}% just to generate text for the example
\usepackage[colorlinks=true,linkcolor=cyan]{hyperref}

\makeatletter
\patchcmd{\tableofcontents}{\@starttoc{toc}}{\hypertarget{totoc}{}\@starttoc{toc}}{}{}
\makeatother

\backgroundsetup{
scale=1,
angle=0,
color=black,
position=current page.south,
vshift=20pt,
contents={
  \tikz[remember picture,overlay]
    \node[inner sep=0pt] {\hyperlink{totoc}{\Return}};
  }
}

\begin{document}

\tableofcontents
\section{First section}
\lipsum[4]\lipsum[4]
\lipsum[4]\lipsum[4]
\section{Second section}
\lipsum[4]\lipsum[4]
\lipsum[4]\lipsum[4]

\end{document}

An image of the resulting document:

enter image description here

A zoom of one of the pages, showing the button:

enter image description here

In case you have an older version of background, you can use the old syntax (this will also work in the newer versions):

\documentclass{article}
\usepackage[a6paper]{geometry}% just for the example
\usepackage{background}
\usepackage{etoolbox}
\usepackage{keystroke}
\usepackage{lipsum}% just to generate text for the example
\usepackage[colorlinks=true,linkcolor=cyan]{hyperref}

\makeatletter
\patchcmd{\tableofcontents}{\@starttoc{toc}}{\hypertarget{totoc}{}\@starttoc{toc}}{}{}
\makeatother

\SetBgScale{1}
\SetBgAngle{0}
\SetBgColor{black}
\SetBgPosition{current page.south}
\SetBgVshift{20pt}
\SetBgContents{\tikz[remember picture,overlay]
    \node[inner sep=0pt] {\hyperlink{totoc}{\Return}};}

\begin{document}

\tableofcontents
\section{First section}
\lipsum[4]\lipsum[4]
\lipsum[4]\lipsum[4]
\section{Second section}
\lipsum[4]\lipsum[4]
\lipsum[4]\lipsum[4]

\end{document}
Gonzalo Medina
  • 505,128
  • somehow my attempts lead to "Undefined control sequence. \backgroundsetup" and I have the package background included. Any ideas? I copied your example as the sole body of file and I got the same message. Perhaps we have different versions of some package. – Maesumi Aug 26 '13 at 18:36
  • @Maesumi you have an outdated version of the package; either update the package or use the old syntax (I'd suggest the former). In any case, I added an example to my answer using the old syntax; this should also work for you while you update the package. – Gonzalo Medina Aug 26 '13 at 20:10
  • @GonzaloMedina -- Is there any limitation on multiple SetBgContents used in the background package due to non-uniqueness of multiple positions. – Jesse Aug 27 '13 at 04:22
  • @Jesse if I correctly understand what you are asking, then no. Using multiple nodes at the desired positions, for example, you can place multiple material. – Gonzalo Medina Aug 27 '13 at 04:38