答案1
该示例是使用该fancyvrb
包生成的。您可以将代码放在两个minipage
行中并模仿两列布局。另请注意,行号有些错位;下面附有解决方案。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{zlmtt}
\usepackage{fancyvrb}
\begin{document}
\noindent
\begin{minipage}{0.49\linewidth}
\begin{Verbatim}[frame=topline,numbers=left,label=Original Code,framesep=3mm]
class C {
public X x = new X();
public void f() {
...
}
}
\end{Verbatim}
\end{minipage}\hfill
\begin{minipage}{0.49\linewidth}
\begin{Verbatim}[frame=topline,numbers=left,label=After Extract Local,framesep=3mm]
class c {
public X x = new X();
public void f(){
...
}
}
\end{Verbatim}
\end{minipage}
\par\vspace{3ex}
\noindent
\begin{minipage}{0.49\linewidth}
\begin{Verbatim}[frame=topline,numbers=right,label=Original Code,framesep=3mm,numbersep=-4pt]
class C {
public X x = new X();
public void f() {
...
}
}
\end{Verbatim}
\end{minipage}\hfill
\begin{minipage}{0.49\linewidth}
\begin{Verbatim}[frame=topline,numbers=right,label=After Extract Local,framesep=3mm,numbersep=-4pt]
class c {
public X x = new X();
public void f(){
...
}
}
\end{Verbatim}
\end{minipage}
\end{document}