如何将多个子图放在具有不同主标题的单个页面上?

如何将多个子图放在具有不同主标题的单个页面上?

我必须使用 subfigure 命令在一页上添加 8 个图形,其中前 4 个图形应放在一个标题下,后 4 个图形应放在另一个标题下。请提供代码示例指导我,我该怎么做?示例如下附图所示: 在此处输入图片描述

答案1

如果两个环境不应浮动到不同的页面上,您可以将它们minipage(每个环境都有自己的\caption四个\subcaptionbox命令)放入一个环境中:figure

\documentclass{article}

\usepackage{subcaption}
\usepackage{mwe}% for example-image

\begin{document}
\begin{figure}
  \begin{minipage}{\linewidth}\centering
    \subcaptionbox{First}{\includegraphics[height=5em,width=.48\linewidth]{example-image-a}}
    \subcaptionbox{Second}{\includegraphics[height=5em,width=.48\linewidth]{example-image-b}}
    \subcaptionbox{Third}{\includegraphics[height=5em,width=.48\linewidth]{example-image-c}}
    \subcaptionbox{Forth}{\includegraphics[height=5em,width=.48\linewidth]{example-image}}
    \caption{This is the first figure}
  \end{minipage}

  \bigskip
  \begin{minipage}{\linewidth}\centering
    \subcaptionbox{First}{\includegraphics[height=5em,width=.48\linewidth]{example-image-a}}
    \subcaptionbox{Second}{\includegraphics[height=5em,width=.48\linewidth]{example-image-b}}
    \subcaptionbox{Third}{\includegraphics[height=5em,width=.48\linewidth]{example-image-c}}
    \subcaptionbox{Forth}{\includegraphics[height=5em,width=.48\linewidth]{example-image}}
    \caption{This is the second figure}
  \end{minipage}
\end{figure}
\end{document}

在此处输入图片描述

但如果要让它们浮动到不同的页面上,那么只需使用两个图形即可:

\documentclass{article}

\usepackage{subcaption}
\usepackage{mwe}% for example-image

\begin{document}
\begin{figure}
  \centering
  \subcaptionbox{First}{\includegraphics[height=5em,width=.48\linewidth]{example-image-a}}
  \subcaptionbox{Second}{\includegraphics[height=5em,width=.48\linewidth]{example-image-b}}
  \subcaptionbox{Third}{\includegraphics[height=5em,width=.48\linewidth]{example-image-c}}
  \subcaptionbox{Forth}{\includegraphics[height=5em,width=.48\linewidth]{example-image}}
  \caption{This is the first figure}
\end{figure}

\begin{figure}
  \centering
  \subcaptionbox{First}{\includegraphics[height=5em,width=.48\linewidth]{example-image-a}}
  \subcaptionbox{Second}{\includegraphics[height=5em,width=.48\linewidth]{example-image-b}}
  \subcaptionbox{Third}{\includegraphics[height=5em,width=.48\linewidth]{example-image-c}}
  \subcaptionbox{Forth}{\includegraphics[height=5em,width=.48\linewidth]{example-image}}
  \caption{This is the second figure}
\end{figure}
\end{document}

两个数字

答案2

你可以在一个浮点数中添加两个标题。使用subfig软件包可以得到以下解决方案:

\documentclass{article}

\usepackage{subfig}
\usepackage{graphicx}

\begin{document}
\begin{figure}[htbp]
  \centering
    \subfloat[First]{\includegraphics[height=7em,width=.45\linewidth]{example-image-a}}
    \hfil
    \subfloat[Second]{\includegraphics[height=7em,width=.45\linewidth]{example-image-b}}

    \subfloat[Third]{\includegraphics[height=7em,width=.45\linewidth]{example-image-c}}
    \hfil
    \subfloat[Forth]{\includegraphics[height=7em,width=.45\linewidth]{example-image}}
    \caption{This is the first figure}

  \bigskip
    \subfloat[First]{\includegraphics[height=7em,width=.45\linewidth]{example-image-a}}
    \hfil
    \subfloat[Second]{\includegraphics[height=7em,width=.45\linewidth]{example-image-b}}

    \subfloat[Third]{\includegraphics[height=7em,width=.45\linewidth]{example-image-c}}
    \hfil
    \subfloat[Forth]{\includegraphics[height=7em,width=.45\linewidth]{example-image}}
    \caption{This is the second figure}
\end{figure}
\end{document}

在此处输入图片描述

相关内容