7

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

  • you can use subfigure 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? – user31729 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
9

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.

  • Thanks a lot. It worked perfectly fine. thank you so much. – skm Jun 12 '15 at 19:19
  • @skm You're welcome! Glad I could help. – Gonzalo Medina Jun 12 '15 at 21:28
  • Note alo the discussion here about subcaption vs. subfig. – Davor Josipovic Jan 2 '17 at 16:04
1

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}
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.