使用列表和列表格式化源列表框架包
我目前遇到一个问题,列表包无法跨多个页面传播源文件。在文档中写道,“框架”包应该用于各种格式化选项。不幸的是我没有找到“framed”包的任何文档。对于 C# 源,我当前的源格式如下所示:
源格式 http://www .free.image.hosting.net/uploads/88987a1ef4.png
不幸的是,图像服务不再存在,我找不到该图像,因为该帖子是 5 年前发布的。我记得的是,格式化的源代码部分,应该在下一页上可见,只是被截断了,根本没有显示出来。
我对“listings”包的格式是:
\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}
}
任何人都可以帮助我使用“framed”包或任何其他包来实现相似的外观结果,使我的源看起来像这样但可以跨页面分发吗? 如何在框架中嵌入列表的示例并不能令人满意,因为到目前为止我自己也是如此。
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
Unfortunately the image service no longer exists and I can't find that image, since the post was posted more than 5 years ago. What I remember is that the formatted source code part, which should be visible on the next page, was just truncated and did not show up at all.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
列表包已经支持跨页面拆分代码;请参阅下面的示例(抱歉清单太长)。请注意,您不能使用跨页面的浮动,因此您需要使用标题包(例如)在
lstlisting
环境的开头插入标题。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.框架文档位于 .sty 文件本身内。只需像这样使用它:
从文档中,您还可以使用:
在上面的示例中放置您的列表而不是lipsum将允许多页代码,并且所有代码都带有框架;您将无法获得与列表相同的输出,但应该能够进行调整以使事情看起来不错。
The framed documentation is within the .sty file itself. Just use it like this:
From the docs, you can also use:
Putting your listings instead of lipsum in the example above will allow multiple pages of code with a frame around it all; you won't be able to get identical output to listings, but should be able to tweak things to get things looking okay.