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

4
  • you can use subfigure ctan.org/pkg/subfig
    – rpapa
    Commented Jun 11, 2015 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
    Commented Jun 11, 2015 at 20:58
  • @skm use 3 \includegraphics{...} for each of the groups with subfig then?
    – user31729
    Commented Jun 11, 2015 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
    Commented Jun 11, 2015 at 21:25

2 Answers 2

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.

3
  • Thanks a lot. It worked perfectly fine. thank you so much.
    – skm
    Commented Jun 12, 2015 at 19:19
  • @skm You're welcome! Glad I could help. Commented Jun 12, 2015 at 21:28
  • Note alo the discussion here about subcaption vs. subfig. Commented Jan 2, 2017 at 16:04
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}
2
  • This requires loading the subfigure package which is obsolete and shouldn't be used anymore. Commented Jun 11, 2015 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. Commented Jun 11, 2015 at 22:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .