2

I am using hyperref to link my figure call-outs in the text to the actual figures. The figure call-outs are colored blue to make it obvious that they are hyperlinks. I would like to use \Acrobatmenu to provide readers with a similar clickable link in the Figure title to return them easily to their previous location in the document. (I am aware that one can use command + left arrow to perform this task in Adobe reader, but I would like to provide the reader with an obvious signpost to make this task straightforward for them.)

My attempt at a solution defines a new command for the \Acrobatmenu and nests this entity inside \renewcommand{\thefigure}, thus:


\documentclass[10pt]{article}

\usepackage{lipsum} 

\usepackage{mwe}

\DeclareRobustCommand{\Acrobat}[2][GoBack]{%
  \Acrobatmenu{#1}{#2}}


\renewcommand{\thefigure}{S\Acrobat[GoBack]{\textcolor{blue}{\arabic{figure}}}}


% use command left arrow to return to exact reference in Adobe Reader
% or use return buttons above
\usepackage{hyperref} 
\hypersetup{
     colorlinks=true,
    %hidelinks=true, 
    linkcolor=blue,
    citecolor=blue,
    filecolor=magenta,      
    urlcolor=blue,
}

\usepackage[all]{hypcap}





\begin{document}

Here is a fascinating figure (\textbf{\hyperref[fig:one]{Figure~\ref{fig:one}}}).

\lipsum[1-4]


\begin{figure}[!htbp]
    \includegraphics[width = 0.2\textwidth]{example-image-a}
      \caption{
       \label{fig:one}
       \textbf{One of the more scintillating figures.} Surely an interesting figure.
       }
\end{figure}



\end{document}


The document image is:

enter image description here

When I click on Figure S in the phrase Figure S1 in the Figure call-out in the text, I am taken to the Figure. But not when I click on the actual figure number 1. It appears that my code somehow interferes with \ref. However, when I click on the 1 in the phrase Figure S1 in the figure title, I am returned to the correct place in the text. (I have code such that clicking on Figure S in Figure S1 in the figure title returns the reader, but have not shown this code for brevity's sake).

P.S. Added embarassingly later. My question is: Can my code be fixed such that clicking on '1' in the phrase Figure S1 in the text takes the reader to the figure, while maintaining the property that clicking on '1' in the phrase Figure S1 in actual figure legend returns the reader to their previous location in the text.

Many thanks!

Bob
  • 263
  • Related: https://tex.stackexchange.com/questions/14981/usage-of-table-figures-shown-in-caption. Note that the proposed solution there works in all viewers, while \Acrobatmenu works only in Adobe viewers. – Marijn Nov 01 '19 at 07:43
  • I had missed that, nice solution @Marijn, thanks very much. Although that solution has the big advantage of working in all viewers, it requires the reader to remember which page they were looking at before jumping to the table or figure. For that reason, I prefer \Acrobatmenu despite its being limited to only one viewer. – Bob Nov 01 '19 at 18:50
  • @Bob: I think the issue is that during the running text, the label S1 is also generated using \thefigure, hence your interference. Instead of changing \thefigure, it may be better to change \caption itself, maybe by abusing something like the caption package. – Willie Wong Nov 18 '19 at 20:52
  • Thanks very much, @WillieWong! The 'caption' package looks very worthwhile, I will give it a careful gander. – Bob Nov 18 '19 at 23:12

0 Answers0