How can I have a figure (with a caption) that has three subfigures (each with its own caption, say (a), (b) and (c)) with the following layout: There are two columns; the first column is a single subfigure, the second column consists of two subfigures stacked vertically:
2 Answers
Using subcaption
and minipage
s you can achieve this:
\documentclass[]{article}
\usepackage{subcaption}
\usepackage[]{graphicx}
\begin{document}
\begin{figure}% >>>
\centering
\begin{minipage}[t]{.45\linewidth}
\subcaptionbox{text1}
{\includegraphics[width=\linewidth]{example-image-duck}}%
\end{minipage}%
\hfill
\begin{minipage}[b]{.45\linewidth}
\subcaptionbox{text2}
{\includegraphics[width=.5\linewidth]{example-image-duck}}
\subcaptionbox{text3}
{\includegraphics[width=.5\linewidth]{example-image-duck}}%
\end{minipage}%
\caption
{%
Caption.%
\label{fig:caption}%
}%
\end{figure}% <<<
\end{document}
Using the subfig
package as though one has tried to read its manual:
\documentclass[]{article}
\usepackage{subfig}
\usepackage[]{graphicx}
\begin{document}
\begin{figure}% >>>
\centering
\begin{minipage}[t]{.45\linewidth}
\subfloat[text1]
{\includegraphics[width=\linewidth]{example-image-duck}}%
\end{minipage}%
\hfill
\begin{minipage}[b]{.45\linewidth}
\subfloat[text2]
{\includegraphics[width=.5\linewidth]{example-image-duck}}\\
\subfloat[text3]
{\includegraphics[width=.5\linewidth]{example-image-duck}}%
\end{minipage}%
\caption
{%
Caption.%
\label{fig:caption}%
}%
\end{figure}% <<<
\end{document}
Output is almost identical.
-
Thanks! it works. However, I was using the subfig package for some other figures and it is incompatible with subcaption. Is there a similar solution with subfig instead of subcaption? Sep 20, 2018 at 20:21
-
-
With the more modern subcaption
package, you can simply nest subfigure
for advanced layouts, like so:
Result
Code
\documentclass[a4paper,12pt]{book}
\usepackage{subcaption}
\usepackage[]{graphicx}
\begin{document}
\begin{figure}[th]
\begin{subfigure}[b]{0.65\textwidth}
\includegraphics[width=\textwidth]{test}
\caption{1}
\end{subfigure}
\hfill % NOTE1: hfill moves horizontally stacked objects as far apart as it can
\begin{subfigure}[b]{0.32\textwidth}
\begin{subfigure}[t]{\textwidth}
\includegraphics[width=\textwidth]{test}
\caption{2}
\end{subfigure}
% NOTE2: two empty lines = 1 linebreak
\begin{subfigure}[b]{\textwidth}
\includegraphics[width=\textwidth]{test}
\caption{3}
\end{subfigure}
\end{subfigure}
\caption{figure caption}
\end{figure}
\end{document}
A few things to note
- You can force linebreaks (i.e. move to the next "row") through several means. The simplest approach is add two empty lines. Conversely, you want to be careful not to insert random empty lines into your figure environment. (E.g. the other day, I wasted an hour debugging this exact problem because I forgot that empty lines insert rows).
\hfill
can be used to space things out horizontally.- If the total width of all horizontally stacked subfigure exceeds
\textwidth
, it will also automatically move things to the next line. If you want to use more than\textwidth
, you have to solve a more complicated problem (see here).