24

I have 2 figures with same meaning, So I put them in subfigure package, to make it easy to show their similarity.

Here is the code that I used:

\usepackage{subfigure}


\begin{figure}[H]
 \centering
 \subfigure[]
 {
  \includegraphics[width=5.5cm, height=3.5cm]{Pattern_Images2/Result_Paper_17.eps}
   }
 \subfigure[]
 {
  \includegraphics[width=3.5cm, height=3.5cm]{Pattern_Images2/Result_Paper_24.eps}
   }

 \label{fig:Miss_Paper2417}
 \caption{Misclassification because of the distance (a)Paper \cite{Paper17} (b)Paper \cite{Paper24}}
\end{figure}

I call the pic by

Figure \ref{fig:Miss_Paper2417}

The picture appear correctly, but the problem is when I call them in my paragraph, The figure number and caption are not correct..

enter image description here

Im using WinEDT and bibtxtmng

4
  • 1
    Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Commented May 30, 2014 at 10:08
  • 9
    Always place the \label after (or within) the caption. See Why does an environment's label have to appear after the caption? Commented May 30, 2014 at 10:27
  • MWE caption and image captions are also different?
    – sandu
    Commented May 30, 2014 at 10:32
  • The subfigure package is considered deprecated. You should consider using either the subcaption package -- as is done in @sandu's answer -- to the subfig package.
    – Mico
    Commented May 31, 2014 at 5:36

2 Answers 2

29

You can use subcaption and cleveref packages...

\documentclass{scrbook}
\usepackage[demo]{graphicx}
\usepackage{subcaption}

\usepackage{cleveref}

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

\setcounter{chapter}{1}

\begin{document}

  \begin{figure}[htbp!]
    \centering
      \begin{subfigure}{0.45\textwidth}
        \includegraphics[width=\textwidth]{image1}
          \caption{Nice image1}
          \label{fig:NiceImage1}
      \end{subfigure}
      \hfill
      \begin{subfigure}{0.45\textwidth}
        \includegraphics[width=\textwidth]{image1}
          \caption{Nice image 2}
          \label{fig:NiceImage2}
      \end{subfigure}
\caption{
\label{fig:NiceImage}%
Two images}
\end{figure}

Figure \ref{fig:NiceImage}

Figure \ref{fig:NiceImage} \subref{fig:NiceImage1}

\Cref{fig:NiceImage}

\Cref{fig:NiceImage1}

\end{document}
3
  • Note that there's an extra space at the beginning of the main caption, rearrange things or add % after \label{fig:NiceImage} to fix that. Commented May 30, 2014 at 10:59
  • Modified the code based on Torbjorn comment
    – sandu
    Commented May 31, 2014 at 5:23
  • 3
    This requires switching to a package that has a different syntax. Probably a good idea but not easy with collaborators who like the old ways. Is there a quick fix solution using the subfigure package?
    – Kvothe
    Commented Mar 25, 2021 at 15:22
1
\begin{figure}[hbtp]{
\centering  
\subfigure[]{
    \includegraphics[width=0.26\paperwidth]{OMfigue-B09.4-1}
    \label{picture label 4.2.a} }
\centering
\subfigure[]{
    \includegraphics[width=0.26\paperwidth]{OMfigue-N02.4-1}
    \label{picture label 4.2.b} }
    \label{picture label 4.2}       }
\end{figure}

figure\ref{picture label 4.2},figure\ref{picture label 4.2.a}, and figure\ref{picture label 4.2.b}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .