Can an image be included in TeX so that the resulting PDF is clickable leading to a reference?
Asked
Active
Viewed 4.9k times
4 Answers
59
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.
David Carlisle
- 757,742
Tobi
- 56,353
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}
Gonzalo Medina
- 505,128
-
1I 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)? – Nikos Alexandris Oct 10 '15 at 19:50 -
1I found "my" answer here: http://tex.stackexchange.com/a/85103/8272 – Nikos Alexandris Oct 10 '15 at 20:12
13
Sure.
\documentclass{article}
\usepackage{hyperref,graphicx}
\begin{document}
\href{http://www.dante.de}{\includegraphics[width=5cm]{tiger}}
\end{document}
Ulrike Fischer
- 327,261
-
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 May 08 '12 at 13:23
-
You shouldn't put a float like figure in the argument. But I don't see any reason why boxes like
\parboxortabularwith various content shouldn't work. If you want to scale a text, use\resizeboxfrom the graphics package. – Ulrike Fischer May 08 '12 at 13:40 -
1@Maesumi: You should always state such requirements with your question. Are you talking about a normal LaTeX
figurenumbered caption or just some text above or below? – Martin Scharrer May 08 '12 at 13:41 -
@Maesumi: I added some possible ways to my answer whowing how to add a caption an link it. – Tobi May 08 '12 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 May 08 '12 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
-
2Welcome to TSE. This question was posted seven yers ago and your answer adds nothing to the already existing answers. – José Carlos Santos Nov 09 '19 at 15:22

\caption. But I could be wrong of course. – Martin Scharrer May 08 '12 at 13:44