[texhax] listings.sty question: how to implement single-spacing
martin f krafft
madduck at madduck.net
Tue Jun 16 17:41:49 CEST 2009
Hey folks,
I am using the wonderful listings.sty to typeset my code listings
for my thesis. Since I am using (have to use) double-spacing for the
flow text, I'd like to ensure single-spacing for listings to
conserve space, and because it actually increases the readability.
My attempts thus far have been foiled. The following does not work,
even though I can happily define the new environment with with
\lstnewenvironment if I don't try to use the singlespace environment
in its "constructor" and "destructor":
\documentclass{article}
\usepackage{listings,setspace}
\lstnewenvironment{mylisting}
{\begin{singlespace}\lstset{language=pascal}}
{\end{singlespace}}
\begin{document}
\begin{mylisting}
for i:=maxint to 0 do
begin
{ do nothing }
end;
\end{mylisting}
\end{document}
This gives me:
% latex l.tex
This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)
[...]
Package: `setspace' 6.7 <2000/12/01>
) (./l.aux) (/usr/share/texmf-texlive/tex/latex/listings/lstlang1.sty)
(/usr/share/texmf-texlive/tex/latex/base/omscmr.fd))
*
^--- cursor just stays here and I am in TeX command mode
Do you have any idea how to make it do what I want? How can
I typeset visually-appealing listings (with frames across multiple
pages, labels and captions, I don't care so much about syntax
highlighting) in singly-spaced?
Thanks,
--
martin | http://madduck.net/ | http://two.sentenc.es/
"wickedness is a myth
invented by good people
to account for the curious attraction of others."
-- oscar wilde
spamtraps: madduck.bogus at madduck.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature (see http://martin-krafft.net/gpg/)
URL: <http://tug.org/pipermail/texhax/attachments/20090616/a676323c/attachment.bin>
More information about the texhax
mailing list