32

I'm including \usepackage{hyperref} so that each instance of \ref (as well as each page number in the index and the table of contents) automatically links to that page.

When I'm viewing the document (in Sumatra) and I click a link, I jump to the linked page. Is there any easy way to go "back" to where I was before I clicked the link? (And is the answer any different when using Adobe Acrobat reader?)

33

Actually this has nothing to do with TeX …

There’s no default, so one needs to check the viewer’s menus and shortcuts, because each application can use its own method. However, on MS Windows the keys are the same for Adobe Reader, SumatraPDF and PDF XChange Viewer (and probably some others which I can’t test now): Alt plus left cursor key for “Go back to last view” and Alt plus right cursor key for “Go to next view”. The latter is only active, when the former at least once was used. Despite the same key association the different readers behave not exactly the same. Enrico Gregorio (egreg) reported, that on Mac OS X it's Cmd + [ and Cmd + ] (except for Adobe Reader).

  • 1
    Of course, this depends on the operating system and, possibly, on the language (at least on Mac OS X). – egreg Apr 9 '12 at 21:04
  • 1
    Something about: "one needs to check the viewer's menus and shortcuts because each application can use its own method". For example on Mac OS X it's Command+[ and Command+] (except for Adobe Reader). – egreg Apr 9 '12 at 21:33
  • Thank you, I was just looking for this! Really helpful, especially when you read something 1300-1400 pages long (like C++ language standard drafts) and at some place have multiple hyperlinks to places spread over the whole document. – Kusavil Mar 13 '18 at 12:09
9

The PDF format also knows link annotations with named actions, which calls functions of the PDF viewer. The official list of these named actions in the PDF specification for version 1.7 (ISO standard version) is quite short:

  • NextPage, PrevPage
  • FirstPage, LastPage

However, the list supported by AcrobatReader is much longer. Section "5 Acrobat-specific behavior" of the hyperref manual lists some more named actions, among them:

  • GoBack, GoForward

The GoBack action is of interest here. With macro

\Acrobatmenu{<action name>}{<free text>}

a link for going back can be set, for example:

\documentclass[a5paper]{article}
\usepackage[colorlinks]{hyperref}
\usepackage{lipsum}
\usepackage[variablett]{lmodern}

\newcommand*{\Button}[1]{%
  \Acrobatmenu{#1}{\fbox{\texttt{#1}}}%
}
\newcommand*{\Navigation}{%
  \begin{center}
    \Button{FirstPage}\qquad
    \Button{LastPage}\\
    \Button{PrevPage}\qquad
    \Button{NextPage}\\ 
    \Button{GoBack}\qquad
    \Button{GoForward}
  \end{center}%
}

\begin{document}
  \tableofcontents
  \Navigation
  \section{Document start}
  \lipsum[1-3]
  \Navigation
  \section{Last section}
  \lipsum[4]
  \Navigation
\end{document}

Of course, it depends on the PDF viewer, whether actions and which actions are aupported. AR should work, xpdf 3.03 knows the actions of the test file above. Evince 3.4.0 only knows the actions from the PDF specification, but not GoBack or GoForward.

3

To expand on what others said: This back functionality has nothing to do with TeX because you wouldn't encode the back link (from the link destination back to the link source) in the PDF document itself. Rather, the functionality is built into the PDF viewer; when you click a link, taking you to a different page in the PDF document, the PDF viewer remembers where you were and can take you back if you press the right 'back' button. As egreg pointed out, it's common to have many links to the same place so it wouldn't be clear where the back links should point.

Wikipedia is somewhat of an exception in that some link destinations (such as Note #2 here) have a list of all the link sources in the entire document. For Wikipedia, they are labeled with lowercase letters ('a', 'b', ...), and you can just click them one-by-one to see ever place in the main text that references a particular note. I don't know if PDFs support this functionality or, if they do, whether you can create such a PDF with TeX .

3

For the evince PDF viewer it is not so easy to find how to add this functionality. A solution involving the "back" button can be found here.

I had to add the icon for "back" (which is a left arrow) to the toolbar as described above. Note that "back" means "previous viewed page" and not "previous page" which is denoted by the up-arrow icon.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.