# LaTeX - Insert thumbnail with link to fullsize image contained in appendix

What is the best way to include a small thumbnail image which links to the fullsize image which should be contained in the appendix?

Ideally it would be nice to have a macro which created a thumbnail inline and also automatically added a larger image to the appendices. Does this exist?

-- Edit --

Issue with subfigure.

\begin{figure}[H]
\begin{subfigure}
\centering
\end{subfigure}%
\begin{subfigure}
\centering
\end{subfigure}
\caption{Main Tab}
\end{figure}


Packages used

\usepackage{array} %% so can bold columns in a latex table
\usepackage{float} %% used to help position images exactly where typed
\usepackage{subfigure}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage{hyperref}

-

Here's a solution that uses the hyperref package's commands

\hyperlink{<name of link>}{<text or image>}


and

 \hypertarget{<name of link>}{<text or image>}


It defines the command \thumbnailandappendix which takes one argument- the name of the image. This command

• outputs the thumbnail to the page
• saves a bigger version of the thumbnail in a vbox to be used later in the appendix
• uses a counter thumbnail to keep the hyperlinks unique

The clever bit comes from David Carlisle's answer to Write content of box to a file

\documentclass{article}
\usepackage{graphicx}
\usepackage{hyperref}
%\usepackage[left]{showlabels}
%\showlabels{hypertarget}

% set up a counter for links
\newcounter{thumbnail}

% to store the images for later
\newbox\savedimgs
\setbox\savedimgs\vbox{}

% thumbnail and appendix command
\newcommand{\thumbnailandappendix}[1]{%
% #1: name of image
\refstepcounter{thumbnail}
% input thumbnail version
% save the big version for later
\global\setbox\savedimgs\vbox{%
\unvbox\savedimgs
\bigskip
\filbreak
\noindent
\hypertarget{big\thethumbnail}{}

\includegraphics[width=10cm,height=10cm]{#1}}
}

\begin{document}

\thumbnailandappendix{Tux}

\thumbnailandappendix{babbytux}

\clearpage

\appendix

\section{Full-size image}

\unvbox\savedimgs

\end{document}


The showlabels package is especially useful during debugging.

The solution can be made to link the 'big' images back the thumbnails, however, this only makes sense if the thumbnail is used once

% thumbnail and appendix command
\newcommand{\thumbnailandappendix}[1]{%
% #1: name of image
\refstepcounter{thumbnail}
% set up hypertarget before the thumbnail
\hypertarget{small\thethumbnail}{}

% input thumbnail version
% save the big version for later
\global\setbox\savedimgs\vbox{%
\unvbox\savedimgs
\bigskip
\filbreak
\noindent
\hypertarget{big\thethumbnail}{}

}


If the thumbnail is used more than once, then the 'big' image will link back to the most recent thumbnail.

Note: the blank lines are intentional, and important in this macro.

You can use this command in the subfigure environment from the subcaption as expected; make sure to load subcaption before hyperref

\usepackage{subcaption}
\usepackage{hyperref}


and then you can use (for example)

\begin{figure}
\begin{subfigure}{.5\textwidth}
\centering
\thumbnailandappendix{Tux}
\caption{}
\end{subfigure}%
\begin{subfigure}{.5\textwidth}
\centering
\thumbnailandappendix{Tux}
\caption{}
\end{subfigure}
\end{figure}

-
Thanks so much! Just what I wanted! – bencallis Jan 9 '13 at 21:34
How would I go about linking the big image back to the small one? That would be a nice bonus. – bencallis Jan 9 '13 at 21:40
@bencallis you're welcome! see the update :) – cmhughes Jan 9 '13 at 22:00
Great! One more thing I have previously used subfigure to position two figures side by side. Unfortunately using thumbnailandappendix in place of includegraphics does not seem to work there. "Something's wrong -- perhaps a missing \item" – bencallis Jan 9 '13 at 23:29
@bencallis it works fine for me I have updated my answer with details – cmhughes Jan 10 '13 at 0:42