10

I have 2 subfigures vertically arranged using the subcaption package. I can set the vertical space between the 2 to something specific (using \bigskip or \vspace), but I would like to put as much space as possible between the 2 instead, so that the first subfigure is at the top of the page, and the second one at the bottom (with the caption for the whole figure beneath it) - something like \vfill.

Minimal working example:

\documentclass[10pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{subcaption}

\begin{document}
\begin{figure}
    \begin{subfigure}{\textwidth}
        \centering \rule{4cm}{4cm} % 1st subfigure: \includegraphics{fig}...
    \end{subfigure}
    \par\bigskip % maximise vertical space here instead
    \begin{subfigure}{\textwidth}
        \centering \rule{4cm}{4cm} % 2nd subfigure: \includegraphics{fig}...
    \end{subfigure}
\caption{Some caption}
\end{figure}
\end{document}
  • Welcome to TeX.SE! Have you tried \vspace*{\fill} as the "filler" instruction? – Mico Nov 28 '13 at 19:48
  • I just tried it, it doesn't insert any space at all. – tave Nov 28 '13 at 19:58
  • What package provides subfigure environment? – Sigur Nov 28 '13 at 22:59
  • @Sigur subcaption :-) – user11232 Nov 28 '13 at 23:01
  • @HarishKumar, strange! I'm getting the error Environment subfigure undefined. – Sigur Nov 28 '13 at 23:03
11

I put a \vspace*{...} inside the subfigure block, just before \end{subfigure}. It applied the specified amount of spacing between my three subfigures. I did not try it using \fill, but I expect it would have a similar result. I've included a vague snippet of my code below. Hooray for simplicity!

\begin{figure*}[htb]
    \begin{subfigure}[t]{\linewidth}
        \label{}
        \centering\includegraphics[]{image1.eps}
        \caption{}
        \vspace*{2mm}
    \end{subfigure}
    \begin{subfigure}[c]{\linewidth}
        \label{}
        \centering\includegraphics[]{image2.eps}
        \caption{}
        \vspace*{2mm}
    \end{subfigure}
    \begin{subfigure}[b]{\linewidth}
        \label{}
        \centering\includegraphics[]{image3.eps}
        \caption{}
    \end{subfigure}
\end{figure*}
  • 2
    Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Adam Liter Feb 19 '14 at 19:30
  • It works for me. But starred versions of figure and vspace are not needed. Latex2e tells me that figure* is for double column formats (to span both columns) and tex.stackexchange.com/q/89082/157031 gave info on vspace*. – Cyriac Antony Jan 31 at 5:10
6

I don't know why \vspace{\fill} is not working in between. Hence this is a work-around using a parbox:

\documentclass[10pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{showframe}   %% just for demo

\begin{document}
\begin{figure}
    \begin{subfigure}{\textwidth}
       \parbox[t][.48\textheight]{\linewidth}{%  .48 because you have caption below
        \centering \rule{4cm}{4cm}}% 
    \end{subfigure}%
    \par
    \begin{subfigure}{\textwidth}
        \parbox[b][.48\textheight]{\linewidth}{%   %  .48 because you have caption below
        \centering \rule{4cm}{4cm}} 
    \end{subfigure}
\caption{Some caption}
\end{figure}
\end{document}

enter image description here

You can get rid of subfigure and use \parboxes or minipages directly where you can specify the height and width both.

  • Thanks for this workaround. It's working, however it still requires some manual tweaking to adjust the size of the \parbox depending on the length of the figure's caption - which I would have preferred to avoid. (NB: I'm keeping the subfigure to label / reference the subfigures) – tave Nov 29 '13 at 12:26

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.