使用 \subcaption 包的垂直间距

使用 \subcaption 包的垂直间距

我有一个简单的问题。我试图在顶部两个和底部两个子图之间添加一点垂直间距。这是我的代码:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{.5\textwidth}
  \centering
  \includegraphics[scale=0.2]{CHRe100t0_5.jpg}
  \caption{t = 0.5 s and Re = 100}
\end{subfigure}%
\begin{subfigure}{.5\textwidth}
  \centering
  \includegraphics[scale=0.2]{ChRe100t1.jpg}
  \caption{t = 1.0 s and Re = 100}
\end{subfigure}
\begin{subfigure}{.5\textwidth}
   \centering
   \includegraphics[scale=0.2]{CHRe100t1_5.jpg}
   \caption{t = 1.5 s and Re = 100}
\end{subfigure}%
\begin{subfigure}{.5\textwidth}
\centering
   \includegraphics[scale=0.2]{CHRe100t2.jpg}
   \caption{t = 2.0 s and Re = 100}
\end{subfigure}
\caption{y vs. u}
\end{figure}
\end{document}

任何建议将不胜感激!

答案1

您可以在第二个和第三个子图之间插入说明\par\bigskip,以在两组子图之间创建一些额外的垂直空间。如果\bigskip对您来说太多了,请尝试使用\medskip

在此处输入图片描述

\documentclass{article}
\usepackage[demo]{graphicx} % omit 'demo' option in real document
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{.49\textwidth}
  \centering
  \includegraphics[scale=0.2]{CHRe100t0_5.jpg}
  \caption{t = 0.5 s and Re = 100}
\end{subfigure}
\begin{subfigure}{.49\textwidth}
  \centering
  \includegraphics[scale=0.2]{ChRe100t1.jpg}
  \caption{t = 1.0 s and Re = 100}
\end{subfigure}
\par\bigskip % force a bit of vertical whitespace
\begin{subfigure}{.49\textwidth}
   \centering
   \includegraphics[scale=0.2]{CHRe100t1_5.jpg}
   \caption{t = 1.5 s and Re = 100}
\end{subfigure}
\begin{subfigure}{.49\textwidth}
\centering
   \includegraphics[scale=0.2]{CHRe100t2.jpg}
   \caption{t = 2.0 s and Re = 100}
\end{subfigure}
\caption{y vs. u}
\end{figure}
\end{document}

答案2

只需输入较少的代码即可获得与 Mico 相同的结果:

\documentclass{article}
\usepackage[demo]{graphicx} % omit 'demo' option in real document
\usepackage{stackengine}
\begin{document}
\begin{figure}
\centering
\stackunder{\includegraphics[scale=0.2]{CHRe100t0_5.jpg}}{(a) t = 0.5 s and Re = 100}~~~~~~
\stackunder{\includegraphics[scale=0.2]{ChRe100t1.jpg}}{(b) t = 1.0 s and Re = 100}
\par\bigskip
\stackunder{\includegraphics[scale=0.2]{CHRe100t1_5.jpg}}{(c) t = 1.5 s and Re = 100}~~~~~~
\stackunder{\includegraphics[scale=0.2]{CHRe100t2.jpg}}{(d) t = 2.0 s and Re = 100}
\caption{y vs. u}
\end{figure}
\end{document}

答案3

改变\belowcaptionskip长度并用来\par表示新行。

\begin{figure}
  \newcommand{\subfigurehspace}{.49\linewidth}
  \setlength{\belowcaptionskip}{0.5\baselineskip}
  \centering
  % %%% ROW 1 %%%
  \begin{subfigure}[b]{\subfigurehspace}
    \centering
    \includegraphics[width=\linewidth]{1.png}
    \caption{}
  \end{subfigure}
  \hfill
  \begin{subfigure}[b]{\subfigurehspace}
    \centering
    \includegraphics[width=\linewidth]{2.png}
    \caption{}
  \end{subfigure}
  \par
  % %%% ROW 2 %%% 
  \begin{subfigure}[b]{\subfigurehspace}
    \centering
    \includegraphics[width=\linewidth]{3.png}
    \caption{}
  \end{subfigure}
  \hfill
  \begin{subfigure}[b]{\subfigurehspace}
    \centering
    \includegraphics[width=\linewidth]{4.png}
    \caption{}
  \end{subfigure}
\end{figure}

如果您不想在最后一行之后增加间距,您可以\belowcaptionskip在最后一行之前将其重置为原始值。不过这可能没有必要。

相关内容