0

I want to include a file with Haskell code to my LaTeX document.

Unfortunately, the code taking to much space, so I wanted to rotate it to have a landscape format, but somewhat, the code is almost disappearing.

Moreover the code should take about 3-4 pages, but only one shows up. What can I do?

Here is my code:

\documentclass[12pt, a4paper, left=2.5cm, right=2.5cm, top=2.5cm, bottom=2cm]{report}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[ngerman, english]{babel}
\usepackage{graphicx} 
\usepackage{setspace}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{amssymb}
\usepackage{array}
\usepackage{colortbl}
\usepackage{float}
\usepackage[lstlang=haskell]{listings}
\usepackage{rotating}
\usepackage[square]{natbib}

\bibliographystyle{unsrt}

\parindent 0pt    

\begin{document}

\begin{rotate}{90}
\lstset{\tiny, commentstyle=\color{blue}, flexiblecolumns=true}
\lstinputlisting[language=Haskell, caption={Haskell Code}]{Code.hs}
\end{rotate}

\end{document}
2

For this code solution, I just downloaded some Haskell code from the libraries and saved it local in Code.hs. I also removed everything except what is needed to solve your problem.

First, use lscape not `rotating'

You can visit the documention for both at http://texdoc.net just type the name of the package and select the documentation. The later package only works on one page, so your code is too long for it.

Second, check the documentation

For the listings package the options are all keyvalues. So you have to say basicstyle=\tiny and not just \tiny.

Third, try xcolor not colortbl

When using colors an appropriate color package needs to be loaded. Personally, I find that the package xcolor causes the least conflicts.

It now runs for me fine. And, I have attached only the beginning of the output.

You now can build up your desired document a piece at a time. Suggestion for debugging LaTeX problem. Isolate the code and problem as I did and test it a piece at a time, with the documentation reviewed for correct syntax.

\documentclass[12pt, a4paper, left=2.5cm, right=2.5cm, top=2.5cm, bottom=2cm]{report}
\usepackage[ngerman, english]{babel}
\usepackage{xcolor,listings,lscape}
\begin{document}
\begin{landscape}
\lstset{basicstyle=\tiny,  commentstyle=\color{blue},flexiblecolumns=true}%
\lstinputlisting[language=Haskell, caption={Haskell Code}]{Code.hs}
\end{landscape}
\end{document}

enter image description here

0

I dont believe, that this is a MWE. Please provide an example for the next time.

\documentclass[12pt, a4paper, left=2.5cm, right=2.5cm, top=2.5cm, bottom=2cm]{report}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[ngerman, english]{babel}
\usepackage{graphicx} 
\usepackage{setspace}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{amssymb}
\usepackage{array}
\usepackage{colortbl}
\usepackage{float}
\usepackage[lstlang=haskell]{listings}
\usepackage{rotating}
\usepackage[square]{natbib}
\usepackage{pdflscape}

\bibliographystyle{unsrt}

\parindent 0pt    

\begin{document}

% \begin{rotate}{90}
\begin{landscape}
\lstset{\tiny, commentstyle=\color{blue}, flexiblecolumns=true}
\lstinputlisting[language=Haskell, caption={Haskell Code}]{Code.hs}
\end{landscape}
% \end{rotate}

\end{document}

I dont know the content of the codefile.

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.