summaryrefslogtreecommitdiff
path: root/macros/plain/contrib/misc/verbatim.mac
blob: b0c5d1ce6d6322c29bd696a6a07214b2651fe4f8 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
%   ttbar.tex
 
 
% Lifted from TUGBOT.STY.
%
%       Support verbatim listing of TeX source, as defined in TeXbook, p. 421;
%       lifted from MANMAC.TEX, and modified slightly for narrower columns.
 
\chardef\other=12
\def\ttverbatim{\begingroup \catcode`\\=\other
  \catcode`\{=\other \catcode`\}=\other \catcode`\$=\other
  \catcode`\&=\other \catcode`\#=\other \catcode`\%=\other
  \catcode`\~=\other \catcode`\_=\other \catcode`\^=\other
  \catcode`\"=\other
  \obeyspaces \obeylines \tt}
 
\newskip\ttglue
{\tenpoint\tt \global\ttglue=.5em plus .25em minus .15em}
% this should be installed in each font
 
%       From David Eppstein's ``Trees'' paper (6#1), preserve initial spaces.
{\obeyspaces\gdef {\ifvmode\indent\fi\space}}
 
\newdimen\ttrightskip
\ttrightskip=5pc
 
\newif\ifttVertChar \ttVertCharfalse
{\catcode`\|=\active \gdef\VertChar{\def|{\char"7C }}}
 
%\outer\def\begintt{$$\let\par=\endgraf \ttverbatim \parskip=\z@
\outer\def\begintt{$$\def\par{\leavevmode\null\endgraf}\ttverbatim \parskip=\z@
  \ifttVertChar \VertChar \global\ttVertCharfalse \else \catcode`\|=0 \fi
  \catcode`\|=0 \rightskip=-\ttrightskip \ttfinish}
{\catcode`\|=0 |catcode`|\=\other % | is temporary escape character
  |obeylines % end of line is active
  |gdef|ttfinish#1^^M#2\endtt{#1|vbox{#2}|endgroup$$}}
 
%       Other non-tt elements that may be embedded within \begintt...\endtt .
\def\MTH{$}
\def\sb{_}
\def\sp{^}
\def\SP{{\tt\char"20 }}  % "visible" space
\chardef\bs=`\\
\def\vrt{{\tt\char`\|}}
 
\catcode`\|=\active
%{\obeylines \gdef|{\ttverbatim \spaceskip\ttglue \let^^M=\  \let|=\endgroup}}
{\obeylines \gdef\activatettbar{\global\catcode`\|=\active %
  \gdef|{\ttverbatim \spaceskip\ttglue \xspaceskip\ttglue %
         \let^^M=\  \let|=\endgroup}}}
\activatettbar
 
% The active | (which here implements verbatim mode) is redefined in
% such headers as TABLES.TeX and must be able to be reinstated.
% \activatettbar been tested with TABLES.TeX, and the two uses are
% mutually operable (TUGboat 7#2, "Tables in INRSTeX").