~ chicken-core (master) /tests/test.tex
Trap1%slatex-d.tex2%SLaTeX Version 23%Documentation for SLaTeX4%(c) Dorai Sitaram, 1991, 19945%dorai@cs.rice.edu67\documentstyle[slatex]{article}89\slatexdisable{enableslatex}1011\edef\atcatcodebeforepreamble{\the\catcode`@}12\catcode`@111314\inputifpossible{multicol.sty}1516%if Frank Mittelbach's multicol.sty is not17%available, the index will simply waste some paper1819%latex wastes too much paper, so...2021\textheight 11in22\textwidth 8.5in23\oddsidemargin 1.25in24\advance\textheight -2\oddsidemargin25\advance\textwidth -2\oddsidemargin26\advance\oddsidemargin -1in27\evensidemargin\oddsidemargin28\topmargin\oddsidemargin29\advance\topmargin -\headheight30\advance\topmargin -\headsep3132%latex's section headings are way too obnoxiously33%large, so...3435\def\nolargefonts{\let\large\normalsize36\let\Large\normalsize37\let\LARGE\normalsize38\let\huge\normalsize39\let\Huge\normalsize}4041%mini headers for introducing paragraphs4243\def\re{\medbreak\parindent0pt%44\aftergroup\smallskip\obeylines45\llap{$\searrow$\enspace\enspace}}4647%a wide line4849\def\wideline{\centerline{\hrulefill}}5051%smart italics5253\def\italicsbegin{\begingroup\it}54\def\italicsend{\endgroup\futurelet\next\italiccorrection}55\def\italiccorrection{\ifx\next,\else\ifx\next.\else\/\fi\fi}56\def\italicstoggle{\italicsbegin\let\italicstoggle\italicsend}57\catcode`\_\active58\def_{\ifmmode\sb\else\expandafter\italicstoggle\fi}5960%quote.tex, by Hunter Goatley6162{\catcode`\"\active63%64\gdef\begindoublequotes{\global\catcode`\"\active65\global\let\dblqu@te=L}66%67\gdef"{\ifinner\else\ifvmode\let\dblqu@te=L\fi\fi68\if L\dblqu@te``\global\let\dblqu@te=R\else69\let\xxx=\spacefactor70''\global\let\dblqu@te=L%71\spacefactor\xxx72\fi}}7374\def\enddoublequotes{\catcode`\"=12}7576%nicer \verb7778\begingroup\catcode`[1\catcode`]2\catcode`\{12\catcode`\}12%79\gdef\@sverb#1[\if#1{\def\@tempa##1}[\leavevmode\null##1\endgroup]\else80\def\@tempa##1#1[\leavevmode\null##1\endgroup]\fi\@tempa]%81\endgroup8283%nicer \footnote8485\let\latexfootnote\footnote86\def\footnote{\unskip\latexfootnote\bgroup\let\dummy=}8788%item8990\let\o\item9192%index environment that exploits multicol.sty if93%available...9495\renewenvironment{theindex}%96{\parindent0pt%97\let\item\@idxitem98\section*{Index}%99\ifx\multicols\undefined\else100\begin{multicols}{2}\fi}%101{\ifx\multicols\undefined\else102\end{multicols}\fi}103104\catcode`@\atcatcodebeforepreamble105106\begindoublequotes107\makeindex108109%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%110111\title{How to Use SLaTeX}112113\author{Dorai Sitaram\\114{\tt dorai@cs.rice.edu}\\115Department of Computer Science\\116Rice University\\117Houston, TX 77251--1892}118119\date{Gestated 1990\\120First public release, Mar. 1991\\121First major update, Dec. 1991\\122Current update, Jan. 1994}123124\begin{document}125\maketitle126\nolargefonts127128\section{Introduction}129130SLaTeX\index{introduction} is a Scheme program131that allows you to write programs or program fragments132"as is" in your TeX or LaTeX source. SLaTeX is133particularly geared to the programming languages Scheme134and other Lisps, e.g., Common Lisp. The formatting of135the code includes assigning appropriate fonts to the136various tokens in the code (keywords, variables,137constants, data), at the same time retaining the proper138indentation when going to the non-monospace139(non-typewriter) fonts provided by TeX. SLaTeX comes140with two databases that recognize the identifier141conventions of Scheme and Common Lisp respectively.142These can be modified by the user using easy TeX143commands. In addition, the user can inform SLaTeX to144typeset certain identifiers as specially suited LaTeX145expressions (i.e., beyond just fonting them). All this146is done without interfering with the identifier147conventions of the language of the programming code at148all. In sum, no change need be made to your149(presumably running) program code in order to get a150typeset version suited to the particular need: you can151get a spectrum of styles ranging from _no_ fonting152through basic default fonting to various153"mathematical"-looking output for pedagogic or other154reasons.155156\enableslatex157Other packages~\cite{schemeweb,lisp2tex} for158typesetting code fragments use a \verb{verbatim}159environment where all the characters are in a160\verb{monospace typewriter font}. This \verb{monospace}161ensures that the indentation is not affected. However,162the resulting output fails to distinguish between the163various tokens used in the code, e.g., boldface for164keywords like165\scheme{define} and \scheme{lambda}, sans-serif for166constants like \scheme{#t} and \scheme{42}, and italics167for variables such as \scheme{x} and168\scheme{y} in \scheme{(lambda (x y) (cons x (cons y169'())))}.170\slatexdisable{enableslatex}171172The program SLaTeX provides a convenient way of173capturing the indentation information as well as174assigning distinguishing fonts to code tokens without175requiring the user to worry about fonting and spacing.176It uses temporary files to store its typeset version of177the user's code fragments and then calls TeX or LaTeX178on the user's TeX files as well as these temporaries.179180The following section will introduce you to the basic181use of SLaTeX with a small example.182Section~\ref{slatex.sty} introduces the SLaTeX style183files. Section~\ref{glossary} gives a complete184description of all the SLaTeX control sequences. These185include commands for manipulating output positioning,186enhancing the database, changing the fonting defaults,187adding special symbols, and selective disabling of188SLaTeX. Section~\ref{preamble} desribes how to set up189a preamble that reflects your typesetting taste.190Section~\ref{ftp} contains information on obtaining and191installing SLaTeX.192193\section{A quick illustration of using SLaTeX}194\label{quick}195\index{quick illustration}196197This section presents a short example of SLaTeX use.198We first look at a LaTeX file using SLaTeX commands,199and then give a plain TeX version of the same file. We200will see that there are minor differences between the201ways SLaTeX is used with plain TeX and LaTeX (but see202\verb{\defslatexenvstyle} for a way to use the203plain-TeX style with the LaTeX format, and conversely,204the LaTeX style with the plain format).205206\subsection{For LaTeX users}207\index{LaTeX}208\index{scheme@\verb{\scheme}}209\index{schemedisplay@\verb{schemedisplay}!in LaTeX}210\index{in-text Scheme code}211\index{displayed Scheme code}212\index{slatex.sty@\verb{slatex.sty}}213\index{slatex.sty@\verb{slatex.sty}!as document style}214215Consider the following LaTeX (_and_ SLaTeX) file216\verb{quick.tex}:217218\wideline219\begin{verbatim}220% quick.tex221\documentstyle[slatex]{article}222%or:223% \documentstyle{article}224% \input slatex.sty225226In Scheme, the expression \scheme|(set! x 42)| returns227an unspecified value, rather than \scheme'42'.228However, one could get a \scheme{set!} of the latter229style by:230231\begin{schemedisplay}232(define-syntax setq233 (syntax-rules ()234 [(setq x a)235 (begin (set! x a)236 x)]))237\end{schemedisplay}238239\end{document}240\end{verbatim}241\wideline242243First, the SLaTeX definitions in the style file244\verb{slatex.sty} are loaded into your LaTeX file ---245this may be done either as a \verb{\documentstyle}246option, or through an \verb{\input} command.247248\index{scheme@\verb{\scheme}!using grouped argument}249250In-text code is introduced by the SLaTeX control251sequence \verb{\scheme} and is flanked by a pair of252identical characters that are not alphabets or253"\verb|{|". As a special convenient case, SLaTeX also254allows the form \verb|\scheme{...}|.255256The SLaTeX control sequences for displayed code are the257opening \verb|\begin{schemedisplay}| and the closing258\verb|\end{schemedisplay}|.259260The file is now SLaTeX'd by running the command261\verb{slatex} on it from the Unix or DOS command line:262263\begin{verbatim}264slatex quick265\end{verbatim}266or267\begin{verbatim}268slatex quick.tex269\end{verbatim}270This calls a Scheme program \verb{slatex.scm} that271typesets the Scheme code fragments in \verb{quick.tex}272into temporary files. Thereafter, \verb{quick.tex} along with273the temporary files are then passed to LaTeX. (For274information on judiciously reusing temporary files, see275\verb{\slatexseparateincludes}.)276The resulting277\verb{quick.dvi} file, when viewed or printed looks like:278279\enableslatex280\wideline281In Scheme, the expression \scheme|(set! x 42)| returns282an unspecified value, rather than283\scheme'42'. However, one could get a \scheme{set!} of284the latter style by:285286\begin{schemedisplay}287(define-syntax setq288 (syntax-rules ()289 [(setq x a)290 (begin (set! x a)291 x)]))292\end{schemedisplay}293\wideline294295\index{recognizing new syntactic keywords automatically}296297Note that \scheme{setq}, although not normally a298syntactic keyword in Scheme is nevertheless299automatically recognized as such because of the context300in which it occurs. No special treatment is needed to301ensure that it will continue be treated as such in any302subsequent Scheme code in the document.303304\slatexdisable{enableslatex}305306\subsection{For plain TeX users}307\index{plain TeX}308\index{scheme@\verb{\scheme}}309\index{schemedisplay@\verb{schemedisplay}!in plain TeX}310\index{in-text Scheme code}311\index{displayed Scheme code}312313Plain TeX users invoke SLaTeX much the same way, but314for only two exceptions. First, since TeX doesn't have315\verb{\documentstyle}, the file \verb{slatex.sty} is316introduced via an \verb{\input} statement before its317commands can be used in the plain TeX source.318319\index{environments}320321Second, since plain TeX does not have LaTeX's322\verb|\begin{|_env_\verb|}...\end{|_env_\verb|}|323style of environments, any324environment commands in SLaTeX are invoked with the325opening \verb{\}_env_ and the closing \verb{\end}_env_.326327The plain TeX version of \verb{quick.tex} looks like:328329\wideline330\begin{verbatim}331% quick.tex332\input slatex.sty333334In Scheme, the expression \scheme|(set! x 42)| returns335an unspecified value, rather than \scheme'42'.336However, one could get a \scheme{set!} of the latter337style by:338339\schemedisplay340(define-syntax setq341 (syntax-rules ()342 [(setq x a)343 (begin (set! x a)344 x)]))345\endschemedisplay346347\bye348\end{verbatim}349\wideline350351The file is now SLaTeX'd by invoking \verb{slatex} as352before --- SLaTeX is clever enough to figure out353whether the file it operates on should later be send to354LaTeX or plain Tex.355356\section{The style files}357\label{slatex.sty}358\index{slatex.sty@\verb{slatex.sty}}359360In short, the LaTeX (or TeX) file that is given to361SLaTeX undergoes some code-setting preprocessing and is362then handed over to LaTeX (or TeX). The style file363\verb{slatex.sty} defines the appropriate commands so364that LaTeX (or TeX) can recognize the SLaTeX-specific365directives and either process or ignore them. You may366either \verb|\input| the file \verb{slatex.sty} as367usual, or use it as the \verb|\documentstyle| option368\verb{slatex}.369370\index{cltl.sty@\verb{cltl.sty}}371\index{SLaTeX database!for Scheme}372\index{SLaTeX database!for Common Lisp}373\index{SLaTeX database!modifying}374375The default database of SLaTeX recognizes the keywords376and constants of Scheme. The database can be modified377with the commands \verb{\setkeyword},378\verb{\setconstant}, \verb{\setvariable},379\verb{\setspecialsymbol} and \verb{\unsetspecialsymbol}380(q.v.). If you're using Common Lisp rather than381Scheme, use \verb{cltl.sty} instead of382\verb{slatex.sty}.383\verb{cltl.sty} loads \verb{slatex.sty} and modifies384the database to reflect Common Lisp. You may fashion385your own \verb{.sty} files on the model of386\verb{cltl.sty}.387388\section{SLaTeX's control sequences}389\label{glossary}390\index{SLaTeX control sequences}391392You've already seen the SLaTeX control sequence393\verb|\scheme| and the environment394\verb{schemedisplay}. These suffice for quite a few395instances of handling code. However, you will396occasionally require more control on the typesetting397process, and the rest of this section describes the398complete399\footnote{At least that's what you're supposed400to think...} list of SLaTeX control sequences shows you401the ropes.402403{\re404\verb{schemedisplay}}405\index{schemedisplay@\verb{schemedisplay}}406\index{displayed Scheme code}407408[In plain TeX: \verb{\schemedisplay} ...409\verb{\endschemedisplay}; in LaTeX:410\verb|\begin{schemedisplay}| ...411\verb|\end{schemedisplay}|; but see \verb{\defslatexenvstyle}.]412413Typesets the enclosed code, which is typically several414lines of code indented as you normally do in your415Scheme files. E.g.,416417\begin{verbatim}418\begin{schemedisplay}419(define compose ;this is also known as $B$420 (lambda (f g)421 (lambda (x)422 (apply f (g x)))))423\end{schemedisplay}424is the "compose" function.425\end{verbatim}426produces427428\enableslatex429\begin{schemedisplay}430(define compose ;this is also known as $B$431 (lambda (f g)432 (lambda (x)433 (apply f (g x)))))434\end{schemedisplay}435\slatexdisable{enableslatex}436is the "compose" function.437438As with all LaTeX environment enders, if the line after439\verb|\end{schemedisplay}| contains440non-whitespace text, the paragraph continues.441Otherwise --- i.e., when \verb|\end{schemedisplay}| is442followed by at least one blank line --- a fresh443paragraph is started. Similarly, in plain TeX, a fresh444paragraph is started after a \verb{schemedisplay} only445if446\verb|\endschemedisplay| is followed by at least one447blank line.448449\index{Scheme comments}450451Comments in Scheme are usually introduced by "\verb{;}"452(semicolon). The rest of the line after a "\verb{;}"453is set as a line in LaTeX LR mode.454455\index{TeX paragraphs amidst Scheme code}456457Separate _blocks_ of code can either be introduced in458different \verb{schemedisplay} environments or put in a459single \verb{schemedisplay} and separated by a line with460a "\verb{;}" in the first column. This "\verb{;}" is461not typeset and anything following it on the line is462set in (La)TeX LR paragraph mode. Consecutive lines463with "\verb{;}" in the first column are treated464as input for a TeX paragraph, with words possibly465moved around from line to line to ensure justification.466When in paragraph mode, the first line that has _no_467leading "\verb{;}" signals a fresh block468of Scheme code within the469\verb{schemedisplay}. (The \verb{schemedisplay} may470end, or commence, on either a paragraph or a Scheme471code block.)472473E.g.,474475\begin{verbatim}476\begin{schemedisplay}477(define even? ; testing evenness478 (lambda (n)479 (if (= n 0) #t (not (odd? (- n 1))))))480; The procedures {\it even?} above481; and {\it odd?} below are mutually482; recursive.483(define odd? ; testing oddness484 (lambda (n)485 (if (= n 0) #f (not (even? (- n 1))))))486\end{schemedisplay}487\end{verbatim}488produces489490\enableslatex491\begin{schemedisplay}492(define even? ; testing evenness493 (lambda (n)494 (if (= n 0) #t (not (odd? (- n 1))))))495; The procedures {\it even?} above496; and {\it odd?} below are mutually497; recursive.498(define odd? ; testing oddness499 (lambda (n)500 (if (= n 0) #f (not (even? (- n 1))))))501\end{schemedisplay}502\slatexdisable{enableslatex}503504SLaTeX can recognize that blocks of code are separate505if you have at least one empty line separating them.506I.e., there is no need for empty "\verb{;}" lines. This507convenience is to accommodate Scheme files where508definitions are usually separated by one or more blank509lines.510511\index{schemedisplay@\verb{schemedisplay}!allowing page512breaks in}513514Intervening paragraphs, either with lines with a515leading "\verb{;}", or with blank lines, are ideal516spots for \verb{schemedisplay} to allow pagebreaks. In517fact, the default setting for \verb{schemedisplay} also518allows pagebreaks _within_ a Scheme block, but it is519easy to disable this (see entry for520\verb{\rightcodeskip}).521522The space surrounding displayed Scheme code can be523modified by setting the _skip_s \verb{\abovecodeskip},524\verb{\belowcodeskip}, \verb{\leftcodeskip}, and525\verb{\rightcodeskip} (q.v.).526527Note: see \verb{schemeregion}.528529{\re530\verb{\scheme}}531\index{scheme@\verb{\scheme}}532\index{in-text Scheme code}533534Typesets its argument, which is enclosed in arbitrary535but identical non-alphabetic and non-\verb|{|536characters, as in-text code. Special case:537\verb|\scheme{...}| is a convenience (provided the538\verb|...| doesn't contain a539\verb|}|). E.g., \verb+\scheme|(call/cc (lambda (x) x))|+540and \verb+\scheme{(call/cc (lambda (x) x))}+ both541produce542\enableslatex543\scheme{(call/cc (lambda (x) x))}.544\slatexdisable{enableslatex}545\index{scheme@\verb{\scheme}!using grouped argument}546547\index{nesting SLaTeX control sequences}548It _is_ permitted to intermix calls to549\verb{schemedisplay} and550\verb|\scheme|. Thus,551552\begin{verbatim}553\begin{schemedisplay}554(define factorial555 (lambda (n)556 (if (= n 0) ; \scheme{(zero? n)} also possible557 1 (* n (factorial (- n 1)))))) ; or \scheme{... (sub1 1)}558\end{schemedisplay}559\end{verbatim}560produces561562\enableslatex563\begin{schemedisplay}564(define factorial565 (lambda (n)566 (if (= n 0) ; \scheme{(zero? n)} also possible567 1568 (* n (factorial (- n 1)))))) ; or \scheme{... (sub1 1)}569\end{schemedisplay}570\slatexdisable{enableslatex}571572Note: see \verb{schemeregion}.573574{\re575\verb{\schemeresult}}576\index{schemeresult@\verb{\schemeresult}}577578Typesets its argument, which is enclosed in arbitrary579but identical non-alphabetic and non-\verb|{|580characters, as in-text Scheme "result" or data: i.e.,581keyword and variable fonts are disabled. Special582convenient case (as for \verb|\scheme|):583\verb|\schemeresult{...}|. E.g.,584\index{schemeresult@\verb{\schemeresult}!using grouped argument}585586\begin{verbatim}587\scheme|((lambda () (cons 'lambda 'cons)))| yields588\schemeresult|(lambda . cons)|.589\end{verbatim}590produces591592\enableslatex593\scheme|((lambda () (cons 'lambda 'cons)))| yields594\schemeresult|(lambda . cons)|.595\slatexdisable{enableslatex}596597{\re598\verb{schemebox}}599\index{schemebox@\verb{schemebox}}600\index{boxed Scheme code}601602[In plain TeX: \verb{\schemebox} ...603\verb{\endschemebox}; in LaTeX:604\verb|\begin{schemebox}| ...605\verb|\end{schemebox}|; but see \verb{defslatexenvstyle}.]606607The \verb{schemebox} environment is similar to608\verb{schemedisplay} except that the code is provided609as a "box" (i.e., it is not "displayed" in the standard610way). Indeed, when the appropriate skip parameters are611set, \verb{schemedisplay} itself _may_612\footnote{Yes, _may_: Not all \verb{schemedisplay}s invoke613\verb{schemebox}, and if you're curious why,614see entry for \verb{\rightcodeskip}. It is a matter of615whether pagebreaks within Scheme code are allowed or616not.} use a617\verb{schemebox} to create a box of code that is618set off with all-round space as a display.619620Saving a \verb{schemebox} in an explicit box allows you621to move your typeset code arbitrarily.622623Note: see \verb{schemeregion}.624625{\re626\verb{\schemeinput}}627\index{schemeinput@\verb{schemeinput}}628\index{inputting Scheme files as is}629630This can be used to input Scheme files as typeset code.631(Unlike LaTeX's \verb|\input|, \verb|\schemeinput|'s632argument must always be grouped.) The Scheme file can633be specified either by its full name, or without its634extension, if the latter is \verb{.scm}, \verb{.ss} or635\verb{.s}. E.g.,636637\begin{verbatim}638\schemeinput{evenodd.scm} % the .scm is optional!639\end{verbatim}640(where \verb{evenodd.scm} is the name of a Scheme file641containing the code for642\enableslatex643\scheme{even?} and \scheme{odd?} above) produces the same644effect as the645\verb{schemedisplay} version.646\slatexdisable{enableslatex}647648Note: see \verb{schemeregion}.649650{\re651\verb{schemeregion}}652\index{schemeregion@\verb{schemeregion}}653\index{nesting SLaTeX control sequences}654655[In plain TeX: \verb{\schemeregion} ...656\verb{\endschemeregion}; in LaTeX:657\verb|\begin{schemeregion}| ...658\verb|\end{schemeregion}|; but see \verb{defslatexenvstyle}.]659660Calls to \verb|\scheme|, \verb|\schemeresult|,661\verb{schemedisplay}, \verb{schemebox} or662\verb|schemeinput| can be nested in (a Scheme comment)663of other calls. In LaTeX text, they can occur in664bodies of environments or otherwise grouped. However,665they cannot normally be passed as arguments to macros666or included in bodies of macro definitions, even though667these are complete calls and not parameterized with668respect to macro arguments. To be able to do this, you669should cordon off such a text with the670\verb{schemeregion} environment. SLaTeX is fairly671generous about where exactly you throw the cordon.672673E.g., you cannot have674675\begin{verbatim}676...677The code fragment678$\underline{\hbox{\scheme{(call/cc I)}}}$ is ...679...680\end{verbatim}681but you _can_ have682683\begin{verbatim}684\begin{schemeregion}685...686The code fragment687$\underline{\hbox{\scheme{(call/cc I)}}}$ is ...688...689\end{schemeregion}690\end{verbatim}691and this will produce692693\enableslatex694\begin{schemeregion}695...696697The code fragment698$\underline{\hbox{\scheme{(call/cc I)}}}$ is ...699700...701\end{schemeregion}702\slatexdisable{enableslatex}703704Thus, the \verb{schemeregion} environment makes it705possible to put SLaTeX-specific commands inside macro706arguments or macro definitions without causing rupture.707Normally, this can't be done since SLaTeX-specific708commands correspond to \verb{comment}-like regions of709LaTeX code once SLaTeX is done preprocessing your text.710These \verb{comment} regions share the characteristic of711LaTeX's \verb{verbatim} regions, which also can't appear712in macro arguments or definitions.713714To solve this, you enclose the offending text in a715\verb{schemeregion} environment. This "inlines" all716the calls to SLaTeX in its body instead of commenting717them and then invoking \verb|\input|, thus escaping718the fate described above. They are no-ops as far as719non-SLaTeX commands are concerned. However, while a720\verb{schemeregion} allows its constituent SLaTeX721commands to be included in macro arguments and bodies,722it itself cannot be so included. Thus, your723\verb{schemeregion} should be in a position that724satisfies the property A: either directly at the725"top-level" or in a LaTeX environment that satisfies A.726Since this recursive rule might look weird, you may727just stick to calling \verb{schemeregion} at the728"top-level". Or, you may even wrap each of your LaTeX729files in one huge \verb{schemeregion} if you so wish.730This will cover any obscure "non-robust" use of the731SLaTeX primitives --- however, SLaTeX will run slower.732(The term "robust" is not necessarily used in the same733sense as in LaTeX.)734735Note that SLaTeX commands are made robust only if they736are surrounded textually (lexically) by a737\verb{schemeregion}. A region marker doesn't have738dynamic scope in the sense that LaTeX files loaded739using \verb|\input| from within a740\verb{schemeregion} will not inherit it. In summary, a741\verb{schemeregion} makes "robust" all calls to742\verb|\scheme|, \verb{schemedisplay}, \verb{schemebox}743and744\verb|\schemeinput| within it.745746{\re747\verb{\setkeyword}748\verb{\setconstant}749\verb{\setvariable}}750\index{setkeyword@\verb{\setkeyword}}751\index{setconstant@\verb{\setconstant}}752\index{setvariable@\verb{\setvariable}}753\index{SLaTeX database!modifying}754755SLaTeX has a database containing information about756which code tokens are to be treated as {\bf keywords},757which as {\sf constants}, and which as _variables_.758However, there will always be instances where the user759wants to add their own tokens to these categories, or760perhaps even modify the categories as prescribed by761SLaTeX. The control sequences that enable the user to762do these are763\verb|\setkeyword|, \verb|\setconstant|, and764\verb|\setvariable|. Their arguments are entered as765a (space-separated) list enclosed in braces766(\verb|{}|): SLaTeX learns that these are henceforth767to be typeset in the appropriate font. E.g.,768769\enableslatex770\begin{verbatim}771\setconstant{infinity -infinity}772\end{verbatim}773tells SLaTeX that \scheme{infinity} and774\scheme{-infinity} are to be typeset as constants.775\slatexdisable{enableslatex}776777\index{recognizing new syntactic keywords automatically}778779The user need not use \verb|\setkeyword| specify such780new keywords as are introduced by Scheme's and Common781Lisp's syntactic definition facilities, viz.,782\enableslatex783\scheme{define-syntax}/\scheme{syntax-rules},784\scheme{defmacro}, \scheme{extend-syntax},785\scheme{define-macro!}: SLaTeX automatically recognizes786new macros defined using these facilities.787\slatexdisable{enableslatex}788789{\re790\verb{\setspecialsymbol}791\verb{\unsetspecialsymbol}}792\index{setspecialsymbol@\verb{\setspecialsymbol}}793\index{unsetspecialsymbol@\verb{\unsetspecialsymbol}}794\index{SLaTeX database!modifying}795\index{recognizing special symbols}796797These commands are useful to generate798"mathematical"-looking typeset versions of your code,799over and beyond the fonting capabilities provided by800default. For instance, although your code is801restricted to using ascii identifiers that follow some802convention, the corresponding typeset code could be803more mnemonic and utilize the full suite of804mathematical and other symbols provided by TeX. This805of course should not require you to interfere with your806code itself, which should run in its ascii807representation. It is only the typeset version that808has the new look. For instance, you might want all809occurrences of \verb|lambda|, \verb|and|,810\verb|equiv?|,811\verb|below?|, \verb|above?|, \verb|a1| and \verb|a2| in812your code to be typeset as $\lambda$, $\land$, $\equiv$,813$\sqsubseteq$, $\sqsupseteq$, $a_1$ and $a_2$ respectively.814To do this, you should \verb|\setspecialsymbol| the815concerned identifier to the desired TeX expansion, viz.,816817\enableslatex818\begin{verbatim}819\setspecialsymbol{lambda}{$\lambda$}820\setspecialsymbol{and}{$\land$}821\setspecialsymbol{equiv?}{$\equiv$}822\setspecialsymbol{below?}{$\sqsubseteq$}823\setspecialsymbol{above?}{$\sqsupseteq$}824\setspecialsymbol{a1}{$a_1$}825\setspecialsymbol{a2}{$a_2$}826\end{verbatim}827\slatexdisable{enableslatex}828Now, typing829830\begin{verbatim}831\begin{schemedisplay}832(define equiv?833 (lambda (a1 a2)834 (and (below? a1 a2) (above? a1 a2))))835\end{schemedisplay}836\end{verbatim}837produces838839\enableslatex840\begin{schemedisplay}841(define equiv?842 (lambda (a1 a2)843 (and (below? a1 a2) (above? a1 a2))))844\end{schemedisplay}845\slatexdisable{enableslatex}846Note that with the above settings, \verb|lambda| and847\verb|and| have lost their default keyword status, i.e.,848they will not be typed {\bf boldface}. To retrieve the849original status of special symbols, you should use850\verb|\unsetspecialsymbol|, e.g.851852\enableslatex853\begin{verbatim}854\unsetspecialsymbol{lambda and}855\end{verbatim}856Typing the same program after unsetting the special symbols857as above produces, as expected:858859\begin{schemedisplay}860(define equiv?861 (lambda (a1 a2)862 (and (below? a1 a2) (above? a1 a2))))863\end{schemedisplay}864\slatexdisable{enableslatex}865866In effect, \verb|\setspecialsymbol| extends the867basic "fonting" capability to arbitrary special868typeset versions.869870{\re871\verb{\schemecasesensitive}}872\index{schemecasesensitive@\verb{\schemecasesensitive}}873\index{case sensitivity}874875SLaTeX always typesets output that is of the same case876as your input, regardless of the setting of the877\verb|\schemecasesensitive| command. However, this command878can be used to signal to SLaTeX that all case variations of879an identifier are to be treated identically. E.g. typing880\verb|\schemecasesensitive{false}| implies that while881\verb|lambda| continues to be a keyword, so also are882\verb|Lambda|, \verb|LAMBDA| and \verb|LaMbDa|.883\verb|\schemecasesensitive{true}| reverts it back to884the default mode where case is significant in885determining the class of a token.886887Note that the status \verb|\schemecasesensitive| also888affects the "special symbols" of the previous item.889Thus, in the default case-_sensitive_ setting, only the890case-significant symbol as mentioned in the call to891\verb|\setspecialsymbol| will be replaced by the892corresponding LaTeX expansion. In a case-_in_sensitive893setting, all case variations of the special symbol will894be replaced.895896{\re897\verb{\abovecodeskip}898\verb{\belowcodeskip}899\verb{\leftcodeskip}900\verb{\rightcodeskip}}901\index{abovecodeskip@\verb{\abovecodeskip}}902\index{belowcodeskip@\verb{\belowcodeskip}}903\index{leftcodeskip@\verb{\leftcodeskip}}904\index{rightcodeskip@\verb{\rightcodeskip}}905\index{schemedisplay@\verb{schemedisplay}!adjusting display parameters}906907These are the parameters used by \verb{schemedisplay} for908positioning the displayed code. The default values are909910\begin{verbatim}911\abovecodeskip \medskipamount912\belowcodeskip \medskipamount913\leftcodeskip 0pt914\rightcodeskip 0pt915\end{verbatim}916This produces a flushleft display. The defaults can be917changed to get new display styles. E.g., the918assignment919920\begin{verbatim}921\leftcodeskip5em922\end{verbatim}923shifts the display from the left by a constant 5 ems.924925\index{schemedisplay@\verb{schemedisplay}!allowing page926breaks in}927\index{schemedisplay@\verb{schemedisplay}!disallowing928page breaks in}929930In both the above cases, the \verb{schemedisplay}931environment will be broken naturally across page932boundaries at the right spot if the code is too long to933fit a single page. In fact, automatic pagebreaks934within the Scheme code are allowed if and only if935\verb{\rightcodeskip} is 0pt (its default value). For936all other values of \verb{\rightcodeskip}, each Scheme937code block in a \verb{schemedisplay} is guaranteed to938be on the same page. If you like your current left939indentation, and you're not sure of what value to give940\verb{\rightcodeskip}, but nevertheless don't want941Scheme code broken across pages, you could set942943\begin{verbatim}944\rightcodeskip=0.01pt %or945\rightcodeskip=0pt plus 1fil946\end{verbatim}947948The following explains why the above disable page949breaks within the Scheme block. For example, suppose950you'd set951952\begin{verbatim}953\leftcodeskip=0pt plus 1fil954\rightcodeskip=0pt plus 1fil955\end{verbatim}956This will get you a _centered_ display style. This is957of course because the skip on each side of the code958produces a spring~\cite{tex} that pushes the code to959the center. But for this spring action to work nicely,960the code must have been collected into an unbreakable961box --- which is precisely what962\verb{schemedisplay} does for each of its code blocks963whenever it notices that the prevailing value of964\verb{\rightcodeskip} is not the default zero.965\footnote{0pt plus 1fil $\ne$ 0pt}966967It is this behind-the-scenes selective boxing that968dictates whether a \verb{schemedisplay} block can or969cannot be broken across a page boundary. And the970value of \verb{\rightcodeskip} is used to govern this971selection in a "reasonable" manner.972973{\re974\verb{\keywordfont}975\verb{\constantfont}976\verb{\variablefont}}977\index{keywordfont@\verb{\keywordfont}}978\index{constantfont@\verb{\constantfont}}979\index{variablefont@\verb{\variablefont}}980\index{specifying SLaTeX's fonts}981982These decide the typefaces used for keywords, constants,983and variables. The default definitions are:984985\begin{verbatim}986\def\keywordfont#1{{\bf#1}}987\def\constantfont#1{{\sf#1}}988\def\variablefont#1{{\it#1\/}}989\end{verbatim}990991This is close to the Little Lisper~\cite{ll} style.992Redefine these control sequences for font changes. As993an extreme case, defining all of them to994\verb|{{\tt#1}}| typesets everything in monospace995typewriter font, as, for instance, in SICP~\cite{sicp}.996997{\re998\verb{\defschemedisplaytoken}999\verb{\defschemetoken}1000\verb{\defschemeresulttoken}1001\verb{\defschemeinputtoken}1002\verb{\defschemeregiontoken}}1003\index{defschemedisplaytoken@\verb{\defschemedisplaytoken}}1004\index{defschemetoken@\verb{\defschemetoken}}1005\index{defschemeresulttoken@\verb{\defschemeresulttoken}}1006\index{defschemeboxtoken@\verb{\defschemeboxtoken}}1007\index{defschemeinputtoken@\verb{\defschemeinputtoken}}1008\index{defining SLaTeX control sequences}10091010These define the tokens used by SLaTeX to trigger1011typesetting of in-text code, display code, box code,1012and Scheme files. The default tokens are, as already1013described, \verb{schemedisplay}, \verb|\scheme|,1014\verb|\schemeresult|, \verb{schemebox},1015\verb|\schemeinput| and \verb{schemeregion}1016respectively. If you want shorter or more mnemonic1017tokens, the \verb|\defscheme*token| control sequences1018prove useful. E.g., if you want \verb|\code| to be1019your new control sequence for in-text code, use1020\verb|\defschemetoken{code}|. All instances of1021\verb|\code+...+| after this definition produce1022in-text code, unless overridden by an1023\verb|\undefschemetoken| command.10241025One can have at any time any number of tokens for the1026same activity. One consequence of this is that one can1027have nested \verb{schemeregion}s, provided one has1028different names for the nested call. Otherwise, the1029\verb|\end| of an inner region will prematurely1030terminate an outer region.10311032{\re1033\verb{\undefschemedisplaytoken}1034\verb{\undefschemetoken}1035\verb{\undefschemeresulttoken}1036\verb{\undefschemeinputtoken}1037\verb{\undefschemeregiontoken}}1038\index{undefschemedisplaytoken@\verb{\undefschemedisplaytoken}}1039\index{undefschemetoken@\verb{\undefschemetoken}}1040\index{undefschemeresulttoken@\verb{\undefschemeresulttoken}}1041\index{undefschemeboxtoken@\verb{\undefschemeboxtoken}}1042\index{undefschemeinputtoken@\verb{\undefschemeinputtoken}}1043\index{undefschemeregiontoken@\verb{\undefschemeregiontoken}}1044\index{undefining SLaTeX control sequences}10451046These _un_define the tokens used for triggering1047typesetting in-text code, display code, box code,1048Scheme files, and robust Scheme regions. Use these if1049you want to use these tokens for other purposes and do1050not want to unwittingly trip up the SLaTeX system.10511052{\re1053\verb{\defschememathescape}1054\verb{\undefschememathescape}}1055\index{defschememathescape@\verb{\defschememathescape}}1056\index{undefschememathescape@\verb{\undefschememathescape}}1057\index{TeX mathmode in SLaTeX}1058\index{escape character for mathmode within Scheme}10591060\verb|\defschememathescape{$}| defines the character1061\verb|$| as a mathematical escape character to be used1062within scheme code. (Any character other than1063\verb|}| and whitespace may be chosen instead of1064\verb|$|.) This allows one to use LaTeX-like1065mathematical subformulas within Scheme code, e.g.,10661067\begin{verbatim}1068\defschememathescape{$}10691070\begin{schemedisplay}1071(define $\equiv$1072 (lambda (a$_1$ a$_2$)1073 ($\land$ ($\sqsubseteq$ a$_1$ a$_2$)1074 ($\sqsupseteq$ a$_1$ a$_2$))))1075\end{schemedisplay}1076\end{verbatim}1077produces10781079\enableslatex1080\defschememathescape{$}10811082\begin{schemedisplay}1083(define $\equiv$1084 (lambda (a$_1$ a$_2$)1085 ($\land$ ($\sqsubseteq$ a$_1$ a$_2$)1086 ($\sqsupseteq$ a$_1$ a$_2$))))1087\end{schemedisplay}1088\undefschememathescape{$}1089\slatexdisable{enableslatex}1090\verb|\undefschememathescape{$}| disables the1091math-escape nature, if any, of \verb|$|.10921093{\re1094\verb{\slatexdisable}}1095\index{slatexdisable@\verb{\slatexdisable}}1096\index{disabling SLaTeX}10971098The tokens for typesetting code, as also the token1099\verb|\input| (which is sensitive to SLaTeX, since1100the latter uses it to recursively process files within1101files), can only be used as calls. If they occur in1102the bodies of macro definitions, or their names are1103used for defining other control sequences, SLaTeX will1104not be able to process them. Sometimes, one wants to1105use these tokens, say \verb|\input|, without having1106SLaTeX try to process the inputted file. Or the name1107\verb|\scheme| may be used in a verbatim environment,1108and we don't want such an occurrence to trigger the1109codesetting half of SLaTeX to look for code.11101111Avoiding such uses altogether can be unduly1112restrictive.1113\footnote{Especially when one is writing a "How to ..."1114manual like this where one both uses _and_ mentions the1115control sequences!} One way out is to judiciously use1116the \verb|\undefscheme*token| commands to temporarily1117remove the SLaTeX-specificity of these names. Even1118this can be painful. SLaTeX therefore provides the1119commands \verb|\slatexdisable|. This takes one1120argument word and makes the corresponding control1121sequence out of it. Further, from this point in the1122text, SLaTeX is disabled _until_ the manufactured1123control sequence shows up. This mechanism makes it1124possible to restrict SLaTeX to only appropriate1125portions of the text. Note that the token1126\verb|\slatexdisable| itself can appear in the text1127succeeding its call. The only token that can restore1128SLaTeX-sensitivity is the one created during the call1129to \verb|\slatexdisable|.11301131A typical example of the use of \verb|\slatexdisable|1132is when you use the names \verb|\scheme| and1133\verb|\begin{schemedisplay}| in a \verb{verbatim}1134environment. E.g.,11351136{\medskip1137\obeylines\parindent0pt1138\verb|\slatexdisable{slatexenable}|1139\verb|\begin{verbatim}|1140\verb|slatex provides the command \scheme and the pair|1141\verb|\begin{schemedisplay} and \end{schemedisplay} to typeset|1142\verb|in-text and displayed Scheme code respectively.|1143\verb|\end{verbatim}|1144\verb|\slatexenable|1145\medskip}11461147produces the required11481149\begin{verbatim}1150slatex provides the command \scheme and the pair1151\begin{schemedisplay} and \end{schemedisplay} to typeset1152in-text and display Scheme code respectively.1153\end{verbatim}11541155{\re1156\verb{\slatexignorecurrentfile}}1157\index{slatexignorecurrentfile@\verb{\slatexignorecurrentfile}}1158\index{disabling SLaTeX}11591160This is a SLaTeX pragma included to improve efficiency.1161If you're sure that the remaining portion of a certain1162LaTeX (or TeX) file (including the files that would be1163\verb|\input|ed by it) don't contain any SLaTeX1164commands, then you may place this control sequence in1165it at this point to signal SLaTeX that no preprocessing1166is necessary for the rest of the file.11671168{\re1169\verb{\defslatexenvstyle}}1170\index{defslatexenvstyle@\verb{\defslatexenvstyle}}1171\index{plain TeX}1172\index{LaTeX}1173\index{environments}11741175As section~\ref{quick} showed, the differences in SLaTeX1176usage between plain TeX and LaTeX is simply a matter of1177the difference in the "environment" styles of the two1178formats. It is easy get the behavior of the one1179format with the other.11801181\begin{enumerate}1182\o If you wish to use the plain-TeX style in LaTeX,1183type1184\begin{verbatim}1185\defslatexenvstyle{tex}1186\end{verbatim}1187before first such use.11881189\o Similarly, if you wish to use the LaTeX1190\verb{\begin}/\verb{\end} style in plain TeX, use1191\begin{verbatim}1192\defslatexenvstyle{latex}1193\end{verbatim}1194_provided you have already defined \verb{\begin} and1195\verb{\end} appropriately!_11961197Before doing this, you should keep in mind that1198TeX already has an1199\verb{\end} command --- which is used by TeX's1200\verb{\bye} --- that ends the document. This function1201should be saved under a different name, before1202\verb{\end} can be redefined as an environment closer.1203The following is one way to accomplish this:1204\begin{verbatim}1205\let\plaintexend\end1206\outer\def\bye{\par\vfill\supereject\plaintexend}1207\def\begin#1{\csname#1\endcsname}1208\def\end#1{\csname end#1\endcsname}1209\end{verbatim}1210\end{enumerate}12111212In either case, you can revert to the default style with1213\verb|\defslatexenvstyle{latex}| and1214\verb|\defslatexenvstyle{tex}| respectively.12151216{\re1217\verb{\slatexseparateincludes}}1218\index{slatexseparateincludes@\verb{slatexseparateincludes}}1219\index{reusing SLaTeX's temporary files}12201221By default, the temporary files of SLaTeX use the name1222of the topmost TeX file, i.e., the name stored under1223\verb{\jobname}. In large LaTeX documents using1224\verb{\include}, this may be unduly restrictive.12251226To recapitulate, the \verb{slatex} command creates1227temporary files to store typeset code and then passes1228the baton on to TeX or LaTeX. If no significant change1229has been made to the Scheme code (either in content or1230in relative positioning) in the document, then1231successive calls to (La)TeX could be made directly1232using the old temporary files. This could be a time-saver,1233since it avoids calling up the Scheme typesetter.12341235However, in a large LaTeX document with1236\verb{\include}s, these successive calls to LaTeX often1237entail juggling the \verb{\include}s that are chosen.1238In this case, even though the relative position of the1239Scheme code is preserved within each \verb{include}d1240file, the sequence perceived by the main file changes.1241This spoils the invariance we needed if we'd wanted to1242avoid calling SLaTeX unnecessarily.12431244\index{reusing SLaTeX's temporary files!exploiting1245LaTeX's \verb{\include}}12461247To solve this, the SLaTeX command sequence1248\verb{\slatexseparateincludes} --- which must be called1249before the first occurrence of Scheme code in your1250document ---1251guarantees that each1252\verb{\include}d file will generate its own pool of1253temp files. Thus, if the SLaTeX1254files are created once for each \verb{\include}, they1255will be correctly loaded no matter what sequence of1256\verb{\include}s is taken.12571258{\re1259\verb{\schemecodehook}}1260\index{schemecodehook@\verb{\schemecodehook}}1261\index{hook for \verb{schemedisplay} and1262\verb{schemebox}}12631264The user can define \verb{\schemecodehook} to be1265anything. The hook will be evaluated inside each1266subsequent call to \verb{schemedisplay} and1267\verb{schemebox}. E.g.,12681269\begin{verbatim}1270\let\schemecodehook\tiny1271\end{verbatim}1272converts your Scheme displays and boxes into {\tiny1273small print}.12741275The default value of the hook is \verb{\relax}, a1276no-op.12771278\section{Setting up a file that resets SLaTeX's1279defaults}1280\label{preamble}1281\index{writing personal preamble}1282\index{SLaTeX database!modifying}12831284A sample style modification file for SLaTeX would1285include redefinition of the names of the codesetting1286control sequences, adjustment of the display1287parameters, modification of the font assignments for1288keywords/constants/variables/special symbols, and1289addition of new keywords/constants/variables/special1290symbols to SLaTeX's database.12911292Let's assume you want12931294\begin{itemize}1295\o a centered display style with no vertical skips;12961297\o the names \verb|\code|, \verb{schemefrag}, \verb{scmbox},1298\verb|\sinput| instead of \verb|\scheme|,1299\verb{schemefrag}, \verb{schemebox} and1300\verb|\schemeinput|;13011302\o tokens to disregard case;13031304\o the keywords to come out it \verb{typewriter}, the1305constants in roman, and the variables in {\sl slant};13061307\o "\verb{und}" and "\verb{oder}" as keywords,1308"\verb{true}" and "\verb{false}" as constants,1309"\verb{define}" as a variable (overriding default as1310keyword!), "\verb{F}" as a constant (\verb{f} will also1311be a constant, due to case-insensitivity!);13121313\o "\verb{top}" and "\verb{bottom}" to print as1314$\top$ and $\bot$ respectively.1315\end{itemize}13161317This could be set up as13181319\begin{verbatim}1320\abovecodeskip 0pt1321\belowcodeskip 0pt1322\leftcodeskip 0pt plus 1fil1323\rightcodeskip 0pt plus 1fil13241325\undefschemetoken{scheme}1326\undefschemeboxtoken{schemebox}1327\undefschemedisplaytoken{schemedisplay}1328\undefschemeinputtoken{schemeinput}13291330\defschemetoken{code}1331\defschemeboxtoken{scmbox}1332\defschemedisplaytoken{schemegrag}1333\defschemeinputtoken{sinput}13341335\schemecasesensitive{false}13361337\def\keywordfont#1{{\tt#1}}1338\def\constantfont#1{{\rm#1}}1339\def\variablefont#1{{\sl#1\/}}13401341\setkeyword{und oder}1342\setconstant{true false}1343\setvariable{define}1344\setconstant{F}13451346\setspecialsymbol{top}{$\top$}1347\setspecialsymbol{bottom}{$\bottom$}1348\end{verbatim}13491350This file can then be \verb|\input| in the preamble of1351your LaTeX document.13521353\section{How to obtain and install SLaTeX}1354\label{ftp}1355\index{obtaining and installing SLaTeX}13561357\enableslatex1358\leftcodeskip=0pt plus 1fil1359\rightcodeskip=0pt plus 1fil1360\slatexdisable{enableslatex}13611362SLaTeX is available via anonymous ftp from1363\verb{cs.rice.edu} (or \verb{titan.cs.rice.edu}).1364Login as1365\verb{anonymous}, give your userid as password, change1366to the directory \verb{public/dorai}, convert to1367\verb{bin} mode, and get the file1368\verb{slatex}_NN_\verb{.tar.gz}, where _NN_ is some1369number. Un\verb{gzip}ping and un\verb{tar}ring1370produces a directory \verb{slatex}, containing the1371SLaTeX files. (The file \verb{manifest} lists the1372files in the distribution --- make sure that nothing is1373missing.)13741375To install SLaTeX on your system:13761377\begin{enumerate}1378\o First change directory (\verb{cd}) to \verb{slatex}, the1379directory housing the SLaTeX files.1380\footnote{Some of the SLaTeX files use DOS-style CR-LF1381newlines. You may want to use an appropriate newline1382modifier to the SLaTeX files to make the files comply1383with your operating system's newline format.}13841385\o Edit the file \verb{config.dat} as suggested by the1386comments in the file itself.13871388\o Invoke your Scheme or Common Lisp interpreter.1389Load the file \verb{config.scm}, i.e., type13901391\enableslatex1392\begin{schemedisplay}1393(load "config.scm")1394\end{schemedisplay}1395\slatexdisable{enableslatex}1396at the Scheme (or Common Lisp) prompt. This will1397configure SLaTeX for your Scheme dialect and operating1398system, creating a Scheme file called1399\verb{slatex.scm}. (If you informed \verb{config.dat}1400that your Scheme dialect is Chez, the file1401\verb{slatex.scm} is a compiled version rather than1402Scheme source.) The configuration process also creates1403a batch file \verb{slatex.bat} (on DOS) or a shell1404script \verb{slatex} (on Unix), for convenient1405invocation of SLaTeX from your operating system command1406line. A Scheme/Common Lisp file \verb{callsla.scm} is1407also created --- this lets you call SLaTeX from the1408Scheme/Common Lisp prompt.14091410\o Exit Scheme/Common Lisp.1411\end{enumerate}14121413To set up paths and modify shell script/batch file:14141415\begin{enumerate}1416\o Copy (or move, or link) \verb{slatex.scm} into a1417suitable place, e.g., your \verb{bin} or \verb{lib}1418directory, or the system \verb{bin} or \verb{lib}.14191420\o Copy (or move, or link) \verb{slatex.sty} into a1421suitable place, i.e., somewhere in your \verb{TEXINPUTS}1422path. For installing on a multiuser system, place in1423the directory containing the LaTeX files (on mine this1424is \verb{/usr/local/lib/tex/macros}).142514261427\o \enableslatex1428Copy (or move, or link) the shell script1429\verb{slatex} or the batch file \verb{slatex.bat} to a1430suitable place in your \verb{PATH}, e.g., your {bin} or1431the system {bin} directory. Note that1432\verb{slatex}(\verb{.bat}) sets1433\scheme{SLaTeX.*texinputs*}. If you're making the same1434shell script (or batch file) available to multiple1435users, you should change the line1436\begin{schemedisplay}1437(set! SLaTeX.*texinputs* "...")1438\end{schemedisplay}1439to1440\begin{schemedisplay}1441(set! SLaTeX.*texinputs* (getenv "TEXINPUTS"))1442\end{schemedisplay}1443or some other dialect-dependent way of obtaining the1444\verb{TEXINPUTS} environment variable.1445\slatexdisable{enableslatex}14461447\o Run \verb{slatex} on \verb{slatex-d.tex} (this1448file!) for documentation. (This also serves as a check1449that SLaTeX does indeed work on your machine.) Refer1450to \verb{slatex-d.dvi} when befuddled.1451\end{enumerate}14521453If your dialect did not allow a nice enough shell1454script or batch file, the following provides an1455alternate route to unlocking SLaTeX.14561457\subsection{Other ways of invoking SLaTeX}14581459The configuration process creates shell script/batch1460file \verb{slatex}(\verb{.bat}) for a standard invoking1461mechanism for SLaTeX. The shell script/batch file is1462created to exploit the way your Scheme is called, e.g.,1463matters like whether it accepts \verb{echo}'d1464s-expressions (e.g., Chez) , whether it loads command1465line files (e.g., SCM) , and whether it always checks1466for an "init" file (e.g., MIT C Scheme).14671468\begin{enumerate}1469\o If your Scheme doesn't fall into either of these1470categories, you may have to write your own1471shell script/batch file or devise some other mechanism.14721473\o The shell script/batch file invokes1474Scheme/Common Lisp. If,1475however, you are already in Scheme/Common Lisp and1476spend most of the time continuously at the1477Scheme/Common Lisp prompt rather than the operating1478system prompt, you may avoid some of the delays1479inherent in the shell script/batch file.1480\end{enumerate}14811482\enableslatex1483The file \verb{callsla.scm}, which contains just one1484small procedure named \scheme{call-slatex}, and which1485is created by the configuration process, provides a1486simple calling mechanism from Scheme/Common Lisp, as1487opposed to the operating system command line. You may1488use it as an alternative to the1489\verb{slatex}(\verb{.bat}) shell script/batch file.1490The usage is as follows: load1491\verb{callsla.scm} into Scheme/Common Lisp14921493\begin{schemedisplay}1494(load "callsla.scm")1495\end{schemedisplay}1496and type14971498\setspecialsymbol{<tex-file>}{\va{$\langle$tex-file$\rangle$}}1499\begin{schemedisplay}1500(call-slatex <tex-file>)1501\end{schemedisplay}1502when you need to call SLaTeX on the (La)TeX file1503\scheme{<tex-file>}. This invokes the SLaTeX preprocessor on1504\scheme{<tex-file>}. If your Scheme has a1505\scheme{system} procedure1506that can call the operating system command line,1507\scheme{call-slatex} will also send your file to TeX or1508LaTeX. If your Scheme does not have such a procedure,1509\scheme{call-slatex} will simply prod you to call TeX1510or LaTeX1511yourself.1512\slatexdisable{enableslatex}15131514The outline of the shell script/batch file or1515\verb{callsla.scm} or of any strategy you devise for1516using SLaTeX should include the following actions:15171518\begin{enumerate}1519\o Load the file \verb{slatex.scm} (created by the1520configuration process) into Scheme/Common Lisp.15211522\o \enableslatex1523Set the variable \scheme{SLaTeX.*texinputs*} to the1524path \verb{TEXINPUTS} or \verb{TEXINPUT} used by1525TeX1526\footnote{There is some variation on the name of1527this environment variable. Unix TeX's prefer1528\verb{TEXINPUTS} with an \verb{S}, while DOS (e.g.,1529Eberhard Mattes's emTeX) favors \verb{TEXINPUT} without1530the \verb{S}.}1531to look for1532\slatexdisable{enableslatex}1533\verb|\input|1534files.153515361537\o \enableslatex1538Call the procedure1539\scheme{SLaTeX.process-main-tex-file} on the \verb{.tex}1540file to be processed.1541\slatexdisable{enableslatex}15421543\o Call either \verb{latex} or \verb{tex} on the \verb{.tex} file.1544\end{enumerate}154515461547\enableslatex1548You may devise your own way of calling1549\scheme{SLaTeX.process-main-tex-file}, provided your1550method makes sure that \verb{slatex.scm} has been1551loaded, \scheme{SLaTeX.*texinputs*} set appropriately1552_before_ the call and \verb{latex}/\verb{tex} is called1553_after_ the call.15541555Note that if you prefer to stay in Scheme/Common Lisp1556most of the time, it is a good idea to pre-load the1557procedure \scheme{call-slatex}, perhaps through an1558"init" file. \scheme{call-slatex} is just a1559"one-liner" "call-by-need" hook to SLaTeX and does not1560take up much resources. (Global name clashes between1561your own code and SLaTeX code won't occur unless you1562use variable names starting with "\scheme{SLaTeX.}") If1563you made no calls to \scheme{call-slatex}, the bigger1564file \verb{slatex.scm} is not loaded at all. If you1565make several calls to \scheme{call-slatex},1566\verb{slatex.scm} is loaded only once, at the time of1567the first call.1568\slatexdisable{enableslatex}15691570\subsection{Dialects SLaTeX runs on}1571\index{dialects SLaTeX runs on}15721573\enableslatex1574SLaTeX is implemented in R4RS-compliant Scheme (macros1575are not needed). The code uses the non-standard1576procedures \scheme{delete-file},1577\scheme{file-exists?} and \scheme{force-output}, but1578a Scheme without these procedures can also run SLaTeX1579(the configuration defines the corresponding variables1580to be dummy procedures, since they are not crucial).1581The distribution comes with code to allow SLaTeX to run1582also on Common Lisp. The files \verb{readme} and1583\verb{install} contain all the information necessary to1584configure SLaTeX for your system.1585\slatexdisable{enableslatex}15861587SLaTeX has been tested successfully in the following1588dialects:15891590\begin{itemize}1591\o _On Unix:_1592Chez Scheme (R. Kent Dybvig), Ibuki Common1593Lisp (1987), MIT C Scheme, Elk (Oliver Laumann),1594Scheme-to-C (Joel Bartlett), Scm (Aubrey Jaffer) and1595UMB Scheme (William Campbell);15961597\o _On MS-DOS:_1598MIT C Scheme, Scm (Aubrey Jaffer), Austin Kyoto Common1599Lisp (William Schelter's enhanced version of Taiichi1600Yuasa and Masami Hagiya's KCL) and CLisp (Bruno Haible1601and Michael Stoll).1602\iffalse PCScheme/Geneva (Larry Bartholdi and1603Marc Vuilleumier) \fi1604\end{itemize}16051606If your Scheme is not mentioned here but _is_1607R4RS-compliant, please send a note to the author at1608\verb{dorai@cs.rice.edu} describing your Scheme's1609procedures for deleting files, testing file existence,1610and forcing output, if any, and the configuration file1611will be enhanced to accommodate the new dialect.16121613Bug reports are most welcome --- send to1614\verb{dorai@cs.rice.edu}.1615\index{bug reports}16161617\begin{thebibliography}{9}1618\bibitem{sicp} H. Abelson and G.J. Sussman with J.1619Sussman. Structure and Interpretation of Computer1620Programs. MIT Press, 1985.16211622\bibitem{r4rs} W. Clinger and J. Rees, eds.1623Revised$^4$ Report on the Algorithmic Language Scheme.16241991.16251626\bibitem{ll} D.P. Friedman and M. Felleisen. The1627Little Lisper. Science Research Associates, 1989.16281629\bibitem{tex} D.E. Knuth. The TeXbook.1630Addison-Wesley, 1984.16311632\bibitem{latex} L. Lamport. LaTeX User's Guide and1633Reference Manual. Addison-Wesley, 1986.16341635\bibitem{schemeweb} J. Ramsdell. SchemeWeb. Scheme1636Repository, nexus.yorku.ca, maintained by O. Yigit.16371638\bibitem{lisp2tex} C. Queinnec. LiSP2TeX. Scheme1639Repository.16401641\bibitem{cltl2} G.L. Steele Jr. Common Lisp: The1642Language, 2nd ed. Digital Press, 1990.1643\end{thebibliography}16441645%input slatex-d.ind, the index, if available.1646%slatex-d.ind is generated by running1647% makeind(e)x slatex-d1648%after running latex on slatex-d. The next call1649% latex slatex-d1650%will include slatex-d.ind16511652\inputifpossible{slatex-d.ind}16531654\end{document}16551656\index{schemedisplay@\verb{schemedisplay}!with plain TeX}1657\index{schemebox@\verb{schemebox}!with plain TeX}1658\index{schemeregion@\verb{schemeregion}!with plain TeX}