Formatting source lists with listings and frames

I am currently having a problem that an ad package cannot distribute source files across multiple pages. The document says that the package with the "frame" should be used for various formatting. Unfortunately, I did not find any documents for the "framed" package. My current source formatting looks like this for C # sources:

Formatting the source code http://www.free.image.hosting.net/uploads/88987a1ef4.png


Unfortunately, the image service no longer exists, and I cannot find this image because the post was published more than 5 years ago. I remember that part of the formatted source code that should be visible on the next page was simply truncated and not displayed at all.

My format for the "listings" package:

\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 someone help me achieve similar searches using the β€œframed” package or whatever, so that my source looks like this, but can be distributed between pages? An example of how to embed a listing in a frame will not be satisfactory since I was still myself.

+3
source share
2 answers

The listing package already supports code sharing between pages; see example below (sorry for the long list). Note that you cannot have a float that is paginated, so you need to use a signature package (for example) to insert a caption at the beginning of the environment lstlisting.

\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}
+2

.sty. :

\documentclass{article}
\usepackage{framed,lipsum}
\begin{document}
\begin{framed}
\lipsum[1-10]
\end{framed}
\end{document}

:

  • framed - - (\ fbox)
  • - (\ colorbox),
  • snugshade -
  • leftbar -

; , , .

+1

Source: https://habr.com/ru/post/1722286/


All Articles