[Tex/LaTex] How to insert an image that also acts as a link

graphicshyperref

Can an image be included in TeX so that the resulting PDF is clickable leading to a reference?

Best Answer

Just wrap the image in \href [1]

\documentclass{article}

\usepackage{hyperref}
\usepackage[demo]{graphicx}

\begin{document}
\href{http://www.google.de}{\includegraphics{image}}% [1]

\begin{figure}%[2]
    \centering
    \href{http://www.google.de}{\includegraphics{image}}
    \caption{Non linked caption.}
\end{figure}

%\begin{figure}%[3]
%   \centering
%   \href{http://www.google.de}{%
%       \includegraphics{image}
%       \caption{Linked captions won’t work.}
%   }
%\end{figure}

\begin{figure}%[4]
    \centering
    \href{http://www.google.de}{\includegraphics{image}}
    \caption{\href{http://www.google.de}{Workaround for linked captions}}
\end{figure}

\begin{figure}%[5]
    \href{http://www.google.de}{%
        \parbox{\textwidth}{
            \centering
            \includegraphics{image}
            \caption{Linked captions won’t work.}
        }
    }
\end{figure}

\begin{figure}%[6]
    \centering
    \href{http://www.google.de}{%
        \scalebox{0.5}{
            \parbox{\textwidth}{
                \centering
                \textbf{A Title}\\
                \includegraphics{image}}
        }
    }
\end{figure}

\end{document}

To add a caption just use the {figure} environment as usual and put in the linked graphic [2]: Wrapping the caption in \href too causes an error, since the out will contain paragraphs that can’t be part of a link [3], so you’ll have to link the caption too [4] or you must put the whole {figure} content in a \parbox, which can be linked [5]. [6] shows hoe to add a title (not caption) and scale text an image with \scalebox.

Related Question