减少子图之间的水平空间

减少子图之间的水平空间

我已经使用以下代码创建了一个 2x2 子图:

\begin{figure}
\centering
\begin{subfigure}{0.49\textwidth} % width of upper left subfigure
    \centering
    \includegraphics[width=.5\linewidth]{Test2/22_macro.png}
    \caption{Sample 2.1 - \SI{20}{ppm}} % subcaption
\end{subfigure}%
\hfil
\begin{subfigure}{0.49\textwidth} % width of upper right subfigure
    \centering
    \includegraphics[width=.5\linewidth]{Test2/23_macro.png}
    \caption{Sample 2.3 - \SI{50}{ppm}} % subcaption
\end{subfigure}%
\vfill
\begin{subfigure}{0.49\textwidth} % width of lower left subfigure
    \centering
    \includegraphics[width=.5\linewidth]{Test2/26_macro.png}
    \caption{Sample 2.6 - \SI{100}{ppm}} % subcaption
\end{subfigure}%
\hfil
\begin{subfigure}{0.49\textwidth} % width of lower right subfigure
    \centering
    \includegraphics[width=.5\linewidth]{Test2/27_macro.png}
    \caption{Samples 2.7 - \SI{150}{ppm}} % subcaption
\end{subfigure}%
\caption{} % caption for whole figure
\label{}
\end{figure}

在此处输入图片描述

但是从图中可以看出,图 a 和 b 以及图 c 和 d 之间有很多空白。

如何才能更有效地控制子图之间的水平距离?

提前致谢。

答案1

从你的问题来看,subfigure宽度大约等于一半\textwidth,图像宽度等于一半subfigure。因此,你可以将所有四个子图像放在一行中(第一张图),或者放在两行中(第二张图)。

两种情况的 Latex 代码:

%%%%%%%% first image
\begin{figure}
\begin{subfigure}[b]{0.24\textwidth} % width of upper left subfigure
    \includegraphics[width=\linewidth]{Test2/22_macro.png}
    \caption{Sample 2.1 - \SI{20}{ppm}} % subcaption
\end{subfigure}%
\hfill
\begin{subfigure}[b]{0.24\textwidth} % width of upper right subfigure
    \centering
    \includegraphics[width=\linewidth]{Test2/23_macro.png}
    \caption{Sample 2.3 - \SI{50}{ppm}} % subcaption
\end{subfigure}%
\hfill
\begin{subfigure}[b]{0.24\textwidth} % width of lower left subfigure
    \includegraphics[width=\linewidth]{Test2/26_macro.png}
    \caption{Sample 2.6 - \SI{100}{ppm}} % subcaption
\end{subfigure}%
\hfill
\begin{subfigure}[b]{0.24\textwidth} % width of lower right subfigure
    \includegraphics[width=\linewidth]{Test2/27_macro.png}
    \caption{Samples 2.7 - \SI{150}{ppm}} % subcaption
\end{subfigure}%
    \caption{common caption} % caption for whole figure
\label{fig:foursubfig}
\end{figure}

%%%%%%%% second image
\begin{figure}
\begin{subfigure}[b]{0.49\textwidth} % width of upper left subfigure
    \includegraphics[width=\linewidth]{Test2/22_macro.png}
    \caption{Sample 2.1 - \SI{20}{ppm}} % subcaption
\end{subfigure}%
\hfill
\begin{subfigure}[b]{0.49\textwidth} % width of upper right subfigure
    \centering
    \includegraphics[width=\linewidth]{Test2/23_macro.png}
    \caption{Sample 2.3 - \SI{50}{ppm}} % subcaption
\end{subfigure}

\begin{subfigure}[b]{0.49\textwidth} % width of lower left subfigure
    \includegraphics[width=\linewidth]{Test2/26_macro.png}
    \caption{Sample 2.6 - \SI{100}{ppm}} % subcaption
\end{subfigure}%
\hfill
\begin{subfigure}[b]{0.49\textwidth} % width of lower right subfigure
    \includegraphics[width=\linewidth]{Test2/27_macro.png}
    \caption{Samples 2.7 - \SI{150}{ppm}} % subcaption
\end{subfigure}%
    \caption{common caption} % caption for whole figure
\label{fig:foursubfig}
\end{figure}

%%%%%%%% third image
\begin{figure}
\centering
\begin{subfigure}[b]{0.25\textwidth} % width of upper left subfigure
    \includegraphics[width=\linewidth]{Test2/22_macro.png}
    \caption{Sample 2.1 - \SI{20}{ppm}} % subcaption
\end{subfigure}%
\quad
\begin{subfigure}[b]{0.25\textwidth} % width of upper right subfigure
    \centering
    \includegraphics[width=\linewidth]{Test2/23_macro.png}
    \caption{Sample 2.3 - \SI{50}{ppm}} % subcaption
\end{subfigure}

\begin{subfigure}[b]{0.25\textwidth} % width of lower left subfigure
    \includegraphics[width=\linewidth]{Test2/26_macro.png}
    \caption{Sample 2.6 - \SI{100}{ppm}} % subcaption
\end{subfigure}%
\quad
\begin{subfigure}[b]{0.25\textwidth} % width of lower right subfigure
    \includegraphics[width=\linewidth]{Test2/27_macro.png}
    \caption{Samples 2.7 - \SI{150}{ppm}} % subcaption
\end{subfigure}%
    \caption{common caption} % caption for whole figure
\label{fig:foursubfig}
\end{figure}

在此处输入图片描述

编辑: 您还可以将小图像排列在两行中(第三张图)。

在此处输入图片描述

相关内容