4

Is is possible to make clicking on separate parts of an image link to different sections of the document.

for instance specify a region of a image (x, y, width height) and a hyperref.

(I am aware you can make clicking anywhere in an image link to a single section, but this is not what I need)

(I have seen Link subsections of image to different labels (like html image map) and Possibility to ref link different areas of an image to different labels? but couldn't see how to use what they had said)

Thanks

EDIT: What I have tried which handles a single link.

\documentclass{article}
\usepackage{graphicx}
\usepackage{hyperref}

\begin{document}

\begin{figure}
    \centering
    \hyperref[xxx]{\includegraphics[width=\linewidth]{image.png}}
\end{figure}

\pagebreak
\section{Section 1}

Some Text

\pagebreak
\section{Section 2}
\label{xxx}

Some Text

\end{document}
  • Welcome to TeX - LaTeX! Can you post what you have tried so far. – Andrew Swann Mar 29 '17 at 10:30
  • So far I have only managed to make the whole image act like one big link, which I don't think is the right direction. – Andy T Mar 29 '17 at 10:32
  • Without seeing what you have attempted, how can we say what is applicable or not? You already link to two different approaches. – Andrew Swann Mar 29 '17 at 10:36
3

REVISED APPROACH (\stackinset)

Here, I just \stackinset any number of \hyperrefed \makeboxes to encompass the desired portion of the base image. The \stackinset can be specified relative to the l,c,r horizontal anchors and the t,c,b vertical anchors.

\documentclass{article}
\usepackage{graphicx}
\usepackage{hyperref,stackengine}
\begin{document}

\begin{figure}
    \centering
    \stackinset{l}{10pt}{t}{20pt}{\hyperref[topleft]{\makebox(100,100){}}}{%
    \stackinset{r}{30pt}{t}{40pt}{\hyperref[topright]{\makebox(50,40){}}}{%
    \stackinset{l}{40pt}{b}{50pt}{\hyperref[bottomleft]{\makebox(70,20){}}}{%
    \stackinset{r}{110pt}{b}{70pt}{\hyperref[bottomright]{\makebox(40,80){}}}{%
    \includegraphics[width=\linewidth]{example-image}}}}}
\end{figure}

\clearpage

\pagebreak
\section{Section 1}
\label{topleft}

Some Text

\pagebreak
\section{Section 2}
\label{topright}

Some Text

\pagebreak
\section{Section 3}
\label{bottomleft}

Some Text

\pagebreak
\section{Section 4}
\label{bottomright}

Some Text

\end{document}

enter image description here

ORIGINAL APPROACH (\clipbox)

Here I use \clipbox to partition the figure into 4 [unequal-sized] quadrants, though there is, in theory, no reason you can't slice it into any number of rectangles.

I don't know how, but I am sure hyperref provides the means to make the \hyperref bounding box invisible.

\documentclass{article}
\usepackage{graphicx}
\usepackage{hyperref,trimclip,stackengine}
\begin{document}

\begin{figure}
    \centering
    \setbox0=\hbox{\includegraphics[width=\linewidth]{example-image}}
    \stackunder[0pt]{%
    \hyperref[topleft]{\clipbox{0pt .4\ht0{} .3\wd0{} 0pt}{\copy0}}%
    \hyperref[topright]{\clipbox{.7\wd0{} .4\ht0{} 0pt 0pt}{\copy0}}}{%
    \hyperref[bottomleft]{\clipbox{0pt 0pt .3\wd0{} .6\ht0}{\copy0}}%
    \hyperref[bottomright]{\clipbox{.7\wd0{} 0pt 0pt .6\ht0}{\copy0}}}
\end{figure}

\clearpage

\pagebreak
\section{Section 1}
\label{topleft}

Some Text

\pagebreak
\section{Section 2}
\label{topright}

Some Text

\pagebreak
\section{Section 3}
\label{bottomleft}

Some Text

\pagebreak
\section{Section 4}
\label{bottomright}

Some Text

\end{document}

A click in separate corners of the image will take you to different pages in the document.

enter image description here

3

You can use, e.g., overpic:

\documentclass{article}
\usepackage{graphicx}
\usepackage{overpic,picture}
\usepackage{hyperref}

\begin{document}

\begin{figure}
    \begin{overpic}[%grid,% use this if you need help in finding coordinates
      width=\linewidth]{example-image}
      \put(0,0){\hyperref[sec:first]{\makebox(50,75)[lb]{}}}%
      \put(50,0){\hyperref[sec:last]{\makebox(50,75)[lb]{}}}%
    \end{overpic}
    \caption{Example of link areas}
\end{figure}

\pagebreak
\section{Section 1}
\label{sec:first}
Some Text

\pagebreak
\section{Section 2}
\label{sec:last}

Some Text

\end{document}

enter image description here

The two red frames are the two link areas. If you do not want such frames, use, e.g., hyperref's option pdfborder:

\documentclass{article}
\usepackage{graphicx}
\usepackage{overpic,picture}
\usepackage{hyperref}

\begin{document}

\begin{figure}
    \hypersetup{pdfborder=0 0 0}% No borders around the hyperlink areas
    \begin{overpic}[%grid,% use this if you need help in finding coordinates
      width=\linewidth]{example-image}
      \put(0,0){\hyperref[sec:first]{\makebox(50,75)[lb]{}}}%
      \put(50,0){\hyperref[sec:last]{\makebox(50,75)[lb]{}}}%
    \end{overpic}
    \caption{Example of link areas}
\end{figure}

\pagebreak
\section{Section 1}
\label{sec:first}
Some Text

\pagebreak
\section{Section 2}
\label{sec:last}

Some Text

\end{document}

The border will not be shown:

enter image description here

Nevertheless, the areas are still there.

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.