我最近从 Debian stretch(旧稳定版)升级到了 Debian buster(稳定版)。除其他外,该软件包texlive-latex-extra
(包含该listing
软件包)已升级从2016.20170123-5
到2018.20190227-2
。从那时起,编译文档会在列表前添加额外的空间。
最小示例:
\documentclass{article}
\usepackage{lipsum}
\usepackage{listings}
\begin{document}
\lipsum[1]
\begin{lstlisting}[basicstyle=\ttfamily,frame=single]
this is a listing
with two lines
\end{lstlisting}
\lipsum[2]
\end{document}
使用 Debian stretch 编译,列表前没有多余的空格:
使用 Debian buster 编译,列表前有额外的空格:
我尝试设置abovesep
和belowsep
,但那里定义的空间只是增加了列表上方的空间。
我怎样才能删除列表前的额外空格?谢谢!
根据下面的评论,我使用beforedaleif
重新编译了 Debian 稳定版(添加了额外空间)上的文档,以查看所有版本信息。 listings 包的版本为:\listfiles
\documentclass
2018/09/02 1.7
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian) (preloaded format=pdflatex 2019.7.25) 30 AUG 2019 16:36
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**test.tex
(./test.tex
LaTeX2e <2018-12-01>
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2018/09/03 v1.4i Standard LaTeX file (size option)
)
\c@part=\count80
\c@section=\count81
\c@subsection=\count82
\c@subsubsection=\count83
\c@paragraph=\count84
\c@subparagraph=\count85
\c@figure=\count86
\c@table=\count87
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
(/usr/share/texlive/texmf-dist/tex/latex/listings/listings.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks14
)
\lst@mode=\count88
\lst@gtempboxa=\box27
\lst@token=\toks15
\lst@length=\count89
\lst@currlwidth=\dimen103
\lst@column=\count90
\lst@pos=\count91
\lst@lostspace=\dimen104
\lst@width=\dimen105
\lst@newlines=\count92
\lst@lineno=\count93
\lst@maxwidth=\dimen106
(/usr/share/texlive/texmf-dist/tex/latex/listings/lstmisc.sty
File: lstmisc.sty 2018/09/02 1.7 (Carsten Heinz)
\c@lstnumber=\count94
\lst@skipnumbers=\count95
\lst@framebox=\box28
)
(/usr/share/texlive/texmf-dist/tex/latex/listings/listings.cfg
File: listings.cfg 2018/09/02 1.7 listings configuration
))
Package: listings 2018/09/02 1.7 (Carsten Heinz)
No file test.aux.
\openout1 = `test.aux'.
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
\c@lstlisting=\count96
[1
{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] (./test.aux)
*File List*
article.cls 2018/09/03 v1.4i Standard LaTeX document class
size10.clo 2018/09/03 v1.4i Standard LaTeX file (size option)
listings.sty 2018/09/02 1.7 (Carsten Heinz)
keyval.sty 2014/10/28 v1.15 key=value parser (DPC)
lstmisc.sty 2018/09/02 1.7 (Carsten Heinz)
listings.cfg 2018/09/02 1.7 listings configuration
***********
)
Here is how much of TeX's memory you used:
1826 strings out of 492615
23459 string characters out of 6131390
83138 words of memory out of 5000000
5809 multiletter control sequences out of 15000+600000
3808 words of font info for 15 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
26i,4n,32p,151b,1010s stack positions out of 5000i,500n,10000p,200000b,80000s
</usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr
/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmtt10.pfb>
Output written on test.pdf (1 page, 27204 bytes).
PDF statistics:
16 PDF objects out of 1000 (max. 8388607)
10 compressed objects within 1 object stream
0 named destinations out of 1000 (max. 500000)
1 words of extra memory for PDF output out of 10000 (max. 10000000)
答案1
listings
事实证明,Debian 稳定版上的软件包 ( )版本2018/09/02 1.7
包含一个错误。这也在此处描述:列出之前有额外的空间(Debian stretch 与 buster)?
那里提出的解决方案对我来说不起作用(我没有让它工作\lst@AddToHook
),但根据用户的建议siracusa
,listings
可以将包本地安装到与文档相同的目录中,如下所示:
- 从这里下载
listings.ins
、listings.dtx
和:lstdrvrs.dtx
https://www.ctan.org/texarchive/macros/latex/contrib/listings - 通过运行提取文件
etex listings.ins
- 通过运行照常编译文档,首选
pdflatex
本地版本的包listings
谢谢您的帮助和提示!:)