Table of Figures
The following works by defining a new \fixedlabel
labelling scheme. \fixedlabel{<lab>}{<tag>}
fixes the label <tag>
associated with <lab>
(similar to the \tag
labelling mechanism of amsmath
).
% http://tex.stackexchange.com/questions/52189/including-table-of-figures
\documentclass{article}
\makeatletter
\def\fixedlabel#1#2{%
\@bsphack%
\protected@write\@auxout{}%
{\string\newlabel{#1}{{#2}{\thepage}}}%
\@esphack}
\makeatother
\begin{document}
\begin{table}[ht]
\centering
\begin{tabular}{c@{\quad}cc}
& a & b \\
1 & \rule[-25pt]{100pt}{50pt}\fixedlabel{block1a}{1a}
& \rule[-25pt]{100pt}{50pt}\fixedlabel{block1b}{1b} \\ \\
2 & \rule[-25pt]{100pt}{50pt}\fixedlabel{block2a}{2a}
& \rule[-25pt]{100pt}{50pt}\fixedlabel{block2b}{2b} \\ \\
3 & \rule[-25pt]{100pt}{50pt}\fixedlabel{block3a}{3a}
& \rule[-25pt]{100pt}{50pt}\fixedlabel{block3b}{3b}
\end{tabular}
\caption{This is a caption.}\label{figtab}
\end{table}
See, for example, \ref{block1a} and~\ref{block2b} in Table~\ref{figtab}.
\end{document}
A hyperref
-compatible version of \fixedlabel
is given by:
\def\fixedlabel#1#2{%
\@bsphack
\begingroup
\@onelevel@sanitize\@currentlabelname
\edef\@currentlabelname{%
\expandafter\strip@period\@currentlabelname\relax.\relax\@@@%
}%
\phantomsection%
\protected@write\@auxout{}{%
\string\newlabel{#1}{%
{#2}%
{\thepage}%
{#2}%
{\@currentHref}{}%
}%
}%
\endgroup
\@esphack
}
Here's one possible solution using the tabu package:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{tabu}
\usepackage{caption,subcaption}
\newcounter{tmp}
% \MyIm{<figure name>}{<label>}
\newcommand\MyIm[2]{%
\captionof*{subfigure}{}
\includegraphics[width=4cm,height=2cm]{#1}
\captionof{subfigure}{}\label{#2}%
}
\begin{document}
\begin{center}
\setcounter{tmp}{\thefigure}
\captionsetup[subfigure]{labelformat=empty}
\begin{tabu}{>{\refstepcounter{figure}\thefigure\setcounter{subfigure}{0}}l%
X[c,m]X[c,m]}
\multicolumn{1}{l}{\setcounter{figure}{0}} & a & b \\[-20pt]
& \MyIm{name1}{a} & \MyIm{name2}{b} \\[-30pt]
& \MyIm{name3}{c} & \MyIm{name4}{d} \\[-30pt]
& \MyIm{name5}{e} & \MyIm{name6}{f}
\end{tabu}\setcounter{figure}{\thetmp}
\end{center}
\ref{a} \ref{b} \ref{c} \ref{d} \ref{e} \ref{f}
\end{document}
Some remarks:
A
tmp
counter was used to store the value of the counterfigure
before the table and then, at the end the value forfigure
was restoredThe subcaption package was used to provide an empty caption for each figure; this allows the easy assignment of a
\label
for cross-referencing.This solution cooperates with
hyperref
; the only thing to do is to loadhyperref
andhypcap
:\usepackage{hyperref} \usepackage{hypcap}