0

The following simple but maybe hacky example allows me to

  1. Place two graphics side-by-side in a floating environment.
  2. Assign symbolic labels to the graphics so that I can refer to them in the text.
  3. Print text labels at the top left of every graphic so the reader can see what I refer to.
  4. Print a single figure caption that explains all the subfigures.

However, there is one problem: The text labels are only aligned vertically if the graphics (or more precisely the subfigures) are vertically top-aligned. Some pairs of graphics look better when they are central- or bottom-aligned though. How can I preserve the placement of the labels while changing the alignment of the graphics?

I see this style of figures (side-by-side with labels in the top left and a unified caption) all the time in scientific articles. There the situation can get even more complex with multiple columns and rows of images that are always somehow labeled and aligned. Is there an established way or package to achieve this kind of layout that I could use instead of my ad-hoc solution?

example of misaligned labels

\documentclass{article}

\usepackage{graphicx}
\usepackage[labelfont=bf, singlelinecheck=false]{subcaption}

\begin{document}

\begin{figure}
  \centering
  \begin{subfigure}[t]{0.49\linewidth}
    \centering
    \caption{}\label{fig:example_t1}
    \includegraphics[width=\linewidth]{example-image}
  \end{subfigure}
  \begin{subfigure}[t]{0.49\linewidth}
    \centering
    \caption{}\label{fig:example_t2}
    \includegraphics[width=0.8\linewidth]{example-image}
  \end{subfigure}
  \caption{Examples graphics that look nice if they are top aligned. \textbf{(a)} A first example with a long and detailed description. \textbf{(b)} A second example with a long and detailed description.}\label{fig:examples_t}
\end{figure}

\begin{figure}
  \centering
  \begin{subfigure}[b]{0.49\linewidth}
    \centering
    \caption{}\label{fig:example_b1}
    \includegraphics[width=\linewidth]{example-image}
  \end{subfigure}
  \begin{subfigure}[b]{0.49\linewidth}
    \centering
    \caption{}\label{fig:example_b2}
    \includegraphics[width=0.8\linewidth]{example-image}
  \end{subfigure}
  \caption{Examples graphics that look nice if they are bottom aligned. \textbf{(a)} A first example with a long and detailed description. \textbf{(b)} A second example with a long and detailed description.}\label{fig:examples_b}
\end{figure}

\end{document}

1 Answer 1

2

I see two hackish ways to do what you want: The first involves manually adjusting the height of the box that includes the image+caption and adding some spacing below the caption (with \vfill); the second involves putting the captions outside of the subfigures, on the same line.

Option 1 is not so great because you have to guess the approximate size of the tallest image (in this case, 12\baselineskip):

\documentclass{article}

\usepackage{graphicx}
\usepackage[labelfont=bf, singlelinecheck=false]{subcaption}

\begin{document}

\begin{figure}
  \centering
  \begin{subfigure}[b][12\baselineskip]{0.49\linewidth}
    \centering
    \caption{}\label{fig:example_b1}
    \vfill
    \includegraphics[width=\linewidth]{example-image}
  \end{subfigure}
  \begin{subfigure}[b][12\baselineskip]{0.49\linewidth}
    \centering
    \caption{}\label{fig:example_b2}
    \vfill
    \includegraphics[width=0.8\linewidth]{example-image}
  \end{subfigure}
  \caption{Examples graphics that look nice if they are bottom aligned. \textbf{(a)} A first example with a long and detailed description. \textbf{(b)} A second example with a long and detailed description.}\label{fig:examples_b}
\end{figure}

\end{document}

Option 2 is not so great because it forces us to use \parbox and repeat the width of the images and also because we need to compensate for the padding around the subfigures (with \par\vspace{-1.5\baselineskip):

\documentclass{article}

\usepackage{graphicx}
\usepackage[labelfont=bf, singlelinecheck=false]{subcaption}

\begin{document}

\begin{figure}
  \centering
  \parbox{.49\linewidth}{\subcaption{\label{fig:example_b1}}}
  \parbox{.49\linewidth}{\subcaption{\label{fig:example_b2}}}
  \par\vspace{-1.5\baselineskip}
  \begin{subfigure}[b][12\baselineskip]{0.49\linewidth}
    \centering
    \includegraphics[width=\linewidth]{example-image}
  \end{subfigure}
  \begin{subfigure}[b][12\baselineskip]{0.49\linewidth}
    \centering
    \includegraphics[width=0.8\linewidth]{example-image}
  \end{subfigure}
  \caption{Examples graphics that look nice if they are bottom aligned. \textbf{(a)} A first example with a long and detailed description. \textbf{(b)} A second example with a long and detailed description.}\label{fig:examples_b}
\end{figure}

\end{document}

As a side note, I think it is always a good idea to put figure/table \labels inside the corresponding \caption.

You must log in to answer this question.

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