10

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

skm
  • 960
  • you can use subfigure https://www.ctan.org/pkg/subfig – rpapa Jun 11 '15 at 20:54
  • @rpapa: I think that it will provide a number (i mean (a), (b), (c)...) to each sub-figure. But I need that a number is provided to a group of three figures only as depicted in my sample image above. – skm Jun 11 '15 at 20:58
  • @skm use 3 \includegraphics{...} for each of the groups with subfig then? –  Jun 11 '15 at 21:08
  • @ChristianHupfer: May be, i did not understand your suggestion properly but i think that in that case, each group will become a separate figure which will not look good. – skm Jun 11 '15 at 21:25

2 Answers2

14

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.

Gonzalo Medina
  • 505,128
2

try this

\begin{figure}{h}
\subfigure[caption 1]{\label{...}
\includegraphics{img1-a}\hspace{1em}
\includegraphics{img1-b}\hspace{1em}
\includegraphics{img1-c}
}
subfigure[caption 2]{\label{...}
\includegraphics{img2-a}\hspace{1em}
\includegraphics{img2-b}\hspace{1em}
\includegraphics{img2-c}
}

\caption{}
\label{}
\end{figure}
rpapa
  • 12,350
  • This requires loading the subfigure package which is obsolete and shouldn't be used anymore. – Gonzalo Medina Jun 11 '15 at 22:30
  • Besides, using just h as placement specifier is a recipe for disaster and the placement specifier goes as optional argument for figure and your code snippet uses it as mandatory argument. – Gonzalo Medina Jun 11 '15 at 22:41