多个水平对齐的子图

多个水平对齐的子图

我在尝试显示同一行水平对齐的多个图形时遇到了一些麻烦,我使用了以下 LaTeX 命令,但得到了以下错误放置的图形:

身材不好

\usepackage{caption}
\usepackage{subcaption}

\begin{figure}
    \centering
    \begin{subfigure}[a]{0.125\textwidth}
        \centering
        \includegraphics[width=\textwidth]{Boxplot_Profit_RandCA_Library_KPI_19_31181_Rules_8_Size_3.png}
        \caption{}
        \label{fig:}
    \end{subfigure}
    \hfill
    \begin{subfigure}[b]{0.125\textwidth}
        \centering
        \includegraphics[width=\textwidth]{Boxplot_Weight_RandCA_Library_KPI_19_31181_Rules_8_Size_3.png}
        \caption{}
        \label{fig:}
    \end{subfigure}
    \hfill
    \begin{subfigure}[c]{0.125\textwidth}
        \centering
        \includegraphics[width=\textwidth]{Boxplot_Profit_RandCA_Library_KPI_40_100000_Rules_8_Size_3.png}
        \caption{}
        \label{fig:f}
    \end{subfigure}
    \hfill
    \begin{subfigure}[d]{0.125\textwidth}
        \centering
        \includegraphics[width=\textwidth]{Boxplot_Weight_RandCA_Library_KPI_40_100000_Rules_8_Size_3.png}
        \caption{}
        \label{fig:}
    \end{subfigure}
    \hfill
    \begin{subfigure}[e]{0.125\textwidth}
        \centering
        \includegraphics[width=\textwidth]{Boxplot_Profit_RandCA_Library_KPI_60_100000_Rules_8_Size_3.png}
        \caption{}
        \label{fig:}
    \end{subfigure}
    \hfill
    \begin{subfigure}[f]{0.125\textwidth}
        \centering
        \includegraphics[width=\textwidth]{Boxplot_Weight_RandCA_Library_KPI_40_100000_Rules_8_Size_3.png}
        \caption{}
        \label{fig:}
    \end{subfigure}
       \caption{Six simple graphs}
       \label{fig:three graphs}
\end{figure}

答案1

您似乎正在寻找以下内容:

在此处输入图片描述

正如@Miyase 在他的评论中提到的,您误解了子图选项的含义。Thea 对其位置有以下要求:(t用于顶部)、c(用于中间)和b(用于底部)。标题标签由命令定义\caption,默认为小写字母 a、b、c 等,在每个figure(或table)浮动时重置。

因此,您的图形的 MWE 应该是:

\documentclass{article}
\usepackage[font=small]{subcaption}
\usepackage{graphicx}

\begin{document}
    \begin{figure}[ht]
\setkeys{Gin}{width=\linewidth}
    \begin{subfigure}[t]{0.15\textwidth}
\includegraphics{example-image-duck}%{Boxplot_Profit_RandCA_Library_KPI_19_31181_Rules_8_Size_3.png}
\caption{}
\label{fig:}
    \end{subfigure}
\hfill
    \begin{subfigure}[t]{0.15\textwidth}
\includegraphics{example-image-duck}%{Boxplot_Weight_RandCA_Library_KPI_19_31181_Rules_8_Size_3.png}
\caption{}
\label{fig:}
    \end{subfigure}
\hfill
    \begin{subfigure}[t]{0.15\textwidth}
\includegraphics{example-image-duck}%{Boxplot_Profit_RandCA_Library_KPI_40_100000_Rules_8_Size_3.png}
\caption{}
\label{fig:f}
    \end{subfigure}
\hfill
    \begin{subfigure}[t]{0.15\textwidth}
\includegraphics{example-image-duck}%{Boxplot_Weight_RandCA_Library_KPI_40_100000_Rules_8_Size_3.png}
\caption{}
\label{fig:}
    \end{subfigure}
\hfill
    \begin{subfigure}[t]{0.15\textwidth}
\includegraphics{example-image-duck}%{Boxplot_Profit_RandCA_Library_KPI_60_100000_Rules_8_Size_3.png}
\caption{}
\label{fig:}
    \end{subfigure}
\hfill
    \begin{subfigure}[t]{0.15\textwidth}
\includegraphics{example-image-duck}%{Boxplot_Weight_RandCA_Library_KPI_40_100000_Rules_8_Size_3.png}
\caption{}
\label{fig:}
    \end{subfigure}
\caption{Six simple graphs}
\label{fig:three graphs}
    \end{figure}
\end{document}

答案2

subcaptionbox如果不需要子标题,可以将 的第一个参数设置为空,例如\subcaptionbox{}{\includegraphics[width=.125\linewidth]{example-image}}

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}

\begin{figure}
\centering
\subcaptionbox{a1\label{a1}}{\includegraphics[width=.125\linewidth]{example-image}}\hfill
\subcaptionbox{a2\label{a2}}{\includegraphics[width=.125\linewidth]{example-image}}\hfill
\subcaptionbox{a3\label{a3}}{\includegraphics[width=.125\linewidth]{example-image}}\hfill
\subcaptionbox{a4\label{a4}}{\includegraphics[width=.125\linewidth]{example-image}}\hfill
\subcaptionbox{a5\label{a5}}{\includegraphics[width=.125\linewidth]{example-image}}\hfill
\subcaptionbox{a6\label{a6}}{\includegraphics[width=.125\linewidth]{example-image}}
\caption{bbb}
\label{bbb}
\end{figure}

\end{document}

在此处输入图片描述

相关内容