[comp.text.tex] Program listings with LaTeX

kevinwu@lionsgate.Eng.Sun.COM (Kevin Wu) (10/24/90)

Is it possible to include a program listing in a document typeset by
LaTeX such that the reserved words (if, else, while, do, ...) appear in
bold typewriter type style and most of the program listing appears in
normal typewriter type style?

I plan to submit a short article for a book next week.  The publisher
is asking contributors to submit camera-ready C programs typeset in the
style described above.  I haven't used LaTeX much since I wrote my
thesis three years ago, but now I have a need to typeset some math (in
addition to the C code) and I haven't seen anything better than LaTeX
for doing this.

Please reply by e-mail as I don't read this news group.  If there is no
easy solution with LaTeX, I'll have to use Framemaker.

Kevin

--
Kevin Wu				Internet:  kevinwu@Eng.Sun.COM
Sun Microsystems, Inc.			UUCP:      ...!sun!kevinwu@Eng
2550 Garcia Ave., MS MTV21-04		Phone:     (415) 336-6873
Mountain View, CA  94043		FAX:	   (415) 968-3936

kevinwu@lionsgate.Eng.Sun.COM (Kevin Wu) (10/25/90)

In article <1666@exodus.Eng.Sun.COM>, kevinwu@lionsgate.Eng.Sun.COM (Kevin Wu) writes:
> 
> Is it possible to include a program listing in a document typeset by
> LaTeX such that the reserved words (if, else, while, do, ...) appear in
> bold typewriter type style and most of the program listing appears in
> normal typewriter type style?

Thank you to all who responded to my query.

Most people suggested that I try tgrind.  I found it at rtsg.ee.lbl.gov.
People also said to look for it at june.cs.washington.edu and 
labrea.stanford.edu.

The description in the man page for tgrind begins with these paragraphs:

DESCRIPTION
     Tgrind formats program sources in a nice style using TeX(1).
     Comments  are  placed  in italics, keywords in bold face and
     strings in typewriter font.  Source file line numbers appear
     in  the right margin (every 10 lines).  The start of a func-
     tion is indicated by the function name in large type in  the
     right margin.

     In regular mode  tgrind  processes  its  input  file(s)  and
     passes them to TeX(1) for formatting and output.

One person suggested a set of TeX macros for C programs by Eamonn McManus 
(emcmanus@cs.tcd.ie) posted to this news group in March this year.

And finally, one person used LaTeX's tabbing environment and
defined macros for the reserved words.

--
Kevin Wu				Internet:  kevinwu@Eng.Sun.COM
Sun Microsystems, Inc.			UUCP:      ...!sun!kevinwu@Eng
2550 Garcia Ave., MS MTV21-04		Phone:     (415) 336-6873
Mountain View, CA  94043		FAX:	   (415) 968-3936

piet@cs.ruu.nl (Piet van Oostrum) (10/26/90)

>>>>> In article <1683@exodus.Eng.Sun.COM>, kevinwu@lionsgate.Eng.Sun.COM (Kevin Wu) (KW) writes:

KW> In article <1666@exodus.Eng.Sun.COM>, kevinwu@lionsgate.Eng.Sun.COM (Kevin Wu) writes:
> 
> Is it possible to include a program listing in a document typeset by
> LaTeX such that the reserved words (if, else, while, do, ...) appear in
> bold typewriter type style and most of the program listing appears in
> normal typewriter type style?

KW> Thank you to all who responded to my query.

KW> Most people suggested that I try tgrind.  I found it at rtsg.ee.lbl.gov.
KW> People also said to look for it at june.cs.washington.edu and 
KW> labrea.stanford.edu.

Note that there is also a LaTeX style file tgrind.sty for including the
tgrind output in LaTeX documents.
-- 
Piet van Oostrum <piet@cs.ruu.nl>