Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
1  
Are you sure that the code will fit in two column typesetting? –  egreg Nov 8 '11 at 12:10

3 Answers 3

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.

share|improve this answer

You can use the package multicol or you can switch your document via \twocolumn in the new mode:

\documentclass{report} 
\usepackage{listings}
\usepackage{multicol}
\usepackage{lipsum}
\begin{document}
\chapter{foo}
\lipsum[1]
\begin{multicols}{2}
\begin{lstlisting}[numbers=left,xleftmargin=3em]
First line.
Second line.
Third line.
Next line.
Next Line
Next line.
Next Line
Next line.
Next Line
Next line.
Next Line
\end{lstlisting}
\end{multicols}
\lipsum[2]
\clearpage
\twocolumn
\lipsum[1]
\lipsum[2]
\begin{lstlisting}[numbers=left,xleftmargin=3em]
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}
share|improve this answer

With the standard report class, you may use \twocolumn to switch to two column mode:

\documentclass[a5paper]{report}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{listings}

\begin{document}
\blinddocument
\appendix
\twocolumn
\chapter{Here and now! The two column listing}
\lstinputlisting[{language=[LaTeX]TeX},breaklines=true]{\jobname.tex}

\onecolumn
\chapter{One more chapter in one column mode}
\blindtext

\end{document}

But with this, you may not have additional one column text after the \chapter. With KOMA-Script \chapter may be used inside the optional argument of \twocolumn:

\documentclass[a5paper]{scrreprt}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{listings}

\begin{document}
\blinddocument
\appendix
\twocolumn[%
  \chapter{Here and now! The two column listing}
  \blindtext

  \vspace*{\baselineskip}
]


\lstinputlisting[{language=[LaTeX]TeX},breaklines=true]{\jobname.tex}

\onecolumn
\chapter{One more chapter in one column mode}
\blindtext

\end{document}

But there's a alround suggestion for the standard classes too: multicol

\documentclass[a4paper]{report}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{listings}
\usepackage{multicol}

\begin{document}
\blinddocument
\appendix
\chapter{Here and now! The two column listing}
\blindtext

\begin{multicols}{2}
\lstinputlisting[{language=[LaTeX]TeX},breaklines=true]{\jobname.tex}
\end{multicols}

\chapter{One more chapter in one column mode}
\blindtext

\end{document}

And this is indeed the same like

\documentclass[a4paper]{report}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{listings}
\usepackage{multicol}

\begin{document}
\blinddocument
\appendix
\chapter{Here and now! The two column listing}
\blindtext

\lstinputlisting[{language=[LaTeX]TeX},breaklines=true,multicols=2]{\jobname.tex}

\chapter{One more chapter in one column mode}
\blindtext

\end{document}

Note, that if you are using option multicols you have to load package multicol. Package listings does not load multicol itself!

For more information about \begin{multicols}{…}[…] please have a look at the package manual.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.