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}
%\showlabels{hyperlink}
% 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
\hyperlink{big\thethumbnail}{\includegraphics[width=1cm,height=1cm]{#1}}
% 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
\hyperlink{big\thethumbnail}{\includegraphics[width=1cm,height=1cm]{#1}}
% save the big version for later
\global\setbox\savedimgs\vbox{%
\unvbox\savedimgs
\bigskip
\filbreak
\noindent
\hypertarget{big\thethumbnail}{}
\hyperlink{small\thethumbnail}{\includegraphics[width=10cm,height=10cm]{#1}}}
}
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}
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 09 '13 at 23:29