Latex nubering of subfigures

1. May 5, 2009

ryan88

Hi,

In my report, I want figures to be numbered within sections, so I put the following in the preamble of my document:
Code (Text):
\numberwithin{figure}{section}
This works great, except for when I am referencing subfigures. I have the following code:
Code (Text):
\begin{figure}[h]
\centering
\subfigure[$f(x)$]{
\includegraphics[width=0.4\textwidth]{figures/fx}
\label{fig:fx}
}
\subfigure[$\Phi_{50}(x,y)$]{
\includegraphics[width=0.4\textwidth]{figures/phi_comp}
\label{fig:phi_comp}
}
\caption{$\Phi_{N}(x,y)$ for $N=1,20,50$}
\label{fig:fx_phi_comp}
\end{figure}
Figure \ref{fig:fx} shows that ...
This produces something like "Figure 2(a) shows that ..." instead of "Figure 4.2(a) shows that ...". I have worked around this by doing the following:
Code (Text):
Figure \ref{sec:comparison}.\ref{fig:fx} shows that ...
Where sec:comparison is the label I have applied to the appropriate section.

Is this the only way around this? Or am I doing something wrong?

Thanks,

Ryan

2. May 5, 2009

matt grime

What does altering the subfigure counter do? Something like

Code (Text):
\numberwithin{subfigure}{section}

I've never used that numberwithin command, instead I would have defined the figure counter afresh with a \newcounter declaration for subfigures (please don't ask me to work out what it should be on the fly - I googled it and found at least 3 different suggestions for syntax, none of which I can verify as working).