Hello,
I'm trying to figure out a nice way of putting a code block next to a graphic inside a figure. The reason I want to do this is the code block on the left is an example, and the graphic on the right would be a picture of the memory layout.
I've tried a couple of different things. For example, I tried subfigure, which didn't work. What I tried was (where lstlisting is part of listings.sty for typesetting code):
\begin{figure}
\subfigure[]{
\begin{lstlisting}
code
\end{lstlisting}
}
\subfigure[]{
\includegraphic{picture}
}
\end{figure}
I've also tried minipage, but there are some problems there. First, it requires manually specifying how much space each figure gets instead of figuring it out automatically. Second, there seems to be a large gap between figures. Also, I'm not sure what the total size is (it doesn't seem to be \linewidth, because making each figure .5\linewidth always causes the figures ot be stacked instead of side-by-side).
What I tried was:
\begin{figure}
\begin{minipage}[t]{.4\linewidth}
\begin{lstlisting}
code
\end{lstlisting}
\end{minipage}
\begin{minipage}[t]{.4\linewidth}
\includegraphics{picture}
\end{minipage}
\end{figure}
Is there a nice way to put code next to a graphic as part of one larger figure?
Thanks,
David
General ⇒ Code Block and Graph side-by-side
NEW: TikZ book now 40% off at Amazon.com for a short time.
