I'm using lstlisting and subfig to place to code examples next to each other. However the frame of the listings, whether I use single frame or bottomline, always runs to the end of the line. So the left listing's frame goes through the right listing's frame.
I can use the 'linewidth' parameter of listings to set the width of frame. However this is prone to error. I have to tune the linewidth and space between the two listings, according to the listing's sizes.
I would rather have the listings package just wrap its frame around the listing, and use the frame as the outer bounding box of the listing, so that is doesn't collide with other listings.
Is that possible?
Thanks.
The current code I have is:
Code: Select all
\begin{figure}[H]
\centering
\begin{SubFloat}{\label{fig:beforeloopfusion}Before loop fusion}
\begin{lstlisting}[boxpos=b,frame=single,rulesep=1cm, framexrightmargin=0cm, xrightmargin=0cm]
...
\end{lstlisting}
\end{SubFloat}
%
\hspace{2cm}
%
\begin{SubFloat}{\label{fig:afterloopfusion}After loop fusion}
\begin{lstlisting}[boxpos=b,frame=single,linewidth = 4cm]
...
\end{lstlisting}
\end{SubFloat}
\end{figure}