I am trying to include some code files in landscape mode into my document which is in portrait mode. I do this using the
\usepackage{lscape}
and
\usepackage{listings}
So far so good. The problem kicks in when a new section begins. The heading is shown in portrait mode (which is fine!) followed by a blank page. On the next page the code appears. Is it possible to combine the portrait mode heading with the landscape mode code on one page? Below is a little example
\documentclass[12pt,a4paper,leqno]{book}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\usepackage{lscape}
\begin{document}
\section*{This is a section}
\begin{landscape}
\begin{lstlisting}
and here comes the code
\end{lstlisting}
\end{landscape}
\end{document}
\documentclass{...}
and ending with\end{document}
.lscape
this is not possible. If you have some textbefore or after thelstlisting
environment, you may use theafterpage
package to fill in the space aftersection*
.