% Latex Macros for Lisp code in text. % Based on macros found in C. Rich's library. \makeatletter % \vobeyspaces turns all spaces into non-breakable spaces. % Note: this is like \@vobeyspaces except without spurious space in defn. {\catcode`\ =\active\gdef\vobeyspaces{\catcode`\ =\active\let =\@xobeysp}} % \def\vobeytabs turns all tabs into 8 non-breakable spaces {\catcode`\^^I=\active\gdef\vobeytabs{\catcode`\^^I=\active\let^^I=\xvobeytabs}} \def\xvobeytabs{\@xobeysp\@xobeysp\@xobeysp\@xobeysp\@xobeysp\@xobeysp\@xobeysp\@xobeysp} % \vobeylines turns all cr's into non-breakable \par's {\catcode`\^^M=\active\gdef\vobeylines{\catcode`\^^M=\active\let^^M=\xvobeylines}} \def\xvobeylines{\par\penalty10000} % \obeycrsp turns cr's into non-breakable spaces {\catcode`\^^M=\active\gdef\obeycrsp{\catcode`\^^M=\active\let^^M=\@xobeysp}} %% \@noligs prevents ?` and !` from being treated as ligatures %% added 19 April 86 [copied from Latex sources] \begingroup \catcode``=13 \gdef\@noligs{\let`=\@lquote} \endgroup % Set up code environment, in which most of the common special characters % appearing in code are treated verbatim, namely: _ # & ^ $ ~ @ " % % *** JAR NEEDED $ AND _ IN SOME CODE *** % Note: \ { } are still enabled so that macros can be called in this % environment. Use \\, \{ and \} to use these characters verbatim % in this environment. % Note: this environment allows no breaking of lines whatsoever; not % at spaces or hypens. To arrange for a break use the standard \- macro, % or the \= macro which breaks, but inserts nothing. This is useful, % for example for allowing hypenated identifiers to be broken, e.g. % FOO-\=BAR. \def\setupcode{\parsep=0pt\parindent=0pt \tt\frenchspacing\catcode``=13\@noligs% \def\\{\char`\\}% \@makeother\#\@makeother\&\@makeother\^%\@makeother\_\@makeother\$% \@makeother\`\@makeother\'% \@makeother\~\@makeother\@\@makeother\"\@makeother\%\vobeytabs\vobeyspaces} % Code environment as described above. Note that blank lines are % not preserved, and lines are not kept on one page. Code is % indented by the same amount as quotes. % Note: to increase left margin, use \leftmargini=1in. % was {\list{}{\parsep=0pt}\item[]\setupcode\obeylines}% % then {\list{\parsep=0pt\listparindent=0pt\leftmargin=0pt}{}\item[]\setupcode% \newenvironment{bigcode}% {\list{}{\parsep=0pt\leftmargin=0pt\labelwidth=0pt\itemindent=0pt% \listparindent=0pt}\item[]\setupcode% \obeylines}% {\endlist} % Code is just like bigcode, but everything inside is kept on one page % Note: This actually works by setting a huge penalty for breaking % between lines of code. % was {\list{}{\parsep=0pt}\item[]\setupcode\vobeylines}% \newenvironment{code}% {\list{}{\parsep=0pt\leftmargin=0pt\labelwidth=0pt\itemindent=0pt% \listparindent=0pt}\item[]\setupcode% \vobeylines}% {\endlist} % Reasonable separation between lines of code \newcommand{\codeskip}{\penalty0\vspace{2ex}} % \cd is used to build a code environment in the middle of text. % Note: only difference from display code is that cr's are taken % as unbreakable spaces instead of \par's. \newcommand{\cd}{\begingroup\setupcode\obeycrsp\startcode} \newcommand{\startcode}[1]{#1\endgroup} %\setbox0\hbox{\@xobeysp}\hline{43\wd0} \makeatother