# Problem with subfig, ref and renewcommand

I have a problem with using the subfigure package and the corresponding references.

I'm wirting my thesis and I want the Figure to be named like this

\numberwithin{figure}{part}
\renewcommand{\thefigure}{\arabic{part}.\arabic{figure}}

This works fine.

If I now have a subfigure I want the Output to be like 1.1.a (Part,Figure,Subfigure) but i only get 1.a (Figure,Subfigure)

I tried to use

\numberwithin{subfigure}{part}
\renewcommand{\thesubfigure}{\arabic{part}.\arabic{figure}.\alph{subfigure
} }

But this screws up the caption of the figure. I include subfigure in the following way:

\begin{figure}[htbp]
\centering
\subfigure[][]{
\includegraphics[width=0.4\textwidth]{Picture1}
\label{fig:Picture1}}
\subfigure[][]{\vspace{2pt}
\includegraphics[width=0.5\textwidth]{Picture2.png}
\label{fig:Picture2}}
\caption[What is seen on Pic1 and 2 ]{(a)text Pic 1 (b) text Pic 2}
\end{figure}

And refer to it with \ref{fig:Picutre1}. Does anyone have an idea?

• Welcome to TeX.SX! You do not need to add your name at the bottom, better to update your details so that the display name is not the random "user....". – Andrew Swann Apr 21 '15 at 10:02
• Please include a MWE so we know which class you are using for example – Bordaigorl Apr 21 '15 at 10:02

Make sure your redefine the figure numbering before loading the subfigure package. Then you should get the output you wish.

Note that \numberwithin already changes the label format, so your \renewcommands are redundant. If you wish to change the printed representation of part in these references, then you should do this by redefining \thepart. This will make the change consistent.

\documentclass{book}

\usepackage{amsmath}
\numberwithin{figure}{part}
\usepackage{subfigure,graphicx}

\renewcommand{\thepart}{\arabic{part}}

\begin{document}

\part{A part}
\begin{figure}[htbp]
\centering
\subfigure[][]{
\includegraphics[width=0.4\textwidth]{example-image-a}
\label{fig:Picture1}}
\subfigure[][]{\vspace{2pt}
\includegraphics[width=0.5\textwidth]{example-image-b}
\label{fig:Picture2}}
\caption[What is seen on Pic1 and 2]{(a) text Pic 1 (b) text Pic 2}
\end{figure}

A reference to \ref{fig:Picture2}.
\end{document}
• Thanks a lot :) Just reordering the include commands solved the problem :) I need the renewcommand to change the style from I.1.a to 1.1.a ;) – user298811 Apr 21 '15 at 11:04
• Glad it helps. If you wish to change the style of the part numbering then you should do this consistently, redefining \thepart instead. – Andrew Swann Apr 21 '15 at 11:08