54

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

4 Answers 4

61

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.

2
  • Nice update, but I have the feeling the OP talks about some sub-title below the image, not a real \caption. But I could be wrong of course. Commented May 8, 2012 at 13:44
  • @MartinScharrer: We all can only guess what the OP want’s, but likely you’re right :-) I added this a possible code for this …
    – Tobi
    Commented May 8, 2012 at 13:45
20

Of course:

\documentclass{article}
\usepackage[demo]{graphicx}% demo option just for the example
\usepackage{hyperref}

\begin{document}

\href{http://www.tex.stackexchange.com}{\includegraphics{name}}

\end{document}
2
  • 1
    I use \href{https://gitlab.com/u/SomeName}{\includegraphics[width=0.31cm,height=0.31cm,keepaspectratio]{figures/gitlab_greyscale}}, but it does not work. Compiling a memoir based document with XeLaTeX. Are there any restrictions (wrt XeLaTeX)? Commented Oct 10, 2015 at 19:50
  • 1
    I found "my" answer here: tex.stackexchange.com/a/85103/8272 Commented Oct 10, 2015 at 20:12
13

Sure.

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

\href{http://www.dante.de}{\includegraphics[width=5cm]{tiger}}
\end{document}
5
  • Does the syntax allow for a title or caption, and would it scale with the picture? How would you give the coordinates for the picture?
    – Maesumi
    Commented May 8, 2012 at 13:23
  • You shouldn't put a float like figure in the argument. But I don't see any reason why boxes like \parbox or tabular with various content shouldn't work. If you want to scale a text, use \resizebox from the graphics package. Commented May 8, 2012 at 13:40
  • 1
    @Maesumi: You should always state such requirements with your question. Are you talking about a normal LaTeX figure numbered caption or just some text above or below? Commented May 8, 2012 at 13:41
  • @Maesumi: I added some possible ways to my answer whowing how to add a caption an link it.
    – Tobi
    Commented May 8, 2012 at 13:43
  • With thanks to Tobi, Gonzola, Ulrike, Martin. I want a regular picture (not LaTeX generated) with some text that will be either above or below it. It does not have to be a formal caption or title for the picture, just so long as it centers with the picture.
    – Maesumi
    Commented May 8, 2012 at 19:37
0

I used a single command with orcid logo picture downloaded from google:

\href{https://orcid.org/0000-0001-9743-2851
}{\includegraphics[width=0.15in,height=0.15in]{orcid.jpg}}

Following is the picture I used

enter image description here

1
  • 2
    Welcome to TSE. This question was posted seven yers ago and your answer adds nothing to the already existing answers. Commented Nov 9, 2019 at 15:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .