# Is there a way to divide ONE figure to reference the subparts of the figure?

I have a figure that basically consists of smaller figures. I don't want to split the big image apart to put it together with latex for convenience. Instead, I want to reference each subpart of the large image with cleverref. I am going to put a node in each picture with tikz naming each subimage (a),(b), ... How can I reference this subimage using cleverref so that the reference looks like this: Figure 1.1a The whole reference should be hyperlinked to the image.

I am already using the following important packages:

\usepackage{caption}
\usepackage{subcaption}
\captionsetup[subfigure]{subrefformat=simple,labelformat=simple}
\renewcommand\thesubfigure{\alph{subfigure}}


and my cleverref options are:

%reference packages
\crefdefaultlabelformat{#2#1#3}
%options for equations
\creflabelformat{equation}{#2#1#3}
\crefformat{equation}{#2Eq.~#1#3}
\Crefformat{equation}{#2Equation~#1#3}
\crefmultiformat{equation}{#2Eqs.~#1#3}%
{ and~#2#1#3}{, #2#1#3}{ and~#2#1#3}
%options for enumerations
\creflabelformat{enumi}{#2(#1)#3}
\crefformat{enumi}{#2(#1)#3}
\Crefformat{enumi}{#2(#1)#3}
%options for figures
\creflabelformat{figure}{#2#1#3}
\crefformat{figure}{#2Fig.~#1#3}
\Crefformat{figure}{#2Figure~#1#3}
\crefmultiformat{figure}{#2Fiqs.~#1#3}%
{ and~#2#1#3}{, #2#1#3}{ and~#2#1#3}

• Not much of an answer, so I'll add it as comment: You could add \phantomsubcaptions and appropriate \labels you can refer to later anywhere inside the figure's code. Jul 17, 2015 at 15:27
• This does not seem to work. If I add \phantomsubcaptions the figure number also goes up, leading to wrong figure numbers in the following figures. Also, only adding additional \label{fig: 1_a}s does not work, as a reference to them via \cref{fig: 1_a} reads "section 1.1" and not "fig 1a".
– Alex
Jul 17, 2015 at 16:44

I'd go with clipping the image and include it four times (this will have no impact on the final PDF size, because the resource will be loaded just once). With \clipbox* of the trimclip package you don't even need to know the image size.

\documentclass{article}

\usepackage{subcaption,graphicx,trimclip,hyperref,cleveref}

\begin{document}

\begin{figure}
\centering

\subcaptionbox{Top left\label{tl}}{%
\clipbox*{0 {.5\height} {.5\width} {1\height}}{%
\includegraphics[width=8cm]{duck}%
}%
\subcaptionbox{Top right\label{tr}}{%
\clipbox*{{.5\width} {.5\height} {1\width} {1\height}}{%
\includegraphics[width=8cm]{duck}%
}%
}

\medskip

\subcaptionbox{Bottom left\label{bl}}{%
\clipbox*{0 0 {.5\width} {.5\height}}{%
\includegraphics[width=8cm]{duck}%
}%
\subcaptionbox{Bottom right\label{br}}{%
\clipbox*{{.5\width} 0 {1\width} {.5\height}}{%
\includegraphics[width=8cm]{duck}%
}%
}

\caption{A split duck}

\end{figure}

\end{document}


A fuller example showing that the references are as expected.

\documentclass{article}

\usepackage{subcaption,graphicx,trimclip}

\captionsetup[subfigure]{subrefformat=simple,labelformat=simple}
\renewcommand\thesubfigure{\alph{subfigure}}

\crefdefaultlabelformat{#2#1#3}
%options for equations
\creflabelformat{equation}{#2#1#3}
\crefformat{equation}{#2Eq.~#1#3}
\Crefformat{equation}{#2Equation~#1#3}
\crefmultiformat{equation}{#2Eqs.~#1#3}%
{ and~#2#1#3}{, #2#1#3}{ and~#2#1#3}
%options for enumerations
\creflabelformat{enumi}{#2(#1)#3}
\crefformat{enumi}{#2(#1)#3}
\Crefformat{enumi}{#2(#1)#3}
%options for figures
\creflabelformat{figure}{#2#1#3}
\crefformat{figure}{#2Fig.~#1#3}
\Crefformat{figure}{#2Figure~#1#3}
\crefmultiformat{figure}{#2Fiqs.~#1#3}%
{ and~#2#1#3}{, #2#1#3}{ and~#2#1#3}

\begin{document}

A reference to \cref{global}, then to
\cref{tl}, \cref{tr}, \cref{bl} and \cref{br}.

\begin{figure}[htp]
\centering

\subcaptionbox{\label{tl}}{%
\clipbox*{0 {.5\height} {.5\width} {1\height}}{%
\includegraphics[width=8cm]{duck}%
}%
\subcaptionbox{\label{tr}}{%
\clipbox*{{.5\width} {.5\height} {1\width} {1\height}}{%
\includegraphics[width=8cm]{duck}%
}%
}

\medskip

\subcaptionbox{\label{bl}}{%
\clipbox*{0 0 {.5\width} {.5\height}}{%
\includegraphics[width=8cm]{duck}%
}%
\subcaptionbox{\label{br}}{%
\clipbox*{{.5\width} 0 {1\width} {.5\height}}{%
\includegraphics[width=8cm]{duck}%
}%
}

\caption{A split duck}\label{global}

\end{figure}

\end{document}


The following code will create links also without clipping the figure; add

\newcommand{\labelphantom}[1]{%
\parbox{0pt}{\phantomsubcaption\label{#1}}%
}


in your preamble and then type

A reference to \cref{global2}, then to
\cref{tl2}, \cref{tr2}, \cref{bl2} and \cref{br2}.

\begin{figure}[htp]
\centering

\labelphantom{tl2}%
\labelphantom{tr2}%
\labelphantom{bl2}%
\labelphantom{br2}%
\includegraphics[width=8cm]{duck}%

\caption{A split duck}\label{global2}

\end{figure}


• Of course, this is an option if I explicitly want subcaptions under each image. But I actually don't want it, so it is a bit of an overkill to use trimclip and later on use phantomcaptions to avoid subcaptions. Is it possible to use more than one label/phantomcaption for an image?
– Alex
Jul 17, 2015 at 16:04
• If you want to see (a), (b) and so on, where's the problem? Jul 17, 2015 at 16:10
• The problem is that the number of figures don't match anymore. When I add some phantomcaptions, the next image has a wrong figure number. LateX skips 4 numbers then.
– Alex
Jul 17, 2015 at 16:12
• I need to do that for about 15 images and they are not always so well seperatable into 4 equally sized pieces. So I don't really want to trim each of them. I just want to be able to reference the same image 4 tiimes with different results. So \cref{fig: fig_1a} should give: Fig. 1a and \cref{fig: fig_1b should give: Fig. 1b.
– Alex
Jul 17, 2015 at 16:34
• the \labelphantom is acutally doing what I want!!! Thx a lot. Nice and easy!
– Alex
Jul 17, 2015 at 16:59