\floatstyle{ruled} \newfloat{Prog}{thp}{lop} \floatname{Prog}{Listing} \newenvironment{program} { \begin{Prog} \renewcommand{\baselinestretch}{1.0} \vspace{0.1cm} } { \end{Prog} } \newcounter{tmp} \newcommand{\CompareWithSize}[4] { \begin{Prog} \setcounter{tmp}{\theProg} \addtocounter{tmp}{1} \renewcommand{\baselinestretch}{1.0} \centering \begin{tabular}{l||l} \begin{minipage}{#3} \vspace{0.1cm} \UseVerbatim{Side1} \end{minipage} & \begin{minipage}{#4} \vspace{0.1cm} \UseVerbatim{Side2} \end{minipage} \\ {\small \hfill \thetmp.1} & {\small \hfill \thetmp.2} \end{tabular} \caption{#1} \label{#2} \end{Prog} } \newcommand{\compare}[2]{\CompareWithSize{#1}{#2}{6.6cm}{6.6cm}} % use \compare to compare two listings side-by-side; follow an % example of use; note that the two listings need to be saved as Side1 % and Side2 %\begin{SaveVerbatim}{Side1} % for i in range(10): % print i %\end{SaveVerbatim} %\begin{SaveVerbatim}{Side2} % import sys % print sys.path %\end{SaveVerbatim} %\compare{caption}{label}