~ chicken-core (chicken-5) /tests/slatex.sty
Trap1% slatex.sty2% SLaTeX v. 2.23% style file to be used in (La)TeX when using SLaTeX4% (c) Dorai Sitaram, Rice U., 1991, 199456% This file (or a soft link to it) should be in some7% directory in your TEXINPUTS path (i.e., the one8% (La)TeX scours for \input or \documentstyle option9% files).1011% Do not attempt to debug this file, since the results12% are not transparent just to (La)TeX. The Scheme part13% of SLaTeX depends on information laid out here -- so14% (La)TeX-minded debugging of this file will almost15% inevitably sabotage SLaTeX.1617% It's possible you don't find the default style set18% out here appealing: e.g., you may want to change the19% positioning of displayed code; change the fonts for20% keywords, constants, and variables; add new keywords,21% constants, and variables; use your names instead of22% the provided \scheme, [\begin|\end]{schemedisplay},23% [\begin|\end]{schemebox}, (or \[end]schemedisplay,24% \[end]schemebox for TeX), which might be seem too25% long or unmnemonic, and many other things. The clean26% way to do these things is outlined in the27% accompanying manual, slatex-d.tex. This way is both28% easier than messing with this .sty file, and safer29% since you will not unwittingly break SLaTeX.303132%%%3334% to prevent loading slatex.sty more than once3536\ifx\slatexignorecurrentfile\UNDEFINED37\else\endinput\fi3839% use \slatexignorecurrentfile to disable slatex for40% the current file. (Unstrangely, the very definition41% disables slatex for the rest of _this_ file, slatex.sty.)4243\def\slatexignorecurrentfile{}4445% checking whether we're using LaTeX or TeX?4647\newif\ifusinglatex48\ifx\newenvironment\UNDEFINED\usinglatexfalse\else\usinglatextrue\fi4950% make @ a letter for TeX51\ifusinglatex\relax\else52\edef\atcatcodebeforeslatex{\the\catcode`@}53\catcode`@1154\fi5556% identification of TeX/LaTeX style for schemedisplay.57% Do \defslatexenvstyle{tex} to get TeX environment58% style in LaTeX59\def\defslatexenvstyle#1{\gdef\slatexenvstyle{#1}}6061\ifusinglatex\defslatexenvstyle{latex}\else\defslatexenvstyle{tex}\fi6263% TeX doesn't have sans-serif; use roman instead64\ifx\sf\UNDEFINED\def\sf{\rm}\fi6566% tabbing from plain TeX67%68\newif\ifus@ \newif\if@cr69\newbox\tabs \newbox\tabsyet \newbox\tabsdone70%71\def\cleartabs{\global\setbox\tabsyet\null \setbox\tabs\null}72\def\settabs{\setbox\tabs\null \futurelet\next\sett@b}73\let\+=\relax % in case this file is being read in twice74\def\sett@b{\ifx\next\+\let\next\relax75 \def\next{\afterassignment\s@tt@b\let\next}%76\else\let\next\s@tcols\fi\next}77\def\s@tt@b{\let\next\relax\us@false\m@ketabbox}78\def\tabalign{\us@true\m@ketabbox} % non-\outer version of \+79\outer\def\+{\tabalign}80\def\s@tcols#1\columns{\count@#1 \dimen@\hsize81 \loop\ifnum\count@>\z@ \@nother \repeat}82\def\@nother{\dimen@ii\dimen@ \divide\dimen@ii\count@83 \setbox\tabs\hbox{\hbox to\dimen@ii{}\unhbox\tabs}%84 \advance\dimen@-\dimen@ii \advance\count@\m@ne}85%86\def\m@ketabbox{\begingroup87 \global\setbox\tabsyet\copy\tabs88 \global\setbox\tabsdone\null89 \def\cr{\@crtrue\crcr\egroup\egroup90 \ifus@\unvbox\z@\lastbox\fi\endgroup91 \setbox\tabs\hbox{\unhbox\tabsyet\unhbox\tabsdone}}%92 \setbox\z@\vbox\bgroup\@crfalse93 \ialign\bgroup&\t@bbox##\t@bb@x\crcr}94%95\def\t@bbox{\setbox\z@\hbox\bgroup}96\def\t@bb@x{\if@cr\egroup % now \box\z@ holds the column97 \else\hss\egroup \global\setbox\tabsyet\hbox{\unhbox\tabsyet98 \global\setbox\@ne\lastbox}% now \box\@ne holds its size99 \ifvoid\@ne\global\setbox\@ne\hbox to\wd\z@{}%100 \else\setbox\z@\hbox to\wd\@ne{\unhbox\z@}\fi101 \global\setbox\tabsdone\hbox{\box\@ne\unhbox\tabsdone}\fi102 \box\z@}103% finished (re)defining TeX's tabbing macros104105% above from plain.tex; was disabled in lplain.tex. Do106% not modify above unless you really know what you're107% up to. Make all changes you want to following code.108% The new env is preferable to LaTeX's tabbing env109% since latter accepts only a small number of tabs110111% following retrieves something like LaTeX's tabbing112% env without the above problem (it also creates a box113% for easy manipulation!)114115\def\lat@xtabbing{\leavevmode\hbox\bgroup\vbox\bgroup116 \def\={\cleartabs&} \def\>{&} \def\\{\cr\tabalign} \tabalign}117\def\endlat@xtabbing{\cr\egroup\egroup}118119%new120121\def\lat@xtabbing{\begingroup122\def\={\cleartabs&} \def\>{&}%123\def\\{\cr\tabalign\lat@xtabbingleftmost}%124\tabalign\lat@xtabbingleftmost}125\def\endlat@xtabbing{\cr\endgroup}126\let\lat@xtabbingleftmost\relax127128% stuff for formating Scheme code129130\newskip\par@nlen \newskip\brack@tlen \newskip\quot@len131\newskip\h@lflambda132133\newbox\garb@ge134\def\s@ttowidth#1#2{\setbox\garb@ge\hbox{#2}#1\wd\garb@ge\relax}135136\s@ttowidth\par@nlen{$($} % size of paren137\s@ttowidth\brack@tlen{$[$} % size of bracket138\s@ttowidth\quot@len{'} % size of quote indentation139\s@ttowidth\h@lflambda{ii} % size of half of lambda indentation140141\def\PRN{\hskip\par@nlen} % these are used by SLaTeX's codesetter142\def\BKT{\hskip\brack@tlen}143\def\QUO{\hskip\quot@len}144\def\HL{\hskip\h@lflambda}145146\newskip\abovecodeskip \newskip\belowcodeskip147\newskip\leftcodeskip \newskip\rightcodeskip148149% the following default assignments give a flushleft150% display151152\abovecodeskip=\medskipamount \belowcodeskip=\medskipamount153\leftcodeskip=0pt \rightcodeskip=0pt154155% adjust above,below,left,right codeskip's to personal156% taste157158% for centered displays159%160% \leftcodeskip=0pt plus 1fil161% \rightcodeskip=0pt plus 1fil162%163% if \rightcodeskip != 0pt, pagebreaks within Scheme164% blocks in {schemedisplay} are disabled165166\def\checkfollpar{\futurelet\next\checkfollparII}167\def\checkfollparII{\ifx\next\par\let\next\relax168\else\par\noindent\let\next\ignorespaces\fi\next}169170% the following are the default font assignments for171% words in code. Change them to suit personal taste172173\def\keywordfont#1{{\bf #1}}174\def\variablefont#1{{\it #1\/}}175\def\constantfont#1{{\sf #1}}176\def\datafont#1{\constantfont{#1}}177178\def\schemecodehook{}179180%program listings that allow page breaks but181%can't be centered182183\def\ZZZZschemedisplay{\edef\thez@skip{\the\z@skip}%184\edef\@tempa{\the\rightcodeskip}%185\ifx\@tempa\thez@skip\let\next\ZZZZschemeprogram186\else\let\next\ZZZZschemeprogramII\fi\next}187188\def\endZZZZschemedisplay{\edef\thez@skip{\the\z@skip}%189\edef\@tempa{\the\rightcodeskip}%190\ifx\@tempa\thez@skip\let\next\endZZZZschemeprogram191\else\let\next\endZZZZschemeprogramII\fi\next}192193\def\ZZZZschemeprogram{\vskip\abovecodeskip194\begingroup195\schemecodehook196\let\sy=\keywordfont \let\cn=\constantfont197\let\va=\variablefont \let\dt=\datafont198\def\lat@xtabbingleftmost{\hskip\leftcodeskip\relax}%199\lat@xtabbing}200201\def\endZZZZschemeprogram{\endlat@xtabbing202\endgroup203\vskip\belowcodeskip204\ifusinglatex\let\next\@endparenv205\else\let\next\checkfollpar\fi\next}206207\def\ZZZZschemeprogramII{\vskip\abovecodeskip208\begingroup209\noindent210%\schemecodehook %\ZZZZschemebox already has it211\hskip\leftcodeskip212\ZZZZschemebox}213214\def\endZZZZschemeprogramII{\endZZZZschemebox215\hskip\rightcodeskip216\endgroup217\vskip\belowcodeskip218\ifusinglatex\let\next\@endparenv219\else\let\next\checkfollpar\fi\next}220221%222223\def\ZZZZschemebox{%224\leavevmode\hbox\bgroup\vbox\bgroup225\schemecodehook226\let\sy=\keywordfont \let\cn=\constantfont227\let\va=\variablefont \let\dt=\datafont228\lat@xtabbing}229\def\endZZZZschemebox{\endlat@xtabbing230\egroup\egroup\ignorespaces}231232%in-text233234\def\ZZZZschemecodeintext{\begingroup235 \let\sy\keywordfont \let\cn\constantfont236 \let\va\variablefont \let\dt\datafont}237238\def\endZZZZschemecodeintext{\endgroup\ignorespaces}239240\def\ZZZZschemeresultintext{\begingroup241 \let\sy\datafont \let\cn\constantfont242 \let\va\datafont \let\dt\datafont}243244\def\endZZZZschemeresultintext{\endgroup\ignorespaces}245246% \comm@nt<some-char>...text...<same-char> comments out247% TeX source analogous to248% \verb<some-char>...text...<same-char>. Sp. case:249% \comm@nt{...text...} == \comm@nt}...text...}250251\def\@makeother#1{\catcode`#112\relax}252253\def\comm@nt{%254 \begingroup255 \let\do\@makeother \dospecials256 \@comm}257258\begingroup\catcode`\<1\catcode`\>2259\catcode`\{12\catcode`\}12260\long\gdef\@comm#1<%261 \if#1{\long\def\@tempa ##1}<\endgroup>\else262 \long\def\@tempa ##1#1<\endgroup>\fi263 \@tempa>264\endgroup265266% input file if possible, else relax267268\def\inputifpossible#1{%269 \immediate\openin0=#1\relax%270 \ifeof0\relax\else\input#1\relax\fi%271 \immediate\closein0}272273\def\ZZZZinput#1{\input#1\relax}274275% you may replace the above by276%277% \def\ZZZZinput#1{\inputifpossible{#1}}278%279% if you just want to call (La)TeX on your text280% ignoring the portions that need to be SLaTeX'ed281282%use \subjobname rather than \jobname to generate283%slatex's temp files --- this allows us to change284%\subjobname for more control, if necessary.285286\let\subjobname\jobname287288% counter for generating temp file names289290\newcount\sch@mefilenamecount291\sch@mefilenamecount=-1292293% To produce displayed Scheme code:294% in LaTeX:295% \begin{schemedisplay}296% ... indented program (with sev'l lines) ...297% \end{schemedisplay}298%299% in TeX:300% \schemedisplay301% ... indented program (with sev'l lines) ...302% \endschemedisplay303304\begingroup\catcode`\|=0\catcode`\[=1\catcode`\]=2%305\catcode`\{=12\catcode`\}=12\catcode`\\=12%306|gdef|defschemedisplaytoken#1[%307 |long|expandafter|gdef|csname ZZZZcomment#1|endcsname[%308 |begingroup309 |let|do|@makeother |dospecials310 |csname ZZZZcomment|slatexenvstyle II#1|endcsname]%311 |long|expandafter|gdef|csname ZZZZcommentlatexII#1|endcsname##1\end{#1}[%312 |endgroup|end[#1]]%313 |long|expandafter|gdef|csname ZZZZcommenttexII#1|endcsname##1\end#1[%314 |endgroup|csname end#1|endcsname]%315 |long|expandafter|gdef|csname #1|endcsname[%316 |global|advance|sch@mefilenamecount by 1|relax%317 |ZZZZinput[|filehider Z|number|sch@mefilenamecount|subjobname.tex]%318 |csname ZZZZcomment#1|endcsname]%319 |long|expandafter|gdef|csname end#1|endcsname[]]%320|endgroup321322\defschemedisplaytoken{schemedisplay}323324\def\undefschemedisplaytoken#1{%325 \expandafter\gdef\csname#1\endcsname{\UNDEFINED}}326327% \scheme|...program fragment...| produces Scheme code328% in-text. Sp. case: \scheme{...} == \scheme}...}329330\def\defschemetoken#1{%331 \long\expandafter\def\csname#1\endcsname{%332 \global\advance\sch@mefilenamecount by 1\relax%333 \ZZZZinput{\filehider Z\number\sch@mefilenamecount\subjobname.tex}%334 \comm@nt}}335\defschemetoken{scheme}336337\def\undefschemetoken#1{%338 \expandafter\gdef\csname#1\endcsname{\UNDEFINED}}339340% \schemeresult|...program fragment...| produces a341% Scheme code result in-text: i.e. keyword or variable342% fonts are replaced by the data font. Sp. case:343% \schemeresult{...} == \schemeresult}...}344345\def\defschemeresulttoken#1{%346 \long\expandafter\def\csname#1\endcsname{%347 \global\advance\sch@mefilenamecount by 1\relax%348 \ZZZZinput{\filehider Z\number\sch@mefilenamecount\subjobname.tex}%349 \comm@nt}}350\defschemeresulttoken{schemeresult}351352\def\undefschemeresulttoken#1{%353 \expandafter\gdef\csname#1\endcsname{\UNDEFINED}}354355% To produce a box of Scheme code:356% in LaTeX:357% \begin{schemebox}358% ... indented program (with sev'l lines) ...359% \end{schemebox}360%361% in TeX:362% \schemebox363% ... indented program (with sev'l lines) ...364% \endschemebox365366\begingroup\catcode`\|=0\catcode`\[=1\catcode`\]=2%367\catcode`\{=12\catcode`\}=12\catcode`\\=12%368|gdef|defschemeboxtoken#1[%369 |long|expandafter|gdef|csname ZZZZcomment#1|endcsname[%370 |begingroup371 |let|do|@makeother |dospecials372 |csname ZZZZcomment|slatexenvstyle II#1|endcsname]%373 |long|expandafter|gdef|csname ZZZZcommentlatexII#1|endcsname##1\end{#1}[%374 |endgroup|end[#1]]%375 |long|expandafter|gdef|csname ZZZZcommenttexII#1|endcsname##1\end#1[%376 |endgroup|csname end#1|endcsname]%377 |long|expandafter|gdef|csname #1|endcsname[%378 |global|advance|sch@mefilenamecount by 1|relax%379 |ZZZZinput[|filehider Z|number|sch@mefilenamecount|subjobname.tex]%380 |csname ZZZZcomment#1|endcsname]%381 |long|expandafter|gdef|csname end#1|endcsname[]]%382|endgroup383384\defschemeboxtoken{schemebox}385386\def\undefschemeboxtoken#1{%387 \expandafter\gdef\csname#1\endcsname{\UNDEFINED}}388389% for wholesale dumping of all-Scheme files into TeX (converting390% .scm files to .tex),391% use392% \schemeinput{<filename>}393% .scm, .ss, .s extensions optional394395\def\defschemeinputtoken#1{%396 \long\expandafter\gdef\csname#1\endcsname##1{%397 \global\advance\sch@mefilenamecount by 1\relax%398 \ZZZZinput{\filehider Z\number\sch@mefilenamecount\subjobname.tex}}}399\defschemeinputtoken{schemeinput}400401\def\undefschemeinputtoken#1{%402 \expandafter\gdef\csname#1\endcsname{\UNDEFINED}}403404% delineating a region that features typeset code405% not usually needed, except when using \scheme and schemedisplay406% inside macro-args and macro-definition-bodies407% in LaTeX:408% \begin{schemeregion}409% ...410% \end{schemeregion}411%412% in TeX:413% \schemeregion414% ...415% \endschemeregion416417\begingroup\catcode`\|=0\catcode`\[=1\catcode`\]=2%418\catcode`\{=12\catcode`\}=12\catcode`\\=12%419|gdef|defschemeregiontoken#1[%420 |long|expandafter|gdef|csname ZZZZcomment#1|endcsname[%421 |begingroup422 |let|do|@makeother |dospecials423 |csname ZZZZcomment|slatexenvstyle II#1|endcsname]%424 |long|expandafter|gdef|csname ZZZZcommentlatexII#1|endcsname##1\end{#1}[%425 |endgroup|end[#1]]%426 |long|expandafter|gdef|csname ZZZZcommenttexII#1|endcsname##1\end#1[%427 |endgroup|csname end#1|endcsname]%428 |long|expandafter|gdef|csname #1|endcsname[%429 |global|advance|sch@mefilenamecount by 1|relax%430 |ZZZZinput[|filehider Z|number|sch@mefilenamecount|subjobname.tex]%431 |csname ZZZZcomment#1|endcsname]%432 |long|expandafter|gdef|csname end#1|endcsname[]]%433|endgroup434435\defschemeregiontoken{schemeregion}436437\def\undefschemeregiontoken#1{%438 \expandafter\gdef\csname#1\endcsname{\UNDEFINED}}439440% introducing new code-tokens to the keyword, variable and constant441% categories442443\def\comm@ntII{%444 \begingroup445 \let\do\@makeother \dospecials446 \@commII}447448\begingroup\catcode`\[1\catcode`\]2449\catcode`\{12\catcode`\}12450\long\gdef\@commII{[%451 \long\def\@tempa ##1}[\endgroup]\@tempa]%452\endgroup453454\let\setkeyword\comm@ntII455\let\setvariable\comm@ntII456\let\setconstant\comm@ntII457458% \defschememathescape makes the succeeding grouped character an459% escape into latex math from within Scheme code;460% this character can't be }461462\let\defschememathescape\comm@ntII463\let\undefschememathescape\comm@ntII464465% telling SLaTeX that a certain Scheme identifier is to466% be replaced by the specified LaTeX expression.467% Useful for generating ``mathematical''-looking468% typeset code even though the corresponding Scheme469% code is ascii as usual and doesn't violate470% identifier-naming rules471472\def\setspecialsymbol{%473 \begingroup474 \let\do\@makeother \dospecials475 \@commIII}476477\begingroup\catcode`\[1\catcode`\]2478\catcode`\{12\catcode`\}12479\long\gdef\@commIII{[%480 \long\def\@tempa ##1}[\endgroup\@gobbleI]\@tempa]%481\endgroup482483\def\@gobbleI#1{}484485% \unsetspecialsymbol strips Scheme identifier(s) of486% any ``mathematical'' look lent by the above487488\let\unsetspecialsymbol\comm@ntII489490% enabling/disabling slatex491492\def\slatexdisable#1{\expandafter\gdef\csname#1\endcsname{}}493494% \schemecasesensitive takes either true or false as495% argument496497\def\schemecasesensitive#1{}498499%for latex only: use \slatexseparateincludes before the500%occurrence of any Scheme code in your file, if you501%want the various \include'd files to have their own502%pool of temporary slatex files. This lets you juggle503%your \include's in successive runs of LaTeX without504%having to worry that the temp. files may interfere.505%By default, only a single pool of temp files is used.506%Warning: On DOS, if your \include'd files have fairly507%similar names, avoid \slatexseparateincludes since the508%short filenames on DOS will likely confuse the temp509%file pools of different \include files.510511\def\slatexseparateincludes{%512\gdef\include##1{{\def\subjobname{##1}%513\sch@mefilenamecount=-1%514\@include##1 }}}515516% convenient abbreviations for characters517518\begingroup519\catcode`\|=0520|catcode`|\=12521|gdef|ttbackslash{{|tt|catcode`|\=12\}}522|endgroup523\mathchardef\lt="313C524\mathchardef\gt="313E525\begingroup526 \catcode`\@12%527 \global\let\atsign@%528\endgroup529\chardef\dq=`\"530531% leading character of slatex filenames: . for unix to532% keep them out of the way533534\def\filehider{.}535536% since the above doesn't work of dos, slatex on dos537% will use a different character, and make the538% redefinition available through the following539540\inputifpossible{xZfilhid.tex}541542% @ is no longer a letter for TeX543544\ifusinglatex\relax\else545\catcode`@\atcatcodebeforeslatex546\fi547548\message{*** Check: Are you sure you called SLaTeX? ***}