I currently have a problem, that listings package cannot spread source files across multiple pages. In the doc is written, that the "framed" package should be used for various formatting option. Unfortunately I did not find any docs for the "framed" package. My current source formatting looks like this for C# sources:
Source Formatting http://www.free.image.hosting.net/uploads/88987a1ef4.png
My formatting for "listings" package is:
\newcommand{\sourceFormatterCSharp}
{
\lstset
{ language=[Sharp]C
, captionpos=b
%, frame=lines
, morekeywords={var, get, set}
, basicstyle=\footnotesize\ttfamily
, keywordstyle=\color{blue}
, commentstyle=\color{darkgreen}
, stringstyle=\color{darkred}
, backgroundcolor=\color{lightgrey}
, numbers=left
, numberstyle=\scriptsize
, stepnumber=2
, numbersep=5pt
, breaklines=true
, tabsize=2
, showstringspaces=false
, emph={double, bool, int, unsigned, char, true, false, void, get, set}
, emphstyle=\color{blue}
, emph={Assert, Test}
, emphstyle=\color{red}
, emph={[2]\#using, \#define, \#ifdef, \#endif}
, emphstyle={[2]\color{blue}}
, frame=shadowbox
, rulesepcolor=\color{grey}
, lineskip={-1.5pt} % single line spacing
}
}
% first optional param is placement
% param1 file name without extension
% param2 chapter number, e.g. 1 or 2 ...
% param3 caption to use
\newcommand{\embedCSharp}[4][htbp]
{
\sourceFormatterCSharp
\includeListing{#1}{#4}{#3:#2}{#3/#2.cs}
}
Can anybody help me achieving similar looking results using "framed" package or any other for my source to look like this but be distributable across pages? An example how to embed a listing in the frame would not satisfy, since I was so far myself.
The listings package already supports splitting code across pages; see example below (sorry about the long listing). Note that you cannot have a float that breaks across pages, so you'll need to use the caption package (for example) to insert a caption at the beginning of the lstlisting
environment.
\documentclass{article} \usepackage[a5paper,landscape]{geometry} \usepackage{xcolor,listings} \begin{document} \definecolor{lightgrey}{gray}{0.8} \lstset { captionpos=b , backgroundcolor=\color{lightgrey} , numbers=left , numberstyle=\scriptsize , stepnumber=2 , numbersep=5pt , frame=shadowbox , rulesepcolor=\color{gray} } \begin{lstlisting} a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z \end{lstlisting} \end{document}