[Tex/LaTex] how to group images in a figure

floats

I want to group images and assign the same sub-figure number in a figure consisting of several such groups. Please have a look at the following image to understand my question properly.

image

Best Answer

Two options, but the general idea is the same: to use one subfigure environment (requires subcaption) or \subfloat command (requires subfig) for each group.

Here's one option using the powerful subcaption package:

\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}

\begin{document}

\begin{figure}
  \begin{subfigure}{\linewidth}
  \includegraphics[width=.3\linewidth]{example-image-a}\hfill
  \includegraphics[width=.3\linewidth]{example-image-a}\hfill
  \includegraphics[width=.3\linewidth]{example-image-a}
  \caption{}
  \end{subfigure}\par\medskip
  \begin{subfigure}{\linewidth}
  \includegraphics[width=.3\linewidth]{example-image-b}\hfill
  \includegraphics[width=.3\linewidth]{example-image-b}\hfill
  \includegraphics[width=.3\linewidth]{example-image-b}
  \caption{}
  \end{subfigure}\par\medskip
  \begin{subfigure}{\linewidth}
  \includegraphics[width=.3\linewidth]{example-image-c}\hfill
  \includegraphics[width=.3\linewidth]{example-image-c}\hfill
  \includegraphics[width=.3\linewidth]{example-image-c}
  \caption{}
  \end{subfigure}
  \caption{Some grouped images}
\end{figure}

\end{document}

The output:

enter image description here

And now with the help of the subfig package:

\documentclass{article}
\usepackage{subfig}
\usepackage{graphicx}

\begin{document}

\begin{figure}
  \subfloat[]{%
  \begin{minipage}{\linewidth}
  \includegraphics[width=.3\linewidth]{example-image-a}\hfill
  \includegraphics[width=.3\linewidth]{example-image-a}\hfill
  \includegraphics[width=.3\linewidth]{example-image-a}%
  \end{minipage}%
  }\par
  \subfloat[]{%
  \begin{minipage}{\linewidth}
  \includegraphics[width=.3\linewidth]{example-image-b}\hfill
  \includegraphics[width=.3\linewidth]{example-image-b}\hfill
  \includegraphics[width=.3\linewidth]{example-image-b}%
  \end{minipage}%
  }\par
  \subfloat[]{%
  \begin{minipage}{\linewidth}
  \includegraphics[width=.3\linewidth]{example-image-c}\hfill
  \includegraphics[width=.3\linewidth]{example-image-c}\hfill
  \includegraphics[width=.3\linewidth]{example-image-c}%
  \end{minipage}%
  }
  \caption{Some grouped images}
\end{figure}

\end{document}

The output:

enter image description here

Another option might be to use the floatrow package.