21

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!

23

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}
  • 1
    Wouldn't \par\bigskip be (conceptually, but not only) better? – egreg Jun 23 '13 at 19:22
  • @egreg - thanks for the suggestion. I've modified the code. – Mico Jun 23 '13 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}
  • 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 Jun 24 '13 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. – Steven B. Segletes Jun 24 '13 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. – Steven B. Segletes Jul 11 '16 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.