How to Use SLaTeX

 Dorai Sitaram 
 Download Version 20090928 

SLaTeX is a Scheme program that allows you to write programs or program fragments “as is” in your TeX or LaTeX source. It is particularly geared to the programming languages Scheme and other Lisps, eg, Common Lisp. The formatting of the code includes assigning appropriate fonts and colors to the various tokens in the code (keywords, variables, constants, data), at the same time retaining the proper indentation when going to the non-monospace (non-typewriter) fonts provided by TeX. SLaTeX comes with two databases that recognize the identifier conventions of Scheme and Common Lisp respectively. These can be modified by the user with easy TeX commands. In addition, the user can tell SLaTeX to typeset certain identifiers as specially suited TeX expressions (ie, beyond just fonting them). All this is done without interfering with the identifier conventions of the language of the programming code. In sum, no change need be made to your (presumably running) program code in order to get a typeset version with a desired look: You can get a spectrum of styles ranging from no fonting through basic default fonting to various “mathematical”-looking output for pedagogic or other reasons.

Popular packages for typesetting Scheme code, eg, Queinnec’s LiSP2TeX [6] and Ramsdell’s SchemeWeb [7], use a verbatim-like environment where all the characters are in a monospace typewriter font. While the monospace ensures that the indentation is not affected, it fails to distinguish between the various tokens used in the code. On the other hand, SLaTeX can font- or even color-code1 the tokens, eg, boldface and/or red for keywords like define and lambda, sans-serif and/or green for constants like #t and 42, and italics and/or blue for variables such as x and y in (lambda (x y) (cons x (cons y '()))). SLaTeX provides a convenient way of capturing the indentation information as well as assigning distinguishing fonts to code tokens without requiring the user to worry about fonting and spacing. It uses temporary files to store its typeset version of the user’s code fragments and then calls TeX or LaTeX on the user’s TeX files as well as these temporaries.

The rest of this manual has the following outline:

        1  Introductory example
        2  The SLaTeX style files
        3  SLaTeX’s control sequences
        4  Resetting SLaTeX’s defaults
        5  Obtaining and installing SLaTeX
        6  References
        7  Index


1 To get color, you need a dvi driver such as Rokicki’s dvips and a color printer. If you don’t have a color printer, you can still view your color-coded document on screen, but will have to settle for grayscaling on your paper output.

Last modified: Sat, Oct 3, 2009, 6:43 pm UTC−5 +1