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

sandu
  • 7,950
user52695
  • 353

2 Answers2

28

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}
sandu
  • 7,950
  • 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. – Torbjørn T. May 30 '14 at 10:59
  • Modified the code based on Torbjorn comment – sandu May 31 '14 at 05: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? – Marten Mar 25 '21 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}