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

Samples of our recordings are shown in the Figure XXXXX. 
\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}}\\
\caption{The caption goes here.}}

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

Just found a solution:

Stick the label for the whole figure inside the caption environment.

It doesn't seem to work anywhere else. E.g. it can't be after the caption, inside the parbox, or after the parbox, inside the figure environment. I'm not sure about the logic behind this.

  • 1
    Not inside the caption but put a label for the figure environment is the logic. – percusse Dec 15 '13 at 15:56
  • 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
  • @percusse Please see my edit. – User 17670 Dec 15 '13 at 16:46
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.