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.

I have a

\documentclass[11pt, 12pt, oneside, twocolumn, fleqn, leqno]{book}

which was given to us by our professor. My problem is, he want us to put the LaTex Code inside the pdf document that will be passed to him as the output. So I have tried:

\begin{landscape}
\begin{widetext}
\begin{lstlisting}[label=Preface,caption=Latex Code]
Latex code goes here
\end{lstlisting}
\end{widetext}
\end{landscape}

Now I have two problems in this scenario. 1.) I cannot seem to put the excess words of the latex code into a new landscape page and then the other one is 2.) the widetext function doesn't seem to work here.

share|improve this question
add comment

2 Answers

somewhat to my surprise, the \verbatiminput command works inside a figure.

so, provided you can divide up your source code into chunks each of which will fit on one page (portrait mode), you can do something like this, using the full-width figure* environment:

in the preamble: \usepackage{verbatim}

in the main file:

\begin{document

\input{file1}
\input{file2}

\begin{figure*}
\small
\verbatiminput{jobname.tex}
\end{figure*}
\begin{figure*}
\small
\verbatiminput{file1.tex}
\end{figure*}
\begin{figure*}
\small
\verbatiminput{file2.tex}
\end{figure*}

\end{document}

it's something of a hack, but portrait presentation of code looks better to me than landscape. to shorten the main file, you could even pack all the figure* commands into a separate "appendix" file with a short introductory text, and \verbatiminput the appendix file as the last thing.

share|improve this answer
add comment

use

\onecolumn
\begin{landscape} 
\begin{lstlisting}[label=Preface,caption=Latex Code,
  xrightmargin=-...,xleftmargin=-...  %%%% only if needed for more space
  ] 

 Latex code goes here 

\end{lstlisting} 
\end{landscape}

\twocolumn

or do you mean the landscape format into only one column of a two column page?

share|improve this answer
add comment

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.