39

I have a simple problem. I'm trying to add a little bit of vertical spacing between the top two and bottom two subfigures. Here's my code:

\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}

Any suggestions would be greatly appreciated!

0

3 Answers 3

49

You could insert the instructions \par\bigskip between the second and third subfigure to create a bit of extra vertical space between the two sets of subfigures. If \bigskip is too much for your taste, try using \medskip.

enter image description here

\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
  • 6
    Wouldn't \par\bigskip be (conceptually, but not only) better?
    – egreg
    Commented Jun 23, 2013 at 19:22
  • @egreg - thanks for the suggestion. I've modified the code.
    – Mico
    Commented Jun 23, 2013 at 20:35
2

The same result (as Mico) can be obtained with less typing:

\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
  • An interesting solution. Real quick: Will this solution allow the creation of hyperlinks to each of the four subfigure environments (assuming, of course, that each one is given its own \label)?
    – Mico
    Commented Jun 24, 2013 at 0:50
  • @Mico. I don't use hyperref so I can't answer with authority, but the stackengine package makes no special provisions for it. Thus, I would guess that \label{} would get you to the figure, but not the subfigure. Commented Jun 24, 2013 at 10:09
  • 1
    @Mico A little late in reply, but this answer, tex.stackexchange.com/questions/170304/…, shows how hyperref can be incorporated with stackengine to handle subfigure hotlinks. Commented Jul 11, 2016 at 9:55
1

Change the \belowcaptionskip length and use \par to denote new rows.

\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}

If you don't want additional spacing after the last row, you can reset \belowcaptionskip to its original value before the final row. This should probably not be necessary, though.

1
  • The \par is not necessary. Lines will also break automatically, and have the desired vertical spacing until the next row. Commented Apr 10, 2023 at 14:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .