1

How can I divide my page in two to show my code with lstlisting? This is a large code and I want to set as 2 pages in one. Is an appendix of my project not all the document.

EDIT

thanks to Bordaigorl I set it to double column but when I add \landscape option this is my result:

enter image description here

  • You could use \twocolumn in your appendix to switch to a two column display. In that way you do not need to break your code in minipages manually – Bordaigorl Dec 17 '13 at 10:58
  • Thanks, how can I set it to landscape because with \landscape it doesnt works properly :/ I attached an image – tato469 Dec 17 '13 at 11:05
  • 1
    Good point. I suggest you have a look at the geometry package, I think that handles twocolumns correctly. – Bordaigorl Dec 17 '13 at 11:14
  • Ok I will take a look – tato469 Dec 17 '13 at 11:18
  • How do you allow rotated (so technically normal) content on landscape pages ? (comment answer below) @Bordaigorl: Can you achiev this with geometry? Including geometry package changes the page layout -even without any additional parameters- in a way that I would like to avoid. – gr4nt3d Apr 11 '15 at 14:29
4

A simple solution would be to switch to a two columns layout for the appendix. Unfortunately the \twocolumn macro does not play well with packages to switch to landscape mode mid-document. The geometry package solves the problem for whole-document layout but it cannot switch to landscape mid-document.

A solution achieving both two columns and landscape for a section of the document can be obtained using the packages lscape (or pdflscape) and multicol:

\documentclass{article}

\usepackage{lipsum} % just for the demo

\usepackage{listings}
\usepackage{multicol}
\usepackage{pdflscape}

\begin{document}

\lipsum

\begin{landscape}
\begin{multicols}{2}
\begin{lstlisting}
very long code
\end{lstlisting}
\end{multicols}
\end{landscape}


\end{document}
  • How do you allow rotated (so technically normal) content on landscape pages ? - I'd like to put chapter (appendix) and section headings at the top of the page in normal vertical-paper style. Landscape does not allow me to start code on the same page as my chapter heading (modifies next page). – gr4nt3d Apr 11 '15 at 14:18
  • @hillbilly you could try with \rotatebox but for a specific situation I would suggest you post a new question with a MWE – Bordaigorl Apr 12 '15 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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