5

I have several images and I must put their names below them. Moreover, I need to give the name of the group of that images too (for example, "first layer", "second layer" ect as show below). I need to have something as shown in the figure below.

image

IMPORTANT: In my case, a group of images may contain more than one row. I mean, the "(a) first layer" may contain more than 3 images and hence can be a group of images in more than one row.

2
  • The question is answered here: tex.stackexchange.com/questions/132599/… Commented Jul 27, 2015 at 21:37
  • @rvaneijk: Actually in my case, a group of images may contain more than one row. Commented Jul 27, 2015 at 21:40

2 Answers 2

3

Two options:

  1. Using some tabulars for each layer and the subcaption package:

    enter image description here

    The code:

    \documentclass{article}
    \usepackage{subcaption}
    \usepackage{graphicx}
    
    \begin{document}
    
    \begin{figure}
    \begin{minipage}{\linewidth}
      \centering
      \begin{tabular}{ccc}
      \includegraphics[width=.28\linewidth,height=1cm]{example-image-a}
        & \includegraphics[width=.28\linewidth,height=1cm]{example-image-b}
        & \includegraphics[width=.28\linewidth,height=1cm]{example-image-c} \\
      First image & Second image & Third image \\  
      \includegraphics[width=.28\linewidth,height=1cm]{example-image-a}
        & \includegraphics[width=.28\linewidth,height=1cm]{example-image-b} \\
      Fourth image & Fifth image &
      \end{tabular}
      \subcaption{First layer}
      \end{minipage}\par\bigskip
      \begin{minipage}{\linewidth}
      \centering
      \begin{tabular}{ccc}
      \includegraphics[width=.28\linewidth,height=1cm]{example-image-a}
        & \includegraphics[width=.28\linewidth,height=1cm]{example-image-b}
        & \includegraphics[width=.28\linewidth,height=1cm]{example-image-c} \\
      First image & Second image & Third image \\  
      \end{tabular}
      \subcaption{Second layer}
      \end{minipage}
    \caption{a figure with some layers of subfigures each with its own name and each layer with a subcaption}
    \end{figure}
    
    \end{document}
    

    Above I used a standard tabular with three c type columns; if the text below the images should span more than one line, you could use tabularx from the tabularx package and centered X columns, as the option below illustrates.

  2. Since the OP is using subfig, the subcaption package cannot be used; here's an approach using the same idea as before, but with tabularx and the subfig package:

    \documentclass{article}
    \usepackage[caption=false]{subfig}
    \usepackage{graphicx}
    \usepackage{tabularx}
    
    \newcolumntype{Y}{>{\centering\arraybackslash}X}
    
    \begin{document}
    
    \begin{figure}
    \subfloat[First layer]{%
    \begin{minipage}{\linewidth}
      \centering
      \begin{tabularx}{\linewidth}{YYY}
      \includegraphics[width=\linewidth,height=1cm]{example-image-a}
        & \includegraphics[width=\linewidth,height=1cm]{example-image-b}
        & \includegraphics[width=\linewidth,height=1cm]{example-image-c} \\
      First image & Second image & Third image \\  
      \includegraphics[width=\linewidth,height=1cm]{example-image-a}
        & \includegraphics[width=\linewidth,height=1cm]{example-image-b} \\
      Fourth image & Fifth image &
      \end{tabularx}
      \end{minipage}}\par\medskip
    \subfloat[Second layer]{%
      \begin{minipage}{\linewidth}
      \centering
      \begin{tabularx}{\linewidth}{YYY}
      \includegraphics[width=\linewidth,height=1cm]{example-image-a}
        & \includegraphics[width=\linewidth,height=1cm]{example-image-b}
        & \includegraphics[width=\linewidth,height=1cm]{example-image-c} \\
      First image & Second image & Third image \\  
      \end{tabularx}
      \end{minipage}}
    \caption{a figure with some layers of subfigures each with its own name and each layer with a subcaption}
    \end{figure}
    
    \end{document}
    

    enter image description here

9
  • It throws an error Undefined control sequence. \subcaption because I am already using \usepackage[caption = false]{subfig} Commented Jul 27, 2015 at 22:10
  • 1
    @skm You should have mentioned that in the first place! subcaption and subfig are incompatible. In some minutes I'll update my answer using subfig instead. Commented Jul 27, 2015 at 22:12
  • Actually, I am already using \usepackage[caption = false]{subfig} and hence I cannot use \usepackage{subcaption} in combination to it Commented Jul 27, 2015 at 22:12
  • @skm Please see the updated answer under the "Update" section. Commented Jul 27, 2015 at 22:16
  • 2
    @skm If you want normal size for the subcaptions load the subfig package like this: \usepackage[caption=false,font=normalsize]{subfig}. The other option is to use something like \small First image & \small Second image... inside the table to reduce the font size for the image names. Commented Jul 27, 2015 at 22:36
0

You can have multiple rows, e.g. look at this example from ClassicThesis:

begin{figure}[bth]
    \myfloatalign
    \subfloat[Asia personas duo.]
    {\includegraphics[width=.45\linewidth]{gfx/example_1}} \quad
    \subfloat[Pan ma signo.]
    {\label{fig:example-b}%
     \includegraphics[width=.45\linewidth]{gfx/example_2}} \\
    \subfloat[Methodicamente o uno.]
    {\includegraphics[width=.45\linewidth]{gfx/example_3}} \quad
    \subfloat[Titulo debitas.]
    {\includegraphics[width=.45\linewidth]{gfx/example_4}}
    \caption[Tu duo titulo debitas latente]{Tu duo titulo debitas
    latente.}\label{fig:example}
\end{figure}
5
  • it is giving me several error among which one is "undefined control sequence. \myfloatalign". Please tell me, which package should be included for that. Commented Jul 27, 2015 at 21:51
  • can you provide an screenshot of the figure which will be resulted with the above code. Commented Jul 27, 2015 at 21:57
  • I will try to create a working document tomorrow, it is 0h06 now.. ok? Commented Jul 27, 2015 at 22:07
  • can one say why the answer was downvoted? Commented Jul 27, 2015 at 23:20
  • Got this from classicthesis files: \newcommand{\myfloatalign}{\centering} Commented Aug 26, 2024 at 6:43

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.