# Figure and caption side-by-side with multiple includegraphics commands

I am trying to adapt this solution (top option) for placing captions beside the figure. If I have one figure it works as expected, but when I try to add a second \includegraphics command to get an image immediately below the first - the spacing does not work as I expected (see figures below). How do I fix this? Or is there an alternative? I tried sidecap but it did not work for me.

MWE

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

\begin{document}

\begin{figure}
\floatbox[{\capbeside\thisfloatsetup{capbesideposition={left,top},capbesidewidth=0.4\textwidth}}]{figure}[\FBwidth]
{\caption{A test figure with its caption side by side - works fine if I only have one includegraphics}\label{fig:test}}
{\includegraphics[width=0.5\textwidth]{example-grid-100x100pt}}
\end{figure}

\begin{figure}
\floatbox[{\capbeside\thisfloatsetup{capbesideposition={left,top},capbesidewidth=0.4\textwidth}}]{figure}[\FBwidth]
{\caption{With two includegraphics everything is pushed to the right outside the page borders}\label{fig:test}}
{\includegraphics[width=0.5\textwidth]{example-grid-100x100pt} \\ \includegraphics[width=0.5\textwidth]{example-image-b}}
\end{figure}

\end{document}

• As it is, your code gives the following error message: Something's wrong--perhaps a missing \item.. Please never ever ignore error messages! Even if you get something that on first glance resembles a pdf file, there can still be issues with it. After an error, TeX only tries to recover enough to syntax check more of the file, it does not try to make sensible output after an error. Sep 8, 2019 at 8:11
• Are the two images suppose to only have a single caption? Sep 8, 2019 at 8:13
• The floatrow package tends to do strange things to captions. See tex.stackexchange.com/questions/403661/… Sep 8, 2019 at 16:18
• @leandriis the error message isn't being ignored - I just don't know how to fix things. If I knew how to fix it I wouldn't need to post on SE ;) And yes it's like the MWE - two images with a single caption. Sep 8, 2019 at 23:51
• @Esme_: There was no hint on an error message in the question. This is why I initially expected the code to compile without errors but yielding the undesired output. My above comment was intended more like "don't worry about undesired outputs as long as there are error messages". Sep 9, 2019 at 8:14

I suppose that your two images only have a single caption that is top aligned with the upper of the two images. In the following MWE, I have used a tabular to help position the images:

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

\begin{document}
\begin{figure}
\floatbox[{\capbeside\thisfloatsetup{capbesideposition={left,top},capbesidewidth=0.4\textwidth}}]{figure}[\FBwidth]
{\caption{With two includegraphics everything is pushed to the right outside the page borders}\label{fig:test}}
{\begin{tabular}{@{}l@{}}\includegraphics[width=0.5\textwidth]{example-grid-100x100pt} \\
\includegraphics[width=0.5\textwidth]{example-image-b}\end{tabular}
}
\end{figure}

\end{document}