summaryrefslogtreecommitdiff
path: root/macros/plain/contrib/misc/fortran.tex
blob: 93aa198de9dec19d94fbf4e2cb3769863a98eacd (plain)
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
%%%---Cut Here--------------------------------------------------------
%%% File: Fortran.TeX
% 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
\def\uncatcodespecials{\def\do##1{\catcode`##1=12 }\dospecials}
\def\listing#1{\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{\advance\lineno by1
    \llap{\Alistrm\the\lineno\ \ }\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}}
%%%---Cut Here--------------------------------------------------------