File: test.tex

package info (click to toggle)
chicken 5.3.0-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 32,892 kB
  • sloc: ansic: 580,083; lisp: 71,987; tcl: 1,445; sh: 588; makefile: 60
file content (1658 lines) | stat: -rw-r--r-- 52,853 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
%slatex-d.tex
%SLaTeX Version 2
%Documentation for SLaTeX
%(c) Dorai Sitaram, 1991, 1994
%dorai@cs.rice.edu

\documentstyle[slatex]{article}

\slatexdisable{enableslatex}

\edef\atcatcodebeforepreamble{\the\catcode`@}
\catcode`@11

\inputifpossible{multicol.sty}

%if Frank Mittelbach's multicol.sty is not
%available, the index will simply waste some paper

%latex wastes too much paper, so...

\textheight 11in
\textwidth 8.5in
\oddsidemargin 1.25in
\advance\textheight -2\oddsidemargin
\advance\textwidth -2\oddsidemargin
\advance\oddsidemargin -1in
\evensidemargin\oddsidemargin
\topmargin\oddsidemargin
\advance\topmargin -\headheight
\advance\topmargin -\headsep

%latex's section headings are way too obnoxiously
%large, so...

\def\nolargefonts{\let\large\normalsize
\let\Large\normalsize
\let\LARGE\normalsize
\let\huge\normalsize
\let\Huge\normalsize}

%mini headers for introducing paragraphs

\def\re{\medbreak\parindent0pt%
\aftergroup\smallskip\obeylines
\llap{$\searrow$\enspace\enspace}}

%a wide line

\def\wideline{\centerline{\hrulefill}}

%smart italics

\def\italicsbegin{\begingroup\it}
\def\italicsend{\endgroup\futurelet\next\italiccorrection}
\def\italiccorrection{\ifx\next,\else\ifx\next.\else\/\fi\fi}
\def\italicstoggle{\italicsbegin\let\italicstoggle\italicsend}
\catcode`\_\active
\def_{\ifmmode\sb\else\expandafter\italicstoggle\fi}

%quote.tex, by Hunter Goatley

{\catcode`\"\active
%
\gdef\begindoublequotes{\global\catcode`\"\active
\global\let\dblqu@te=L}
%
\gdef"{\ifinner\else\ifvmode\let\dblqu@te=L\fi\fi
\if L\dblqu@te``\global\let\dblqu@te=R\else
\let\xxx=\spacefactor
''\global\let\dblqu@te=L%
\spacefactor\xxx
\fi}}

\def\enddoublequotes{\catcode`\"=12}

%nicer \verb

\begingroup\catcode`[1\catcode`]2\catcode`\{12\catcode`\}12%
\gdef\@sverb#1[\if#1{\def\@tempa##1}[\leavevmode\null##1\endgroup]\else
\def\@tempa##1#1[\leavevmode\null##1\endgroup]\fi\@tempa]%
\endgroup

%nicer \footnote

\let\latexfootnote\footnote
\def\footnote{\unskip\latexfootnote\bgroup\let\dummy=}

%item

\let\o\item

%index environment that exploits multicol.sty if
%available...

\renewenvironment{theindex}%
{\parindent0pt%
\let\item\@idxitem
\section*{Index}%
\ifx\multicols\undefined\else
\begin{multicols}{2}\fi}%
{\ifx\multicols\undefined\else
\end{multicols}\fi}

\catcode`@\atcatcodebeforepreamble

\begindoublequotes
\makeindex

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\title{How to Use SLaTeX}

\author{Dorai Sitaram\\
{\tt dorai@cs.rice.edu}\\
Department of Computer Science\\
Rice University\\
Houston, TX 77251--1892}

\date{Gestated 1990\\
First public release, Mar. 1991\\
First major update, Dec. 1991\\
Current update, Jan. 1994}

\begin{document}
\maketitle
\nolargefonts

\section{Introduction}

SLaTeX\index{introduction} is a Scheme program
that allows you to write programs or program fragments
"as is" in your TeX or LaTeX source.  SLaTeX is
particularly geared to the programming languages Scheme
and other Lisps, e.g., Common Lisp.  The formatting of
the code includes assigning appropriate fonts 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 using easy TeX
commands.  In addition, the user can inform SLaTeX to
typeset certain identifiers as specially suited LaTeX
expressions (i.e., beyond just fonting them).  All this
is done without interfering with the identifier
conventions of the language of the programming code at
all.  In sum, no change need be made to your
(presumably running) program code in order to get a
typeset version suited to the particular need: 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.

\enableslatex
Other packages~\cite{schemeweb,lisp2tex} for
typesetting code fragments use a \verb{verbatim}
environment where all the characters are in a
\verb{monospace typewriter font}.  This \verb{monospace}
ensures that the indentation is not affected.  However,
the resulting output fails to distinguish between the
various tokens used in the code, e.g., boldface for
keywords like
\scheme{define} and \scheme{lambda}, sans-serif for
constants like \scheme{#t} and \scheme{42}, and italics
for variables such as \scheme{x} and
\scheme{y} in \scheme{(lambda (x y) (cons x (cons y
'())))}.
\slatexdisable{enableslatex}

The program 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 following section will introduce you to the basic
use of SLaTeX with a small example.
Section~\ref{slatex.sty} introduces the SLaTeX style
files.  Section~\ref{glossary} gives a complete
description of all the SLaTeX control sequences.  These
include commands for manipulating output positioning,
enhancing the database, changing the fonting defaults,
adding special symbols, and selective disabling of
SLaTeX.  Section~\ref{preamble} desribes how to set up
a preamble that reflects your typesetting taste.
Section~\ref{ftp} contains information on obtaining and
installing SLaTeX.

\section{A quick illustration of using SLaTeX}
\label{quick}
\index{quick illustration}

This section presents a short example of SLaTeX use.
We first look at a LaTeX file using SLaTeX commands,
and then give a plain TeX version of the same file.  We
will see that there are minor differences between the
ways SLaTeX is used with plain TeX and LaTeX (but see
\verb{\defslatexenvstyle} for a way to use the
plain-TeX style with the LaTeX format, and conversely,
the LaTeX style with the plain format).

\subsection{For LaTeX users}
\index{LaTeX}
\index{scheme@\verb{\scheme}}
\index{schemedisplay@\verb{schemedisplay}!in LaTeX}
\index{in-text Scheme code}
\index{displayed Scheme code}
\index{slatex.sty@\verb{slatex.sty}}
\index{slatex.sty@\verb{slatex.sty}!as document style}

Consider the following LaTeX (_and_ SLaTeX) file
\verb{quick.tex}:

\wideline
\begin{verbatim}
% quick.tex
\documentstyle[slatex]{article}
%or:
%  \documentstyle{article}
%  \input slatex.sty

In Scheme, the expression \scheme|(set! x 42)| returns
an unspecified value, rather than \scheme'42'.
However, one could get a \scheme{set!} of the latter
style by:

\begin{schemedisplay}
(define-syntax setq
  (syntax-rules ()
    [(setq x a)
     (begin (set! x a)
	    x)]))
\end{schemedisplay}

\end{document}
\end{verbatim}
\wideline

First, the SLaTeX definitions in the style file
\verb{slatex.sty} are loaded into your LaTeX file ---
this may be done either as a \verb{\documentstyle}
option, or through an \verb{\input} command.

\index{scheme@\verb{\scheme}!using grouped argument}

In-text code is introduced by the SLaTeX control
sequence \verb{\scheme} and is flanked by a pair of
identical characters that are not alphabets or
"\verb|{|".  As a special convenient case, SLaTeX also
allows the form \verb|\scheme{...}|.

The SLaTeX control sequences for displayed code are the
opening \verb|\begin{schemedisplay}| and the closing
\verb|\end{schemedisplay}|.

The file is now SLaTeX'd by running the command
\verb{slatex} on it from the Unix or DOS command line:

\begin{verbatim}
slatex quick
\end{verbatim}
or
\begin{verbatim}
slatex quick.tex
\end{verbatim}
This calls a Scheme program \verb{slatex.scm} that
typesets the Scheme code fragments in \verb{quick.tex}
into temporary files.   Thereafter, \verb{quick.tex} along with
the temporary files are then passed to LaTeX.  (For
information on judiciously reusing temporary files, see
\verb{\slatexseparateincludes}.)
The resulting
\verb{quick.dvi} file, when viewed or printed looks like:

\enableslatex
\wideline
In Scheme, the expression \scheme|(set! x 42)| returns
an unspecified value, rather than
\scheme'42'.  However, one could get a \scheme{set!} of
the latter style by:

\begin{schemedisplay}
(define-syntax setq
  (syntax-rules ()
    [(setq x a)
     (begin (set! x a)
	    x)]))
\end{schemedisplay}
\wideline

\index{recognizing new syntactic keywords automatically}

Note that \scheme{setq}, although not normally a
syntactic keyword in Scheme is nevertheless
automatically recognized as such because of the context
in which it occurs.  No special treatment is needed to
ensure that it will continue be treated as such in any
subsequent Scheme code in the document.

\slatexdisable{enableslatex}

\subsection{For plain TeX users}
\index{plain TeX}
\index{scheme@\verb{\scheme}}
\index{schemedisplay@\verb{schemedisplay}!in plain TeX}
\index{in-text Scheme code}
\index{displayed Scheme code}

Plain TeX users invoke SLaTeX much the same way, but
for only two exceptions.  First, since TeX doesn't have
\verb{\documentstyle}, the file \verb{slatex.sty} is
introduced via an \verb{\input} statement before its
commands can be used in the plain TeX source.

\index{environments}

Second, since plain TeX does not have LaTeX's
\verb|\begin{|_env_\verb|}...\end{|_env_\verb|}|
style of environments, any
environment commands in SLaTeX are invoked with the
opening \verb{\}_env_ and the closing \verb{\end}_env_.

The plain TeX version of \verb{quick.tex} looks like:

\wideline
\begin{verbatim}
% quick.tex
\input slatex.sty

In Scheme, the expression \scheme|(set! x 42)| returns
an unspecified value, rather than \scheme'42'.
However, one could get a \scheme{set!} of the latter
style by:

\schemedisplay
(define-syntax setq
  (syntax-rules ()
    [(setq x a)
     (begin (set! x a)
	    x)]))
\endschemedisplay

\bye
\end{verbatim}
\wideline

The file is now SLaTeX'd by invoking \verb{slatex} as
before --- SLaTeX is clever enough to figure out
whether the file it operates on should later be send to
LaTeX or plain Tex.

\section{The style files}
\label{slatex.sty}
\index{slatex.sty@\verb{slatex.sty}}

In short, the LaTeX (or TeX) file that is given to
SLaTeX undergoes some code-setting preprocessing and is
then handed over to LaTeX (or TeX).  The style file
\verb{slatex.sty} defines the appropriate commands so
that LaTeX (or TeX) can recognize the SLaTeX-specific
directives and either process or ignore them.  You may
either \verb|\input| the file \verb{slatex.sty} as
usual, or use it as the \verb|\documentstyle| option
\verb{slatex}.

\index{cltl.sty@\verb{cltl.sty}}
\index{SLaTeX database!for Scheme}
\index{SLaTeX database!for Common Lisp}
\index{SLaTeX database!modifying}

The default database of SLaTeX recognizes the keywords
and constants of Scheme.  The database can be modified
with the commands \verb{\setkeyword},
\verb{\setconstant}, \verb{\setvariable},
\verb{\setspecialsymbol} and \verb{\unsetspecialsymbol}
(q.v.).  If you're using Common Lisp rather than
Scheme, use \verb{cltl.sty} instead of
\verb{slatex.sty}.
\verb{cltl.sty} loads \verb{slatex.sty} and modifies
the database to reflect Common Lisp.  You may fashion
your own \verb{.sty} files on the model of
\verb{cltl.sty}.

\section{SLaTeX's control sequences}
\label{glossary}
\index{SLaTeX control sequences}

You've already seen the SLaTeX control sequence
\verb|\scheme| and the environment
\verb{schemedisplay}.  These suffice for quite a few
instances of handling code.  However, you will
occasionally require more control on the typesetting
process, and the rest of this section describes the
complete
\footnote{At least that's what you're supposed
to think...} list of SLaTeX control sequences shows you
the ropes.

{\re
\verb{schemedisplay}}
\index{schemedisplay@\verb{schemedisplay}}
\index{displayed Scheme code}

[In plain TeX: \verb{\schemedisplay} ...
\verb{\endschemedisplay}; in LaTeX:
\verb|\begin{schemedisplay}| ...
\verb|\end{schemedisplay}|; but see \verb{\defslatexenvstyle}.]

Typesets the enclosed code, which is typically several
lines of code indented as you normally do in your
Scheme files.  E.g.,

\begin{verbatim}
\begin{schemedisplay}
(define compose          ;this is also known as $B$
  (lambda (f g)
    (lambda (x)
      (apply f (g x)))))
\end{schemedisplay}
is the "compose" function.
\end{verbatim}
produces

\enableslatex
\begin{schemedisplay}
(define compose        ;this is also known as $B$
  (lambda (f g)
    (lambda (x)
      (apply f (g x)))))
\end{schemedisplay}
\slatexdisable{enableslatex}
is the "compose" function.

As with all LaTeX environment enders, if the line after
\verb|\end{schemedisplay}| contains
non-whitespace text, the paragraph continues.
Otherwise --- i.e., when \verb|\end{schemedisplay}| is
followed by at least one blank line --- a fresh
paragraph is started.  Similarly, in plain TeX, a fresh
paragraph is started after a \verb{schemedisplay} only
if
\verb|\endschemedisplay| is followed by at least one
blank line.

\index{Scheme comments}

Comments in Scheme are usually introduced by "\verb{;}"
(semicolon).  The rest of the line after a "\verb{;}"
is set as a line in LaTeX LR mode.

\index{TeX paragraphs amidst Scheme code}

Separate _blocks_ of code can either be introduced in
different \verb{schemedisplay} environments or put in a
single \verb{schemedisplay} and separated by a line with
a "\verb{;}" in the first column.  This "\verb{;}" is
not typeset and anything following it on the line is
set in (La)TeX LR paragraph mode.  Consecutive lines
with "\verb{;}" in the first column are treated
as input for a TeX paragraph, with words possibly
moved around from line to line to ensure justification.
When in paragraph mode, the first line that has _no_
leading "\verb{;}" signals a fresh block
of Scheme code within the
\verb{schemedisplay}.  (The \verb{schemedisplay} may
end, or commence, on either a paragraph or a Scheme
code block.)

E.g.,

\begin{verbatim}
\begin{schemedisplay}
(define even?             ; testing evenness
  (lambda (n)
    (if (= n 0) #t (not (odd? (- n 1))))))
; The procedures {\it even?} above
; and {\it odd?} below are mutually
; recursive.
(define odd?              ; testing oddness
  (lambda (n)
    (if (= n 0) #f (not (even? (- n 1))))))
\end{schemedisplay}
\end{verbatim}
produces

\enableslatex
\begin{schemedisplay}
(define even?             ; testing evenness
  (lambda (n)
    (if (= n 0) #t (not (odd? (- n 1))))))
; The procedures {\it even?} above
; and {\it odd?} below are mutually
; recursive.
(define odd?              ; testing oddness
  (lambda (n)
    (if (= n 0) #f (not (even? (- n 1))))))
\end{schemedisplay}
\slatexdisable{enableslatex}

SLaTeX can recognize that blocks of code are separate
if you have at least one empty line separating them.
I.e., there is no need for empty "\verb{;}" lines.  This
convenience is to accommodate Scheme files where
definitions are usually separated by one or more blank
lines.

\index{schemedisplay@\verb{schemedisplay}!allowing page
breaks in}

Intervening paragraphs, either with lines with a
leading "\verb{;}", or with blank lines, are ideal
spots for \verb{schemedisplay} to allow pagebreaks.  In
fact, the default setting for \verb{schemedisplay} also
allows pagebreaks _within_ a Scheme block, but it is
easy to disable this (see entry for
\verb{\rightcodeskip}).

The space surrounding displayed Scheme code can be
modified by setting the _skip_s \verb{\abovecodeskip},
\verb{\belowcodeskip}, \verb{\leftcodeskip}, and
\verb{\rightcodeskip} (q.v.).

Note: see \verb{schemeregion}.

{\re
\verb{\scheme}}
\index{scheme@\verb{\scheme}}
\index{in-text Scheme code}

Typesets its argument, which is enclosed in arbitrary
but identical non-alphabetic and non-\verb|{|
characters, as in-text code.  Special case:
\verb|\scheme{...}| is a convenience (provided the
\verb|...| doesn't contain a
\verb|}|).  E.g., \verb+\scheme|(call/cc (lambda (x) x))|+
and \verb+\scheme{(call/cc (lambda (x) x))}+ both
produce
\enableslatex
\scheme{(call/cc (lambda (x) x))}.
\slatexdisable{enableslatex}
\index{scheme@\verb{\scheme}!using grouped argument}

\index{nesting SLaTeX control sequences}
It _is_ permitted to intermix calls to
\verb{schemedisplay} and
\verb|\scheme|.  Thus,

\begin{verbatim}
\begin{schemedisplay}
(define factorial
  (lambda (n)
    (if (= n 0) ; \scheme{(zero? n)} also possible
        1 (* n (factorial (- n 1)))))) ; or \scheme{... (sub1 1)}
\end{schemedisplay}
\end{verbatim}
produces

\enableslatex
\begin{schemedisplay}
(define factorial
  (lambda (n)
    (if (= n 0) ; \scheme{(zero? n)} also possible
	1
	(* n (factorial (- n 1)))))) ; or \scheme{... (sub1 1)}
\end{schemedisplay}
\slatexdisable{enableslatex}

Note: see \verb{schemeregion}.

{\re
\verb{\schemeresult}}
\index{schemeresult@\verb{\schemeresult}}

Typesets its argument, which is enclosed in arbitrary
but identical non-alphabetic and non-\verb|{|
characters, as in-text Scheme "result" or data: i.e.,
keyword and variable fonts are disabled.  Special
convenient case (as for \verb|\scheme|):
\verb|\schemeresult{...}|.  E.g.,
\index{schemeresult@\verb{\schemeresult}!using grouped argument}

\begin{verbatim}
\scheme|((lambda () (cons 'lambda 'cons)))| yields
\schemeresult|(lambda . cons)|.
\end{verbatim}
produces

\enableslatex
\scheme|((lambda () (cons 'lambda 'cons)))| yields
\schemeresult|(lambda . cons)|.
\slatexdisable{enableslatex}

{\re
\verb{schemebox}}
\index{schemebox@\verb{schemebox}}
\index{boxed Scheme code}

[In plain TeX: \verb{\schemebox} ...
\verb{\endschemebox}; in LaTeX:
\verb|\begin{schemebox}| ...
\verb|\end{schemebox}|; but see \verb{defslatexenvstyle}.]

The \verb{schemebox} environment is similar to
\verb{schemedisplay} except that the code is provided
as a "box" (i.e., it is not "displayed" in the standard
way).  Indeed, when the appropriate skip parameters are
set, \verb{schemedisplay} itself _may_
\footnote{Yes, _may_:  Not all \verb{schemedisplay}s invoke
\verb{schemebox}, and if you're curious why,
see entry for \verb{\rightcodeskip}.  It is a matter of
whether pagebreaks within Scheme code are allowed or
not.} use a
\verb{schemebox} to create a box of code that is
set off with all-round space as a display.

Saving a \verb{schemebox} in an explicit box allows you
to move your typeset code arbitrarily.

Note: see \verb{schemeregion}.

{\re
\verb{\schemeinput}}
\index{schemeinput@\verb{schemeinput}}
\index{inputting Scheme files as is}

This can be used to input Scheme files as typeset code.
(Unlike LaTeX's \verb|\input|, \verb|\schemeinput|'s
argument must always be grouped.)  The Scheme file can
be specified either by its full name, or without its
extension, if the latter is \verb{.scm}, \verb{.ss} or
\verb{.s}.  E.g.,

\begin{verbatim}
\schemeinput{evenodd.scm}    % the .scm is optional!
\end{verbatim}
(where \verb{evenodd.scm} is the name of a Scheme file
containing the code for
\enableslatex
\scheme{even?} and \scheme{odd?} above) produces the same
effect as the
\verb{schemedisplay} version.
\slatexdisable{enableslatex}

Note: see \verb{schemeregion}.

{\re
\verb{schemeregion}}
\index{schemeregion@\verb{schemeregion}}
\index{nesting SLaTeX control sequences}

[In plain TeX: \verb{\schemeregion} ...
\verb{\endschemeregion}; in LaTeX:
\verb|\begin{schemeregion}| ...
\verb|\end{schemeregion}|; but see  \verb{defslatexenvstyle}.]

Calls to \verb|\scheme|, \verb|\schemeresult|,
\verb{schemedisplay}, \verb{schemebox} or
\verb|schemeinput| can be nested in (a Scheme comment)
of other calls.  In LaTeX text, they can occur in
bodies of environments or otherwise grouped.  However,
they cannot normally be passed as arguments to macros
or included in bodies of macro definitions, even though
these are complete calls and not parameterized with
respect to macro arguments.  To be able to do this, you
should cordon off such a text with the
\verb{schemeregion} environment.  SLaTeX is fairly
generous about where exactly you throw the cordon.

E.g., you cannot have

\begin{verbatim}
...
The code fragment
$\underline{\hbox{\scheme{(call/cc I)}}}$ is ...
...
\end{verbatim}
but you _can_ have

\begin{verbatim}
\begin{schemeregion}
...
The code fragment
$\underline{\hbox{\scheme{(call/cc I)}}}$ is ...
...
\end{schemeregion}
\end{verbatim}
and this will produce

\enableslatex
\begin{schemeregion}
...

The code fragment
$\underline{\hbox{\scheme{(call/cc I)}}}$ is ...

...
\end{schemeregion}
\slatexdisable{enableslatex}

Thus, the \verb{schemeregion} environment makes it
possible to put SLaTeX-specific commands inside macro
arguments or macro definitions without causing rupture.
Normally, this can't be done since SLaTeX-specific
commands correspond to \verb{comment}-like regions of
LaTeX code once SLaTeX is done preprocessing your text.
These \verb{comment} regions share the characteristic of
LaTeX's \verb{verbatim} regions, which also can't appear
in macro arguments or definitions.

To solve this, you enclose the offending text in a
\verb{schemeregion} environment.  This "inlines" all
the calls to SLaTeX in its body instead of commenting
them and then invoking \verb|\input|, thus escaping
the fate described above.  They are no-ops as far as
non-SLaTeX commands are concerned.  However, while a
\verb{schemeregion} allows its constituent SLaTeX
commands to be included in macro arguments and bodies,
it itself cannot be so included.  Thus, your
\verb{schemeregion} should be in a position that
satisfies the property A: either directly at the
"top-level" or in a LaTeX environment that satisfies A.
Since this recursive rule might look weird, you may
just stick to calling \verb{schemeregion} at the
"top-level".  Or, you may even wrap each of your LaTeX
files in one huge \verb{schemeregion} if you so wish.
This will cover any obscure "non-robust" use of the
SLaTeX primitives --- however, SLaTeX will run slower.
(The term "robust" is not necessarily used in the same
sense as in LaTeX.)

Note that SLaTeX commands are made robust only if they
are surrounded textually (lexically) by a
\verb{schemeregion}.  A region marker doesn't have
dynamic scope in the sense that LaTeX files loaded
using \verb|\input| from within a
\verb{schemeregion} will not inherit it.  In summary, a
\verb{schemeregion} makes "robust" all calls to
\verb|\scheme|, \verb{schemedisplay}, \verb{schemebox}
and
\verb|\schemeinput| within it.

{\re
\verb{\setkeyword}
\verb{\setconstant}
\verb{\setvariable}}
\index{setkeyword@\verb{\setkeyword}}
\index{setconstant@\verb{\setconstant}}
\index{setvariable@\verb{\setvariable}}
\index{SLaTeX database!modifying}

SLaTeX has a database containing information about
which code tokens are to be treated as {\bf keywords},
which as {\sf constants}, and which as _variables_.
However, there will always be instances where the user
wants to add their own tokens to these categories, or
perhaps even modify the categories as prescribed by
SLaTeX.  The control sequences that enable the user to
do these are
\verb|\setkeyword|, \verb|\setconstant|, and
\verb|\setvariable|.  Their arguments are entered as
a (space-separated) list enclosed in braces
(\verb|{}|): SLaTeX learns that these are henceforth
to be typeset in the appropriate font.  E.g.,

\enableslatex
\begin{verbatim}
\setconstant{infinity -infinity}
\end{verbatim}
tells SLaTeX that \scheme{infinity} and
\scheme{-infinity} are to be typeset as constants.
\slatexdisable{enableslatex}

\index{recognizing new syntactic keywords automatically}

The user need not use \verb|\setkeyword| specify such
new keywords as are introduced by Scheme's and Common
Lisp's syntactic definition facilities, viz.,
\enableslatex
\scheme{define-syntax}/\scheme{syntax-rules},
\scheme{defmacro}, \scheme{extend-syntax},
\scheme{define-macro!}: SLaTeX automatically recognizes
new macros defined using these facilities.
\slatexdisable{enableslatex}

{\re
\verb{\setspecialsymbol}
\verb{\unsetspecialsymbol}}
\index{setspecialsymbol@\verb{\setspecialsymbol}}
\index{unsetspecialsymbol@\verb{\unsetspecialsymbol}}
\index{SLaTeX database!modifying}
\index{recognizing special symbols}

These commands are useful to generate
"mathematical"-looking typeset versions of your code,
over and beyond the fonting capabilities provided by
default.  For instance, although your code is
restricted to using ascii identifiers that follow some
convention, the corresponding typeset code could be
more mnemonic and utilize the full suite of
mathematical and other symbols provided by TeX.  This
of course should not require you to interfere with your
code itself, which should run in its ascii
representation.  It is only the typeset version that
has the new look.  For instance, you might want all
occurrences of \verb|lambda|, \verb|and|,
\verb|equiv?|,
\verb|below?|, \verb|above?|, \verb|a1| and \verb|a2| in
your code to be typeset as $\lambda$, $\land$, $\equiv$,
$\sqsubseteq$, $\sqsupseteq$, $a_1$ and $a_2$ respectively.
To do this, you should \verb|\setspecialsymbol| the
concerned identifier to the desired TeX expansion, viz.,

\enableslatex
\begin{verbatim}
\setspecialsymbol{lambda}{$\lambda$}
\setspecialsymbol{and}{$\land$}
\setspecialsymbol{equiv?}{$\equiv$}
\setspecialsymbol{below?}{$\sqsubseteq$}
\setspecialsymbol{above?}{$\sqsupseteq$}
\setspecialsymbol{a1}{$a_1$}
\setspecialsymbol{a2}{$a_2$}
\end{verbatim}
\slatexdisable{enableslatex}
Now, typing

\begin{verbatim}
\begin{schemedisplay}
(define equiv?
  (lambda (a1 a2)
    (and (below? a1 a2) (above? a1 a2))))
\end{schemedisplay}
\end{verbatim}
produces

\enableslatex
\begin{schemedisplay}
(define equiv?
  (lambda (a1 a2)
    (and (below? a1 a2) (above? a1 a2))))
\end{schemedisplay}
\slatexdisable{enableslatex}
Note that with the above settings, \verb|lambda| and
\verb|and| have lost their default keyword status, i.e.,
they will not be typed {\bf boldface}.  To retrieve the
original status of special symbols, you should use
\verb|\unsetspecialsymbol|, e.g.

\enableslatex
\begin{verbatim}
\unsetspecialsymbol{lambda and}
\end{verbatim}
Typing the same program after unsetting the special symbols
as above produces, as expected:

\begin{schemedisplay}
(define equiv?
  (lambda (a1 a2)
    (and (below? a1 a2) (above? a1 a2))))
\end{schemedisplay}
\slatexdisable{enableslatex}

In effect, \verb|\setspecialsymbol| extends the
basic "fonting" capability to arbitrary special
typeset versions.

{\re
\verb{\schemecasesensitive}}
\index{schemecasesensitive@\verb{\schemecasesensitive}}
\index{case sensitivity}

SLaTeX always typesets output that is of the same case
as your input, regardless of the setting of the
\verb|\schemecasesensitive| command.  However, this command
can be used to signal to SLaTeX that all case variations of
an identifier are to be treated identically.  E.g. typing
\verb|\schemecasesensitive{false}| implies that while
\verb|lambda| continues to be a keyword, so also are
\verb|Lambda|, \verb|LAMBDA| and \verb|LaMbDa|.
\verb|\schemecasesensitive{true}| reverts it back to
the default mode where case is significant in
determining the class of a token.

Note that the status \verb|\schemecasesensitive| also
affects the "special symbols" of the previous item.
Thus, in the default case-_sensitive_ setting, only the
case-significant symbol as mentioned in the call to
\verb|\setspecialsymbol| will be replaced by the
corresponding LaTeX expansion.  In a case-_in_sensitive
setting, all case variations of the special symbol will
be replaced.

{\re
\verb{\abovecodeskip}
\verb{\belowcodeskip}
\verb{\leftcodeskip}
\verb{\rightcodeskip}}
\index{abovecodeskip@\verb{\abovecodeskip}}
\index{belowcodeskip@\verb{\belowcodeskip}}
\index{leftcodeskip@\verb{\leftcodeskip}}
\index{rightcodeskip@\verb{\rightcodeskip}}
\index{schemedisplay@\verb{schemedisplay}!adjusting display parameters}

These are the parameters used by \verb{schemedisplay} for
positioning the displayed code.  The default values are

\begin{verbatim}
\abovecodeskip \medskipamount
\belowcodeskip \medskipamount
\leftcodeskip 0pt
\rightcodeskip 0pt
\end{verbatim}
This produces a flushleft display.  The defaults can be
changed to get new display styles.  E.g., the
assignment

\begin{verbatim}
\leftcodeskip5em
\end{verbatim}
shifts the display from the left by a constant 5 ems.

\index{schemedisplay@\verb{schemedisplay}!allowing page
breaks in}
\index{schemedisplay@\verb{schemedisplay}!disallowing
page breaks in}

In both the above cases, the \verb{schemedisplay}
environment will be broken naturally across page
boundaries at the right spot if the code is too long to
fit a single page.  In fact, automatic pagebreaks
within the Scheme code are allowed if and only if
\verb{\rightcodeskip} is 0pt (its default value).  For
all other values of \verb{\rightcodeskip}, each Scheme
code block in a \verb{schemedisplay} is guaranteed to
be on the same page.  If you like your current left
indentation, and you're not sure of what value to give
\verb{\rightcodeskip}, but nevertheless don't want
Scheme code broken across pages, you could set

\begin{verbatim}
\rightcodeskip=0.01pt %or
\rightcodeskip=0pt plus 1fil
\end{verbatim}

The following explains why the above disable page
breaks within the Scheme block.  For example, suppose
you'd set

\begin{verbatim}
\leftcodeskip=0pt plus 1fil
\rightcodeskip=0pt plus 1fil
\end{verbatim}
This will get you a _centered_ display style.  This is
of course because the skip on each side of the code
produces a spring~\cite{tex} that pushes the code to
the center.  But for this spring action to work nicely,
the code must have been collected into an unbreakable
box --- which is precisely  what
\verb{schemedisplay} does for each of its code blocks
whenever it notices that the prevailing value of
\verb{\rightcodeskip} is not the default zero.
\footnote{0pt plus 1fil $\ne$ 0pt}

It is this behind-the-scenes selective boxing that
dictates whether a \verb{schemedisplay} block can or
cannot be broken across a page boundary.  And the
value of \verb{\rightcodeskip} is used to govern this
selection in a "reasonable" manner.

{\re
\verb{\keywordfont}
\verb{\constantfont}
\verb{\variablefont}}
\index{keywordfont@\verb{\keywordfont}}
\index{constantfont@\verb{\constantfont}}
\index{variablefont@\verb{\variablefont}}
\index{specifying SLaTeX's fonts}

These decide the typefaces used for keywords, constants,
and variables.  The default definitions are:

\begin{verbatim}
\def\keywordfont#1{{\bf#1}}
\def\constantfont#1{{\sf#1}}
\def\variablefont#1{{\it#1\/}}
\end{verbatim}

This is close to the Little Lisper~\cite{ll} style.
Redefine these control sequences for font changes.  As
an extreme case, defining all of them to
\verb|{{\tt#1}}| typesets everything in monospace
typewriter font, as, for instance, in SICP~\cite{sicp}.

{\re
\verb{\defschemedisplaytoken}
\verb{\defschemetoken}
\verb{\defschemeresulttoken}
\verb{\defschemeinputtoken}
\verb{\defschemeregiontoken}}
\index{defschemedisplaytoken@\verb{\defschemedisplaytoken}}
\index{defschemetoken@\verb{\defschemetoken}}
\index{defschemeresulttoken@\verb{\defschemeresulttoken}}
\index{defschemeboxtoken@\verb{\defschemeboxtoken}}
\index{defschemeinputtoken@\verb{\defschemeinputtoken}}
\index{defining SLaTeX control sequences}

These define the tokens used by SLaTeX to trigger
typesetting of in-text code, display code, box code,
and Scheme files.  The default tokens are, as already
described, \verb{schemedisplay}, \verb|\scheme|,
\verb|\schemeresult|, \verb{schemebox},
\verb|\schemeinput| and \verb{schemeregion}
respectively.  If you want shorter or more mnemonic
tokens, the \verb|\defscheme*token| control sequences
prove useful.  E.g., if you want \verb|\code| to be
your new control sequence for in-text code, use
\verb|\defschemetoken{code}|.  All instances of
\verb|\code+...+| after this definition produce
in-text code, unless overridden by an
\verb|\undefschemetoken| command.

One can have at any time any number of tokens for the
same activity.  One consequence of this is that one can
have nested \verb{schemeregion}s, provided one has
different names for the nested call.  Otherwise, the
\verb|\end| of an inner region will prematurely
terminate an outer region.

{\re
\verb{\undefschemedisplaytoken}
\verb{\undefschemetoken}
\verb{\undefschemeresulttoken}
\verb{\undefschemeinputtoken}
\verb{\undefschemeregiontoken}}
\index{undefschemedisplaytoken@\verb{\undefschemedisplaytoken}}
\index{undefschemetoken@\verb{\undefschemetoken}}
\index{undefschemeresulttoken@\verb{\undefschemeresulttoken}}
\index{undefschemeboxtoken@\verb{\undefschemeboxtoken}}
\index{undefschemeinputtoken@\verb{\undefschemeinputtoken}}
\index{undefschemeregiontoken@\verb{\undefschemeregiontoken}}
\index{undefining SLaTeX control sequences}

These _un_define the tokens used for triggering
typesetting in-text code, display code, box code,
Scheme files, and robust Scheme regions.  Use these if
you want to use these tokens for other purposes and do
not want to unwittingly trip up the SLaTeX system.

{\re
\verb{\defschememathescape}
\verb{\undefschememathescape}}
\index{defschememathescape@\verb{\defschememathescape}}
\index{undefschememathescape@\verb{\undefschememathescape}}
\index{TeX mathmode in SLaTeX}
\index{escape character for mathmode within Scheme}

\verb|\defschememathescape{$}| defines the character
\verb|$| as a mathematical escape character to be used
within scheme code.  (Any character other than
\verb|}| and whitespace may be chosen instead of
\verb|$|.)  This allows one to use LaTeX-like
mathematical subformulas within Scheme code, e.g.,

\begin{verbatim}
\defschememathescape{$}

\begin{schemedisplay}
(define $\equiv$
  (lambda (a$_1$ a$_2$)
    ($\land$ ($\sqsubseteq$ a$_1$ a$_2$)
	     ($\sqsupseteq$ a$_1$ a$_2$))))
\end{schemedisplay}
\end{verbatim}
produces

\enableslatex
\defschememathescape{$}

\begin{schemedisplay}
(define $\equiv$
  (lambda (a$_1$ a$_2$)
    ($\land$ ($\sqsubseteq$ a$_1$ a$_2$)
	     ($\sqsupseteq$ a$_1$ a$_2$))))
\end{schemedisplay}
\undefschememathescape{$}
\slatexdisable{enableslatex}
\verb|\undefschememathescape{$}| disables the
math-escape nature, if any, of \verb|$|.

{\re
\verb{\slatexdisable}}
\index{slatexdisable@\verb{\slatexdisable}}
\index{disabling SLaTeX}

The tokens for typesetting code, as also the token
\verb|\input| (which is sensitive to SLaTeX, since
the latter uses it to recursively process files within
files), can only be used as calls.  If they occur in
the bodies of macro definitions, or their names are
used for defining other control sequences, SLaTeX will
not be able to process them.  Sometimes, one wants to
use these tokens, say \verb|\input|, without having
SLaTeX try to process the inputted file.  Or the name
\verb|\scheme| may be used in a verbatim environment,
and we don't want such an occurrence to trigger the
codesetting half of SLaTeX to look for code.

Avoiding such uses altogether can be unduly
restrictive.
\footnote{Especially when one is writing a "How to ..."
manual like this where one both uses _and_ mentions the
control sequences!} One way out is to judiciously use
the \verb|\undefscheme*token| commands to temporarily
remove the SLaTeX-specificity of these names.  Even
this can be painful.  SLaTeX therefore provides the
commands \verb|\slatexdisable|.  This takes one
argument word and makes the corresponding control
sequence out of it.  Further, from this point in the
text, SLaTeX is disabled _until_ the manufactured
control sequence shows up.  This mechanism makes it
possible to restrict SLaTeX to only appropriate
portions of the text.  Note that the token
\verb|\slatexdisable| itself can appear in the text
succeeding its call.  The only token that can restore
SLaTeX-sensitivity is the one created during the call
to \verb|\slatexdisable|.

A typical example of the use of \verb|\slatexdisable|
is when you use the names \verb|\scheme| and
\verb|\begin{schemedisplay}| in a \verb{verbatim}
environment.  E.g.,

{\medskip
\obeylines\parindent0pt
\verb|\slatexdisable{slatexenable}|
\verb|\begin{verbatim}|
\verb|slatex provides the command \scheme and the pair|
\verb|\begin{schemedisplay} and \end{schemedisplay} to typeset|
\verb|in-text and displayed Scheme code respectively.|
\verb|\end{verbatim}|
\verb|\slatexenable|
\medskip}

produces the required

\begin{verbatim}
slatex provides the command \scheme and the pair
\begin{schemedisplay} and \end{schemedisplay} to typeset
in-text and display Scheme code respectively.
\end{verbatim}

{\re
\verb{\slatexignorecurrentfile}}
\index{slatexignorecurrentfile@\verb{\slatexignorecurrentfile}}
\index{disabling SLaTeX}

This is a SLaTeX pragma included to improve efficiency.
If you're sure that the remaining portion of a certain
LaTeX (or TeX) file (including the files that would be
\verb|\input|ed by it) don't contain any SLaTeX
commands, then you may place this control sequence in
it at this point to signal SLaTeX that no preprocessing
is necessary for the rest of the file.

{\re
\verb{\defslatexenvstyle}}
\index{defslatexenvstyle@\verb{\defslatexenvstyle}}
\index{plain TeX}
\index{LaTeX}
\index{environments}

As section~\ref{quick} showed, the differences in SLaTeX
usage between plain TeX and LaTeX is simply a matter of
the difference in the "environment" styles of the two
formats.  It is easy get the behavior of the one
format with the other.

\begin{enumerate}
\o  If you wish to use the plain-TeX style in LaTeX,
type
\begin{verbatim}
\defslatexenvstyle{tex}
\end{verbatim}
before first such use.

\o  Similarly, if you wish to use the LaTeX
\verb{\begin}/\verb{\end} style in plain TeX, use
\begin{verbatim}
\defslatexenvstyle{latex}
\end{verbatim}
_provided you have already defined \verb{\begin} and
\verb{\end} appropriately!_

Before doing this, you should keep in mind that
TeX already has an
\verb{\end} command --- which is used by TeX's
\verb{\bye} --- that ends the document. This function
should be saved under a different name, before
\verb{\end} can be redefined as an environment closer.
The following is one way to accomplish this:
\begin{verbatim}
\let\plaintexend\end
\outer\def\bye{\par\vfill\supereject\plaintexend}
\def\begin#1{\csname#1\endcsname}
\def\end#1{\csname end#1\endcsname}
\end{verbatim}
\end{enumerate}

In either case, you can revert to the default style with
\verb|\defslatexenvstyle{latex}| and
\verb|\defslatexenvstyle{tex}| respectively.

{\re
\verb{\slatexseparateincludes}}
\index{slatexseparateincludes@\verb{slatexseparateincludes}}
\index{reusing SLaTeX's temporary files}

By default, the temporary files of SLaTeX use the name
of the topmost TeX file, i.e., the name stored under
\verb{\jobname}.  In large LaTeX documents using
\verb{\include}, this may be unduly restrictive.

To recapitulate, the \verb{slatex} command creates
temporary files to store typeset code and then passes
the baton on to TeX or LaTeX.  If no significant change
has been made to the Scheme code (either in content or
in relative positioning) in the document, then
successive calls to (La)TeX could be made directly
using the old temporary files.  This could be a time-saver,
since it avoids calling up the Scheme typesetter.

However, in a large LaTeX document with
\verb{\include}s, these successive calls to LaTeX often
entail juggling the \verb{\include}s that are chosen.
In this case, even though the relative position of the
Scheme code is preserved within each \verb{include}d
file, the sequence perceived by the main file changes.
This spoils the invariance we needed if we'd wanted to
avoid calling SLaTeX unnecessarily.

\index{reusing SLaTeX's temporary files!exploiting
LaTeX's \verb{\include}}

To solve this, the SLaTeX command sequence
\verb{\slatexseparateincludes} --- which must be called
before the first occurrence of Scheme code in your
document ---
guarantees that each
\verb{\include}d file will generate its own pool of
temp files.  Thus, if the SLaTeX
files are created once for each \verb{\include}, they
will be correctly loaded no matter what sequence of
\verb{\include}s is taken.

{\re
\verb{\schemecodehook}}
\index{schemecodehook@\verb{\schemecodehook}}
\index{hook for \verb{schemedisplay} and
\verb{schemebox}}

The user can define \verb{\schemecodehook} to be
anything.  The hook will be evaluated inside each
subsequent call to \verb{schemedisplay} and
\verb{schemebox}.  E.g.,

\begin{verbatim}
\let\schemecodehook\tiny
\end{verbatim}
converts your Scheme displays and boxes into {\tiny
small print}.

The default value of the hook is \verb{\relax}, a
no-op.

\section{Setting up a file that resets SLaTeX's
defaults}
\label{preamble}
\index{writing personal preamble}
\index{SLaTeX database!modifying}

A sample style modification file for SLaTeX would
include redefinition of the names of the codesetting
control sequences, adjustment of the display
parameters, modification of the font assignments for
keywords/constants/variables/special symbols, and
addition of new keywords/constants/variables/special
symbols to SLaTeX's database.

Let's assume you want

\begin{itemize}
\o a centered display style with no vertical skips;

\o the names \verb|\code|, \verb{schemefrag}, \verb{scmbox},
\verb|\sinput| instead of \verb|\scheme|,
\verb{schemefrag}, \verb{schemebox} and
\verb|\schemeinput|;

\o tokens to disregard case;

\o the keywords to come out it \verb{typewriter}, the
constants in roman, and the variables in {\sl slant};

\o "\verb{und}" and "\verb{oder}" as keywords,
"\verb{true}" and "\verb{false}" as constants,
"\verb{define}" as a variable (overriding default as
keyword!), "\verb{F}" as a constant (\verb{f} will also
be a constant, due to case-insensitivity!);

\o "\verb{top}" and "\verb{bottom}" to print as
$\top$ and $\bot$ respectively.
\end{itemize}

This could be set up as

\begin{verbatim}
\abovecodeskip 0pt
\belowcodeskip 0pt
\leftcodeskip 0pt plus 1fil
\rightcodeskip 0pt plus 1fil

\undefschemetoken{scheme}
\undefschemeboxtoken{schemebox}
\undefschemedisplaytoken{schemedisplay}
\undefschemeinputtoken{schemeinput}

\defschemetoken{code}
\defschemeboxtoken{scmbox}
\defschemedisplaytoken{schemegrag}
\defschemeinputtoken{sinput}

\schemecasesensitive{false}

\def\keywordfont#1{{\tt#1}}
\def\constantfont#1{{\rm#1}}
\def\variablefont#1{{\sl#1\/}}

\setkeyword{und oder}
\setconstant{true false}
\setvariable{define}
\setconstant{F}

\setspecialsymbol{top}{$\top$}
\setspecialsymbol{bottom}{$\bottom$}
\end{verbatim}

This file can then be \verb|\input| in the preamble of
your LaTeX document.

\section{How to obtain and install SLaTeX}
\label{ftp}
\index{obtaining and installing SLaTeX}

\enableslatex
\leftcodeskip=0pt plus 1fil
\rightcodeskip=0pt plus 1fil
\slatexdisable{enableslatex}

SLaTeX is available via anonymous ftp from
\verb{cs.rice.edu} (or \verb{titan.cs.rice.edu}).
Login as
\verb{anonymous}, give your userid as password, change
to the directory \verb{public/dorai}, convert to
\verb{bin} mode, and get the file
\verb{slatex}_NN_\verb{.tar.gz}, where _NN_ is some
number.  Un\verb{gzip}ping and un\verb{tar}ring
produces a directory \verb{slatex}, containing the
SLaTeX files.  (The file \verb{manifest} lists the
files in the distribution --- make sure that nothing is
missing.)

To install SLaTeX on your system:

\begin{enumerate}
\o First change directory (\verb{cd}) to \verb{slatex}, the
directory housing the SLaTeX files.
\footnote{Some of the SLaTeX files use DOS-style CR-LF
newlines.  You may want to use an appropriate newline
modifier to the SLaTeX files to make the files comply
with your operating system's newline format.}

\o Edit the file \verb{config.dat} as suggested by the
comments in the file itself.

\o Invoke your Scheme or Common Lisp interpreter.
Load the file \verb{config.scm}, i.e., type

\enableslatex
\begin{schemedisplay}
(load "config.scm")
\end{schemedisplay}
\slatexdisable{enableslatex}
at the Scheme (or Common Lisp) prompt.  This will
configure SLaTeX for your Scheme dialect and operating
system, creating a Scheme file called
\verb{slatex.scm}.  (If you informed \verb{config.dat}
that your Scheme dialect is Chez, the file
\verb{slatex.scm} is a compiled version rather than
Scheme source.)  The configuration process also creates
a batch file \verb{slatex.bat} (on DOS) or a shell
script \verb{slatex} (on Unix), for convenient
invocation of SLaTeX from your operating system command
line.  A Scheme/Common Lisp file \verb{callsla.scm} is
also created --- this lets you call SLaTeX from the
Scheme/Common Lisp prompt.

\o Exit Scheme/Common Lisp.
\end{enumerate}

To set up paths and modify shell script/batch file:

\begin{enumerate}
\o Copy (or move, or link) \verb{slatex.scm} into a
suitable place, e.g., your \verb{bin} or \verb{lib}
directory, or the system \verb{bin} or \verb{lib}.

\o Copy (or move, or link) \verb{slatex.sty} into a
suitable place, i.e., somewhere in your \verb{TEXINPUTS}
path.  For installing on a multiuser system, place in
the directory containing the LaTeX files (on mine this
is \verb{/usr/local/lib/tex/macros}).


\o \enableslatex
Copy (or move, or link) the shell script
\verb{slatex} or the batch file \verb{slatex.bat} to a
suitable place in your \verb{PATH}, e.g., your {bin} or
the system {bin} directory.  Note that
\verb{slatex}(\verb{.bat}) sets
\scheme{SLaTeX.*texinputs*}.  If you're making the same
shell script (or batch file) available to multiple
users, you should change the line
\begin{schemedisplay}
(set! SLaTeX.*texinputs* "...")
\end{schemedisplay}
to
\begin{schemedisplay}
(set! SLaTeX.*texinputs* (getenv "TEXINPUTS"))
\end{schemedisplay}
or some other dialect-dependent way of obtaining the
\verb{TEXINPUTS} environment variable.
\slatexdisable{enableslatex}

\o Run \verb{slatex} on \verb{slatex-d.tex} (this
file!) for documentation.  (This also serves as a check
that SLaTeX does indeed work on your machine.)  Refer
to \verb{slatex-d.dvi} when befuddled.
\end{enumerate}

If your dialect did not allow a nice enough shell
script or batch file, the following provides an
alternate route to unlocking SLaTeX.

\subsection{Other ways of invoking SLaTeX}

The configuration process creates shell script/batch
file \verb{slatex}(\verb{.bat}) for a standard invoking
mechanism for SLaTeX.  The shell script/batch file is
created to exploit the way your Scheme is called, e.g.,
matters like whether it accepts \verb{echo}'d
s-expressions (e.g., Chez) , whether it loads command
line files (e.g., SCM) , and whether it always checks
for an "init" file (e.g., MIT C Scheme).

\begin{enumerate}
\o  If your Scheme doesn't fall into either of these
categories, you may have to write your own
shell script/batch file or devise some other mechanism.

\o  The shell script/batch file invokes
Scheme/Common Lisp.  If,
however, you are already in Scheme/Common Lisp and
spend most of the time continuously at the
Scheme/Common Lisp prompt rather than the operating
system prompt, you may avoid some of the delays
inherent in the shell script/batch file.
\end{enumerate}

\enableslatex
The file \verb{callsla.scm}, which contains just one
small procedure named \scheme{call-slatex}, and which
is created by the configuration process, provides a
simple calling mechanism from Scheme/Common Lisp, as
opposed to the operating system command line.  You may
use it as an alternative to the
\verb{slatex}(\verb{.bat}) shell script/batch file.
The usage is as follows: load
\verb{callsla.scm} into Scheme/Common Lisp

\begin{schemedisplay}
(load "callsla.scm")
\end{schemedisplay}
and type

\setspecialsymbol{<tex-file>}{\va{$\langle$tex-file$\rangle$}}
\begin{schemedisplay}
(call-slatex <tex-file>)
\end{schemedisplay}
when you need to call SLaTeX on the (La)TeX file
\scheme{<tex-file>}.  This invokes the SLaTeX preprocessor on
\scheme{<tex-file>}.  If your Scheme has a
\scheme{system} procedure
that can call the operating system command line,
\scheme{call-slatex} will also send your file to TeX or
LaTeX. If your Scheme does not have such a procedure,
\scheme{call-slatex} will simply prod you to call TeX
or LaTeX
yourself.
\slatexdisable{enableslatex}

The outline of the shell script/batch file or
\verb{callsla.scm} or of any strategy you devise for
using SLaTeX should include the following actions:

\begin{enumerate}
\o Load the file \verb{slatex.scm} (created by the
configuration process) into Scheme/Common Lisp.

\o \enableslatex
Set the variable \scheme{SLaTeX.*texinputs*} to the
path \verb{TEXINPUTS} or \verb{TEXINPUT} used by
TeX
\footnote{There is some variation on the name of
this environment variable.  Unix TeX's prefer
\verb{TEXINPUTS} with an \verb{S}, while DOS (e.g.,
Eberhard Mattes's emTeX) favors \verb{TEXINPUT} without
the \verb{S}.}
to look for
\slatexdisable{enableslatex}
\verb|\input|
files.


\o \enableslatex
Call the procedure
\scheme{SLaTeX.process-main-tex-file} on the \verb{.tex}
file to be processed.
\slatexdisable{enableslatex}

\o Call either \verb{latex} or \verb{tex} on the \verb{.tex} file.
\end{enumerate}


\enableslatex
You may devise your own way of calling
\scheme{SLaTeX.process-main-tex-file}, provided your
method makes sure that \verb{slatex.scm} has been
loaded, \scheme{SLaTeX.*texinputs*} set appropriately
_before_ the call and \verb{latex}/\verb{tex} is called
_after_ the call.

Note that if you prefer to stay in Scheme/Common Lisp
most of the time, it is a good idea to pre-load the
procedure \scheme{call-slatex}, perhaps through an
"init" file.  \scheme{call-slatex} is just a
"one-liner" "call-by-need" hook to SLaTeX and does not
take up much resources.  (Global name clashes between
your own code and SLaTeX code won't occur unless you
use variable names starting with "\scheme{SLaTeX.}") If
you made no calls to \scheme{call-slatex}, the bigger
file \verb{slatex.scm} is not loaded at all.  If you
make several calls to \scheme{call-slatex},
\verb{slatex.scm} is loaded only once, at the time of
the first call.
\slatexdisable{enableslatex}

\subsection{Dialects SLaTeX runs on}
\index{dialects SLaTeX runs on}

\enableslatex
SLaTeX is implemented in R4RS-compliant Scheme (macros
are not needed).  The code uses the non-standard
procedures \scheme{delete-file},
\scheme{file-exists?} and \scheme{force-output}, but
a Scheme without these procedures can also run SLaTeX
(the configuration defines the corresponding variables
to be dummy procedures, since they are not crucial).
The distribution comes with code to allow SLaTeX to run
also on Common Lisp.  The files \verb{readme} and
\verb{install} contain all the information necessary to
configure SLaTeX for your system.
\slatexdisable{enableslatex}

SLaTeX has been tested successfully in the following
dialects:

\begin{itemize}
\o _On Unix:_
Chez Scheme (R. Kent Dybvig), Ibuki Common
Lisp (1987), MIT C Scheme, Elk (Oliver Laumann),
Scheme-to-C (Joel Bartlett), Scm (Aubrey Jaffer) and
UMB Scheme (William Campbell);

\o _On MS-DOS:_
MIT C Scheme, Scm (Aubrey Jaffer), Austin Kyoto Common
Lisp (William Schelter's enhanced version of Taiichi
Yuasa and Masami Hagiya's KCL) and CLisp (Bruno Haible
and Michael Stoll).
\iffalse PCScheme/Geneva (Larry Bartholdi and
Marc Vuilleumier) \fi
\end{itemize}

If your Scheme is not mentioned here but _is_
R4RS-compliant, please send a note to the author at
\verb{dorai@cs.rice.edu} describing your Scheme's
procedures for deleting files, testing file existence,
and forcing output, if any, and the configuration file
will be enhanced to accommodate the new dialect.

Bug reports are most welcome --- send to
\verb{dorai@cs.rice.edu}.
\index{bug reports}

\begin{thebibliography}{9}
\bibitem{sicp} H. Abelson and G.J.  Sussman with J.
Sussman.  Structure and Interpretation of Computer
Programs.  MIT Press, 1985.

\bibitem{r4rs} W. Clinger and J. Rees, eds.
Revised$^4$ Report on the Algorithmic Language Scheme.
1991.

\bibitem{ll} D.P. Friedman and M.  Felleisen.  The
Little Lisper.  Science Research Associates, 1989.

\bibitem{tex} D.E. Knuth.  The TeXbook.
Addison-Wesley, 1984.

\bibitem{latex} L. Lamport.  LaTeX User's Guide and
Reference Manual.  Addison-Wesley, 1986.

\bibitem{schemeweb} J. Ramsdell. SchemeWeb.  Scheme
Repository, nexus.yorku.ca, maintained by O. Yigit.

\bibitem{lisp2tex} C. Queinnec. LiSP2TeX.  Scheme
Repository.

\bibitem{cltl2} G.L. Steele Jr. Common Lisp: The
Language, 2nd ed. Digital Press, 1990.
\end{thebibliography}

%input slatex-d.ind, the index, if available.
%slatex-d.ind is generated by running
%       makeind(e)x slatex-d
%after running latex on slatex-d.  The next call
%       latex slatex-d
%will include slatex-d.ind

\inputifpossible{slatex-d.ind}

\end{document}

\index{schemedisplay@\verb{schemedisplay}!with plain TeX}
\index{schemebox@\verb{schemebox}!with plain TeX}
\index{schemeregion@\verb{schemeregion}!with plain TeX}