[Tex/LaTex] Two column code listings in appendix in a one column report

appendicesformattingtwo-column

How do I place a two column appendix in a single column report? I want it so that at the beginning of the appendix I'm in single column mode, then I want to place some source code listings in 2 column format within my appendix.

Thanks

Best Answer

For multi-column typesetting of listings the listings package provides the multicols=n option, which in fact is a built-in interface to the multicol package.

\documentclass{report} 
\usepackage{listings,multicol}
\usepackage{lipsum}
\begin{document}
\chapter{foo}
\lipsum[1]
\begin{lstlisting}[numbers=left,xleftmargin=3em, multicols=2]
First line.
Second line.
Third line.
Next line.
Next Line
Next line.
Next Line
Next line.
Next Line
Next line.
Next Line
\end{lstlisting}
\lipsum[2]
\end{document}

Note that you have to load multicol explicitly with \usepackage{multicol} in the preamble.