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}
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.