19

I have three images and I want to align them in the way that one image is above the other two. Here's an example:

example alignment

How can I achieve this? For my other figures I use the subcaption package, but I am not able to align the pictures that way with it.


Thanks for all your replys! The answer that is working for me is the one supposed by karlkoeller:

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\centering
\begin{subfigure}[b]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{A mouse}\label{fig:mouse}
\end{subfigure}

\begin{subfigure}[b]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{A gull}\label{fig:gull}
\end{subfigure}
\begin{subfigure}[b]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-c}
\caption{A tiger}\label{fig:tiger}
\end{subfigure}
\caption{Picture of animals}
\label{fig:animals}
\end{figure}

\end{document}
1
  • Could we have a minimal (non)working example?
    – Bernard
    Jan 11, 2015 at 18:32

4 Answers 4

21

You are already using the subcaption package, and it is very easy with it.

Here's the code you need

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\centering
\begin{subfigure}[b]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{A mouse}\label{fig:mouse}
\end{subfigure}

\begin{subfigure}[b]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{A gull}\label{fig:gull}
\end{subfigure}
\begin{subfigure}[b]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-c}
\caption{A tiger}\label{fig:tiger}
\end{subfigure}
\caption{Picture of animals}
\label{fig:animals}
\end{figure}

\end{document}

Output:

enter image description here

If you need to have the subcaption numbers as in your picture, you have to adjust the counter subfigure with \setcounter{subfigure}{<num>} inside the subfigures

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\centering
\begin{subfigure}[b]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-c}
\setcounter{subfigure}{2}%
\caption{A mouse}\label{fig:mouse}
\end{subfigure}

\begin{subfigure}[b]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\setcounter{subfigure}{0}%
\caption{A gull}\label{fig:gull}
\end{subfigure}
\begin{subfigure}[b]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{A tiger}\label{fig:tiger}
\end{subfigure}
\caption{Picture of animals}
\label{fig:animals}
\end{figure}

\end{document} 

Output:

enter image description here

1
  • 3
    It might be worth mentioning that adding an empty line after the first subfigure environment serves as a new line. That is why the two subfigures that follow are placed below the first one. Similarly, by not adding an empty line between the second and third subfigure enviornments, the second and third subfigures shall appear next to each other (as long as they can fit within the page width). Sep 11, 2020 at 18:58
6

Within a figure environment you can start a tabular environment to have more control over the distribution of space. Fill the tabs with subfigures. You can even use the multirow package for even further tweaking and control.

\documentclass{article}

\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{multirow}

\begin{document}

\begin{figure}[h]
  \centering
  \begin{tabular}[c]{ccccc}
    \multirow{2}{*}[14pt]{
    \begin{subfigure}{0.45\textwidth}
      \includegraphics[height=2cm, width=\textwidth]{example-image-b}
      \caption{CEO fixed / total}
      \label{fig:ceoa}
    \end{subfigure}
}&
   \begin{subfigure}[c]{0.11\textwidth}
      \includegraphics[height=1cm, width=\textwidth]{example-image-a}
      \label{fig:ceob}
    \end{subfigure}&
    \begin{subfigure}[c]{0.11\textwidth}
      \includegraphics[height=1cm, width=\textwidth]{example-image-a}
      \label{fig:ceoc}
    \end{subfigure}&
    \begin{subfigure}[c]{0.11\textwidth}
      \includegraphics[height=1cm, width=\textwidth]{example-image-a}
      \label{fig:ceoe}
    \end{subfigure}&
    \begin{subfigure}[c]{0.11\textwidth}
      \includegraphics[height=1cm, width=\textwidth]{example-image-a}
      \label{fig:cdfeod}
    \end{subfigure}\\
    &
        \begin{subfigure}[c]{0.11\textwidth}
      \includegraphics[height=1cm, width=\textwidth]{example-image-a}
      \label{fig:caeob}
    \end{subfigure}&
    \begin{subfigure}[c]{0.11\textwidth}
      \includegraphics[height=1cm, width=\textwidth]{example-image-a}
      \label{fig:ceoac}
    \end{subfigure}&
    \begin{subfigure}[c]{0.11\textwidth}
      \includegraphics[height=1cm, width=\textwidth]{example-image-a}
      \label{fig:ceose}
    \end{subfigure}&
    \begin{subfigure}[c]{0.11\textwidth}
      \includegraphics[height=1cm, width=\textwidth]{example-image-a}
      \label{fig:ceod}
    \end{subfigure}\\
  \end{tabular}    
  \caption{Compensation measures}
  \label{fig:ceo}
\end{figure}

\end{document}

enter image description here

3
  • Almost all your subfigure environments are pointless in a tabular cell. You don't have a caption either, so i don't get the point of using it. It just makes the code longer and harder to read.
    – Johannes_B
    Oct 7, 2017 at 5:51
  • In this very example I agree. I put them though to show that it is posible to tabulate with them, which means that it is possible to caption and label.
    – EA304GT
    Oct 7, 2017 at 6:42
  • You can use caption and label in the table cells as well. subfigure is just a minipage which also sets the captiontype. Using captionof would be just enough.
    – Johannes_B
    Oct 7, 2017 at 6:48
5

It's relatively easy with the floatrow package, and its subfloatrowenvironment:

\documentclass{article}
\usepackage{subcaption}
\usepackage{floatrow}
\usepackage{graphicx}
\usepackage[showframe]{geometry}

\begin{document}

\begin{figure}
\floatsetup{capposition = below, floatrowsep =qquad,}
\centering
\begin{subfloatrow}
\centering
  \ffigbox[\textwidth]{\caption{The Death of Procris}}{%
  \includegraphics[width=0.8\textwidth]{Piero_di_Cosimo_1}
  }
\end{subfloatrow}
\vskip1cm
\begin{subfloatrow}
    \ffigbox[0.5\textwidth]{\caption{Portrait of Simonetta Vespucci}}{%
  \includegraphics[width=0.4\textwidth]{Piero_di_Cosimo_3}%
  }
    \ffigbox[0.5\textwidth]{\caption{Portrait of Simonetta Vespucci}}{%
  \includegraphics[width=0.4\textwidth]{Piero_di_Cosimo_3}%
  }
\end{subfloatrow}
\caption{Three paintings by Piero di Cosimo}
\label{PC}
\end{figure}

\end{document} 

enter image description here

3

You can use minipages to specify how the images should be aligned. If you include the image into a box first, then you can get the width of the image (which should be the width of the minipage) using \wd, i.e.:

\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}
\begin{document}
\begin{figure}
  \newcommand*\FigVSkip{0.5em}
  \newcommand*\FigHSkip{0.1em}
  \newsavebox\FigBox
  \centering
  % Top image is centered, so no need to get width
  \begin{minipage}{\textwidth}
    \centering\includegraphics{a_mouse}
    \subcaption{A mouse}
  \end{minipage} \\[\FigVSkip]%
  % Save first image in a box to get the width
  \sbox{\FigBox}{\includegraphics{a_gull}}
  \begin{minipage}{\wd\FigBox}
    \centering\usebox{\FigBox}
    \subcaption{A gull}
  \end{minipage}\hspace*{\FigHSkip}
  % Save second image 
  \sbox{\FigBox}{\includegraphics{a_tiger}}
  \begin{minipage}{\wd\FigBox}
    \centering\usebox{\FigBox}
    \subcaption{A tiger}
  \end{minipage}
  \caption{Pictures of animals}
\end{figure}
\end{document}

I also included the two parameters \FigHSkip and \FigVSkip to set the horizontal and vertical spacing of the images. The rest of the code is almost copied and pasted from subcaption documentation page 4 (subcaption on CTAN)

result

1

You must log in to answer this question.

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