[Tex/LaTex] How to name subfigures in different figures independently

subfloats

I have a problem with subfigure. I want to put some figures at different places in the section. I want to have them in pairs, so I use subfigure. But, instead of labels (a) and (b) in the Figure 1, and labels (a) and (b) in the Figure 2, I have (a) and (b) in Figure 1 and (c) and (d) in Figure 2. And it is like this in whole section. So in the end of the section, I have a pair of pictures, which I have to refer at as Figure 3(e) and 3(f). Instead of that, I would like to have each pair of pictures be named as (a) and (b). So I would have Fig. 1(a) and 1(b), Fig. 2(a) and 2(b), and so on. Do anyone know what to do with it? Thanks.

     \documentclass[12pt,a4paper]{article} 
        \usepackage[english]{babel} 
        \usepackage{graphicx} 
        \usepackage{caption}
        \usepackage{subcaption}
        \usepackage{color} 
        \usepackage{float}

        \begin{document}

        \begin{figure}[H] 
        \begin{subfigure}{.9\textwidth}
          \centering
          \includegraphics[width=.5\linewidth]{1.pdf}
          \caption{$H \rightarrow b\overline{b}$}
         \end{subfigure}
        \begin{subfigure}{.9\textwidth}
          \centering
          \includegraphics[width=.5\linewidth]{2.pdf} 
      \caption{$H \rightarrow \gamma \gamma$} 
     \end{subfigure} 
     \caption{mmmm}
    \end{figure}

text text text 

 \begin{figure}[H] 
        \begin{subfigure}{.9\textwidth}
          \centering
          \includegraphics[width=.5\linewidth]{1.pdf}
          \caption{$H \rightarrow b\overline{b}$}
         \end{subfigure}
        \begin{subfigure}{.9\textwidth}
          \centering
          \includegraphics[width=.5\linewidth]{2.pdf} 
      \caption{$H \rightarrow \gamma \gamma$} 
     \end{subfigure} 
     \caption{mmmm}
    \end{figure}

    \end{document}

Best Answer

By using the subcaption package:

\documentclass{article}

\usepackage{graphicx}
\usepackage{subcaption}


\begin{document}

\begin{figure}
    \begin{subfigure}[b]{.5\linewidth}
        \centering
            \includegraphics[scale=1]{PictureFile1}
            \caption{Subfigure A}
        \label{fig:labelfigure1A}
    \end{subfigure}
    \begin{subfigure}[b]{.5\linewidth}
        \centering
            \includegraphics[scale=1]{PictureFile2}
            \caption{Subfigure B}
        \label{fig:labelfigure1B}
    \end{subfigure}
    \caption{Caption of Figure 1}
    \label{fig:labelfigure1}
\end{figure}

If you want to reference the subfigure A (Figure~\ref{fig:labelfigure1A}), if you want the second (Figure~\ref{fig:labelfigure1B}).  If you want to reference both (Figure~\ref{fig:labelfigure1}


For a new figure, simple add it:

\begin{figure}
    \begin{subfigure}[b]{.5\linewidth}
        \centering
            \includegraphics[scale=1]{PictureFile3}
            \caption{Subfigure A}
        \label{fig:labelfigure2A}
    \end{subfigure}
    \begin{subfigure}[b]{.5\linewidth}
        \centering
            \includegraphics[scale=1]{PictureFile4}
            \caption{Subfigure B}
        \label{fig:labelfigure2B}
    \end{subfigure}
    \caption{Caption of Figure 2}
    \label{fig:labelfigure1}
\end{figure}


\end{document}  

UPDATE

Using your own code, this is what I have:

\documentclass[12pt,a4paper]{article} 
        \usepackage[english]{babel} 
        \usepackage[demo]{graphicx} 
        \usepackage{caption}
        \usepackage{subcaption}
        \usepackage{color} 
        \usepackage{float}

        \begin{document}

        \begin{figure}[H] 
        \begin{subfigure}{.9\textwidth}
          \centering
          \includegraphics[width=.5\linewidth]{demo}
          \caption{$H \rightarrow b\overline{b}$}
                    \label{fig:fig1a}
         \end{subfigure}
        \begin{subfigure}{.9\textwidth}
          \centering
          \includegraphics[width=.5\linewidth]{demo} 
      \caption{$H \rightarrow \gamma \gamma$} 
            \label{fig:fig1b}
     \end{subfigure} 
     \caption{mmmm}
        \label{fig:fig1}
    \end{figure}

text text text.

Reference for Figure 1: \ref{fig:fig1}.

For Figure 1a: \ref{fig:fig1a}.

For Figure 1b: \ref{fig:fig1b}.

Reference for Figure 2: \ref{fig:fig2}.

For Figure 2a: \ref{fig:fig2a}.

For Figure 2b: \ref{fig:fig2b}.

 \begin{figure}[H] 
        \begin{subfigure}{.9\textwidth}
          \centering
          \includegraphics[width=.5\linewidth]{demo}
          \caption{$H \rightarrow b\overline{b}$}
                    \label{fig:fig2a}
         \end{subfigure}
        \begin{subfigure}{.9\textwidth}
          \centering
          \includegraphics[width=.5\linewidth]{demo} 
      \caption{$H \rightarrow \gamma \gamma$} 
            \label{fig:fig2b}
     \end{subfigure} 
     \caption{mmmm}
        \label{fig:fig2}
    \end{figure}

    \end{document}

Please keep in mind that [demo] was only used to replace your picture files. Just remove it on your preamble and use your files like \includegraphics[width=.5\linewidth]{yourownfilehere}.

The output of the code just mentioned is this: enter image description here