summaryrefslogtreecommitdiff
path: root/macros/plain/contrib/misc/verbatim.mac
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/plain/contrib/misc/verbatim.mac
Initial commit
Diffstat (limited to 'macros/plain/contrib/misc/verbatim.mac')
-rw-r--r--macros/plain/contrib/misc/verbatim.mac56
1 files changed, 56 insertions, 0 deletions
diff --git a/macros/plain/contrib/misc/verbatim.mac b/macros/plain/contrib/misc/verbatim.mac
new file mode 100644
index 0000000000..b0c5d1ce6d
--- /dev/null
+++ b/macros/plain/contrib/misc/verbatim.mac
@@ -0,0 +1,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").