diff options
Diffstat (limited to 'macros/plain/contrib/misc/listing.mac')
-rw-r--r-- | macros/plain/contrib/misc/listing.mac | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/macros/plain/contrib/misc/listing.mac b/macros/plain/contrib/misc/listing.mac new file mode 100644 index 0000000000..6be5e4ab04 --- /dev/null +++ b/macros/plain/contrib/misc/listing.mac @@ -0,0 +1,63 @@ +\input 17Point.TeX +\input 14Point.TeX +\input 12Point.TeX +\tenpoint +% This is a file of commands for printing out programs using TeX +% -- see DIRTY TRICKS in TeXbook +% +% This version is designed to print source code at 9 point +% fitting an 80 column line into a 6 true inch width with +% 8 point line numbers before each line. +% It handles TAB (^I) characters almost the same as DEC +% +% usage: +% \input fortran % put this early in the file +% \listing{file.ext} % use dev:[dir] if you wish +% +% B.H. Toby 8/86 +% +\newcount\lineno +\font\Alisttt=cmtt9 at 9 truept +\font\Alistrm=cmr8 at 8 truept +\font\fourteentt=cmtt10 at 14.4 truept +\font\titlefont=cmbx12 scaled 1440 +\newcount\partpageno +\def\uncatcodespecials{\def\do##1{\catcode`##1=12 }\dospecials} +\def\listing#1{\mark{\currentsection \noexpand\else #1} + \penalty-200\vskip18pt plus4pt minus6pt + \leftline{\fourteentt #1} + \mark{#1\noexpand\else #1} \def\currentsection{#1} + \nobreak\smallskip + \par\begingroup\setupverbatim\input#1 \endgroup} +\def\setupverbatim{ + \Alisttt\baselineskip= 8.5truept\lineskip=1truept + \lineskiplimit=1truept\topskip=0pt + \lineno=0 + \def\par{\leavevmode\egroup\box0\endgraf} + \obeylines \uncatcodespecials \obeyspaces + \catcode`\`=\active \catcode`\^^I=\active + \everypar{\startbox}} +\newdimen\w \setbox0=\hbox{\Alisttt\space} \w=8\wd0 +\def\startbox{\setbox0=\hbox\bgroup} +{\catcode`\^^I=\active + \gdef^^I{\leavevmode\egroup + \dimen0=\wd0 + \divide\dimen0 by\w + \multiply\dimen0 by\w + \advance\dimen0 by\w + \wd0=\dimen0 \box0 \startbox}} +{\obeyspaces\global\let =\ } +{\catcode`\`=\active \gdef`{\relax\lq}} + +\def\header#1{\vfill\eject\null\medskip\centerline{\fourteenpoint\bf #1}\bigskip + \message{\noexpand#1}\def\part{#1}\partpageno=\count0} + +\def\title#1{\pageno=0\null\vfill\centerline{\seventeenpoint\bf#1}} + +\def\currentsection{} + +\headline{\ifnum\pageno=\partpageno\hfill\else + \ifodd\pageno{\bf\part}\hss{\tt\iftrue\botmark\fi} + \else{\tt\expandafter\iffalse\topmark\fi}\hss{\bf\part}\fi\fi} +\footline{\ifnum\pageno=0\hfil\else\hfil\tenbf\folio\hfil\fi} + |