The subcaption package provides three ways to build your subfigures:
1) Using the \subcaption command inside, for example, minipages; the syntax:
\subcaption[<list entry>]{<document caption>}
2) Using the subfigure environment.
3) Using the \subcaptionbox command. The syntax:
\subcaptionbox[<list entry>]{<document caption>}[<width>][<inner-pos>]{<contents>}
where <width> is the width of the resulting \parbox; the default value is the width of the contents. <inner-pos> specifies how the contents will be justified inside the resulting \parbox; it can be either c (for \centering), l (for \raggedright), r (for \raggedleft), or s (for no
special justification). The default is c.
Here's a little example, illustrating the three approaches, and the use of \ref and \subref to cross-reference the (sub)figures:
\documentclass{article}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\begin{minipage}[b]{.5\linewidth}
\centering
\rule{3cm}{1cm}% to simulate a figure
\subcaption{Test subfigure one}
\label{fig:sub11}
\end{minipage}%
\begin{minipage}[b]{.5\linewidth}
\centering
\rule{3cm}{1cm}% to simulate a figure
\subcaption{Test subfigure one}
\label{fig:sub12}
\end{minipage}
\caption{A figure with two subfigures}
\label{fig:testfig1}
\end{figure}
\begin{figure}
\begin{subfigure}[b]{.5\linewidth}
\centering
\rule{3cm}{1cm}% to simulate a figure
\subcaption{Test subfigure one}
\label{fig:sub21}
\end{subfigure}%
\begin{subfigure}[b]{.5\linewidth}
\centering
\rule{3cm}{1cm}% to simulate a figure
\subcaption{Test subfigure one}
\label{fig:sub22}
\end{subfigure}
\caption{Another figure with two subfigures}
\label{fig:testfig2}
\end{figure}
\begin{figure}
\centering
\subcaptionbox{Test subfigure one\label{fig:sub31}}[4cm]{\rule{3cm}{1cm}}%
\subcaptionbox{Test subfigure two\label{fig:sub32}}[4cm]{\rule{3cm}{1cm}}
\caption{Another figure with two subfigures}
\label{fig:testfig3}
\end{figure}
As we can see in Figure~\ref{fig:sub22}...
Subfigure~\subref{fig:sub32} of Figure~\ref{fig:testfig3} shows...
\end{document}

In the body the subfigure file is called a, b and so on.
While I am in the body I refer to the full figure as
– gontadu Oct 24 '11 at 08:16\ref{whole}and then refer to the subfigures like\ref{a}and\ref{b}