[Tex/LaTex] How to reference to subfigure in latex

cross-referencingsubfloats

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

Best Answer

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}