多個水平對齊的子圖

多個水平對齊的子圖

我在嘗試顯示同一行中水平對齊的多個圖形時遇到了一些麻煩,我使用以下 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}

在此輸入影像描述

相關內容