Placing listing and figure side by side in memoir
I am writing a document using the memoir class where I want to place
listings (with the listings package) and figures side by side. My first
approach was to save the listing in box and use \subbottom to place both
elements:
\newsavebox{\firstlisting}
\begin{lrbox}{\firstlisting}
\begin{lstlisting}[caption=Hello,label=lst:hello,style=pythoncode]
echo("Hello World!")
\end{lstlisting}
\end{lrbox}
\begin{figure}[htbp]
\centering
\subbottom{
\usebox{\firstlisting}}
\subbottom{
\includegraphics[width=0.45\textwidth]{some_image}}
\caption{Example}
\label{fig:example}
\end{figure}
However, this messes up the placement, as I have formated my listings
environment to look like this: http://stackoverflow.com/a/742069/1809175
Here is how it looks in the document:
I also tried two minipages in a figure environment but this results in
cryptic
Is there a best practice for placing different environments like listings
and figures side by side in the memoir class?
No comments:
Post a Comment