如何让一个图形包含多组图像并且每组图像都有单独的名称?

如何让一个图形包含多组图像并且每组图像都有单独的名称?

我有几张图片,我必须在它们下面放置它们的名称。此外,我还需要给出这些图片组的名称(例如,如下所示的“第一层”、“第二层”等)。我需要有如下图所示的内容。

图像

重要的:在我的例子中,一组图像可能包含多行。我的意思是,“(a)第一层”可能包含多于 3 幅图像,因此可以是多行的一组图像。

答案1

两个选项:

  1. tabular对每一层和包使用一些s subcaption

    在此处输入图片描述

    代码:

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

    tabular上面我使用了具有三种类型列的标准c;如果图像下方的文本跨越多行,则可以使用tabularxtabularx和居中X列,如下面的选项所示。

  2. 由于 OP 正在使用subfigsubcaption因此无法使用该包;这里有一个使用与以前相同想法的方法,但使用tabularxsubfig包:

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

    在此处输入图片描述

答案2

您可以有多行,例如查看此示例经典论文

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}

相关内容