Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
add comment

3 Answers

up vote 22 down vote accepted

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.

share|improve this answer
    
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. –  Martin Scharrer May 8 '12 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 May 8 '12 at 13:45
add comment

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}
share|improve this answer
add comment

Sure.

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

\href{http://www.dante.de}{\includegraphics[width=5cm]{tiger}}
\end{document}
share|improve this answer
    
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 8 '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 \parbox or tabular with various content shouldn't work. If you want to scale a text, use \resizebox from the graphics package. –  Ulrike Fischer May 8 '12 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? –  Martin Scharrer May 8 '12 at 13:41
    
@Maesumi: I added some possible ways to my answer whowing how to add a caption an link it. –  Tobi May 8 '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 8 '12 at 19:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.