# Memoir class - figure and margin figure floats at same vertical level

In a memoir class document, I would like to display a figure and a marginfigure next to each other but I need the top of the marginfigure at the same vertical level as the figure next to it.

When I try the following

\documentclass{memoir}
\usepackage{graphicx}
\begin{document}
\begin{figure}[!ht]
\includegraphics[width=\columnwidth]{example-image-a}
\caption{Figure along text}
\end{figure}
\begin{marginfigure}
\includegraphics[width=\marginparwidth]{example-image-b}
\caption{Margin figure}
\end{marginfigure}
\end{document}


I end up with the top of the marginfigure at a lower level than the top of the figure:

When I invert their order in the code, the opposite occurs:

Is it possible to have the top of both floats at the same vertical level?

• why you not enclose images in the same float environment which has locally increased \textwidth. for example with help of the changepage package? – Zarko Dec 7 '18 at 18:58
• The basic problem here is that the marginfigure is aligned vertically relative to the text in the document, not to the float. Put some text in the MWE above and below the floats to make it clearer what is going on, and also try \begin{figure}[!t] for example. As @Zarko said, the only general solution is to combine both graphics into a single float. – alephzero Dec 7 '18 at 21:43

let me elaborate my comment ...

the package memoir has integrated functionality of the changepage package. for use of its macro adjustwidth for locally change the text width in two side documents is advisable to use the option strict which will push smaller image to margin of a page:

\documentclass[strict]{memoir}
\usepackage[export]{adjustbox} % for align images in table, ...
\usepackage{tabularx}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
\begin{figure}[htb]
\setlength\tabcolsep{0pt}
\begin{tabularx}{\linewidth}{X @{\hspace{\marginparsep}}p{\marginparwidth}}
\includegraphics[width=\linewidth,valign=t]{example-image-a}
\caption{Figure along text}
&   \includegraphics[width=\linewidth,valign=t]{example-image-b}
\caption{Margin figure}
\end{tabularx}

• This works great and I did not know about most of what you explained. However, what would I need to do to have another marginfigure directly below the "B" marginfigure? – jrojasqu Dec 10 '18 at 23:53
• @jrojasqu, if the image is only below "B" and hasn't special requirement for align, than just add one more image in the second column, for example:& \includegraphics[width=\linewidth,valign=t]{example-image-b} \caption{Margin figure B} \medskip \includegraphics[width=\linewidth,valign=b]{example-image-c} \caption{Margin figure C} – Zarko Dec 11 '18 at 0:10
• Wow, it's that easy... I was setting up another table inside the first table just to add more marginfigures below "B" and could not work it out properly. Never crossed my mind to simply skip the line... Thanks a lot! – jrojasqu Dec 11 '18 at 0:18