# How to reference the whole figure with subfig?

I'm using the subfig package in the following way:

Samples of our recordings are shown in the Figure XXXXX.
\begin{figure}
\centering
\subfloat[One']{\includegraphics[width=8cm]{One.eps} \label{fig:One}}\qquad
\subfloat[Two']{\includegraphics[width=8cm]{Two.eps} \label{fig:Two}}\\
\subfloat[Three']{\includegraphics[width=8cm]{Three.eps} \label{fig:Three}}\\
\parbox{15cm}{\vspace{0.4cm}
\caption{The caption goes here.}}
\end{figure}


I'd like to have the XXXXX replaced with something like \ref{fig:TheWholeFigure}, so that I can refer to the whole figure, e.g. "Figure 3" (and not each part e.g. "Figure 3b").

How could I achieve this?

• What's the purpose of the \parbox? – egreg Dec 15 '13 at 16:22
• I use it to customise the total width of the caption. Basically I want my caption width to be different from the main body (surrounding paragraphs etc.) width, so that it is nicer on the eye. 15cm goes well with A4 and the margin sizes that I use. – User 17670 Dec 15 '13 at 16:35
• For that purpose it's better to use the caption package. – egreg Dec 15 '13 at 16:36
• @egreg Thanks for the suggestion. (So that we have something written here on this webpage) Could you summarise in a sentence or two why it is 'better'? I guess this is related to the anti-logic below. – User 17670 Dec 15 '13 at 16:47

• It is just that \label refers to the last command called before it that changed a counter (either a section, a figure, a table and so on...). In your example your labels referred to the subfloat commands and thus to the subfigures. By adding a \label after (or inside) the \caption for the whole figure it will allow you to get a link to this whole figure and not to all the subfigures. – Ludovic C. Dec 15 '13 at 16:08
• It works inside the \parbox after the \caption command. But you should not be using a \parbox anyway. Just write \caption{...}\label{...}. If you need to adjust vertical spacing you can write the previous double backslash as \\[0.4cm]`. – Andrew Swann Dec 15 '13 at 17:35