I am trying to put a figure, next to four other figures, two up and two down. That is, one figure on the left side, four small figures on the right side (2 by 2)
But whenever I add the subcaption, they end up stacking up instead.
I'd be very grateful if anyone can help me.
Thanks!
\documentclass[]{article}
\usepackage[margin=0.8in]{geometry}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}[ht!]
\captionsetup{justification=centering}
\centering
\begin{minipage}{.49\linewidth}
\centering
\includegraphics[width=0.9\linewidth]{figfit22.png}
\subcaption{Measured spacing as function of pitch}
\end{minipage}
\hfill
\centering
\begin{minipage}{.49\linewidth}
\centering
\includegraphics[width=0.31\linewidth]{dif42.png}\subcaption{Pitch: 24 $\mu$m}
\includegraphics[width=0.31\linewidth]{dif12.png}\subcaption{Pitch: 83 $\mu$m}
\includegraphics[width=0.31\linewidth]{dif22.png}\subcaption{Pitch: 125 $\mu$m}
\includegraphics[width=0.31\linewidth]{dif32.png}\subcaption{Pitch: 250 $\mu$m}
\end{minipage}
\end{figure}
\end{document}
Best Answer
Use
\subcaptionbox{<caption>}{<image>}
instead. Note the warning in thesubcaption
manual:So when using
\subcaption
, each of them must have its ownminipage
or similar. With\subcaptionbox
you don't need that.(As I don't have your images I added the
demo
option tographicx
, you want to remove that.)