% plain TeX

% FONTS
\font\bbbold=msbm10
\font\bigrm=cmr7 scaled \magstep4
\font\tenmsa=msam10
\font\ninerm=cmr9
\font\ninebf=cmbx9
\font\nineit=cmti9
\font\ninei=cmmi9
\font\eighti=cmmi8
\font\eightrm=cmr8
\font\eightbf=cmbx8
\font\eightit=cmti8
\font\eightsl=cmsl8
\font\eighttt=cmtt8
\font\tenss=cmss10
\font\ninesy=cmsy9
\font\eightsy=cmsy8
\font\nineit=cmti9
\font\sixrm=cmr6
\font\sixbf=cmbx6
\font\sixi=cmmi6
\font\sixsy=cmsy6
\font\sans=cmss10
\font\eightsans=cmss8
\font\sansit=cmssi10
\def\ninepoint{\def\rm{\fam0\ninerm}%
   \textfont0=\ninerm \scriptfont0=\sixrm \scriptscriptfont0=\fiverm
   \textfont1=\ninei \scriptfont1=\sixi \scriptscriptfont1=\fivei
   \textfont2=\ninesy \scriptfont2=\sixsy \scriptscriptfont2=\fivesy
   \textfont3=\tenex \scriptfont3=\tenex \scriptscriptfont3=\tenex
   \textfont\itfam=\nineit \def\it{\fam\itfam\nineit}%
   \textfont\bffam=\ninebf \scriptfont\bffam=\sixbf
    \scriptscriptfont\bffam=\fivebf \def\bf{\fam\bffam\ninebf}%
   \normalbaselineskip=10.5pt
   \setbox\strutbox=\hbox{\vrule height8pt depth 3pt width0pt}%
   \let\big=\ninebig \normalbaselines\rm}
\catcode`@=11
\def\ninebig#1{{\hbox{$\textfont0=\tenrm\textfont2=\tensy
  \left#1\vbox to7.25pt{}\right.\n@space$}}}
\catcode`@=12
\let\Smallskip=\smallskip
\def\SMALL{\ninepoint\def\medskip{}\def\Bigbreak{\Smallskip}\def\smallskip{}}

% MAGNIFICATION
\magnification=\magstep1

% REGISTERS
\newcount\firstpage
\newcount\footno
\newtoks\chaptername
\newtoks\sectionname
\newwrite\raw
\newwrite\tabcon
\newif\ifindexmode

% FORMATING
\hsize=11cm
\vsize=17.5cm
\voffset=2\baselineskip
\hoffset=1.7truecm
\headline={\Headline}
\footline={\Footline}
\def\Headline{\ifnum\firstpage=\pageno \hfil \else\ifodd\pageno%
   \righthead\else\lefthead\fi\fi}
\def\Footline{\ifnum\firstpage=\pageno \hss\tenrm\folio\hss \else{}\fi}
\newif\ifrighthead
%\def\lefthead{\tenrm\folio\hfil{\eightrm CHAPTER \chapno. \uppercase\expandafter{\the\chaptername}}\hfil}
%\def\righthead{\ifrighthead\hfil{\eightrm{\chapno.\botmark}}%
\def\lefthead{\tenrm\folio\hfil{\eightrm{\botmark}}\hfil}
\def\righthead{\ifrighthead\hfil{\eightrm{\botmark}}%
   \hfil\tenrm\folio\else\lefthead\fi}
\let\chapno=0
%\def\chap#1.#2{\chaptername={#2} \firstpage=\pageno 
    %\footno=0 \def\chapno{#1}
   %\hrule width0pt depth1.5cm
   %\centerline{\tenrm CHAPTER\ #1}\vskip .45cm
   %\centerline{\bigrm #2}\vskip 1cm \ifindexmode\write\tabcon%
   %{#1\  #2 \the\count0}\fi}
\def\chap#1{\chaptername={#1} \firstpage=\pageno 
    \footno=0 
   \hrule width0pt depth1.5cm
   \centerline{\bigrm #1}\vskip 1cm}
\def\section#1.#2{\rightheadtrue\forwardtrue\def\sectionname{\eightrm\uppercase{#2}}\bigbreak\noindent{\bf#1.\ #2}\mark{#1.\ \sectionname}\medskip%
   \ifindexmode\write\tabcon{#1 \the\count0}\fi\nobreak}
\def\foot#1{\advance\footno by1 
  {\baselineskip=9pt 
   \setbox\strutbox=\hbox{\vrule height7pt depth2pt width0pt}%
   \def\textindent##1{\indent\llap{##1}}%
   \def\sl{\eightsl}\def\bf{\eightbf}\def\rm{\eightrm}%
   \eightrm\footnote{$^{\the\footno}$}{#1}}}
\def\footnoterule{}
\skip\footins=\medskipamount
\def\poetry{\smallbreak\parindent=40pt \baselineskip=11pt
  \setbox\strutbox=\hbox{\vrule height8pt depth3pt width 0pt}%
   \obeylines\ninerm}% LEAVE BLANK LINE AND TYPE {\poetry <poem>
%                                                                 }
\def\endchap{\ifodd\pageno\vfill\supereject\headline={\hfil}\eject\line{}\vfil\eject\else\vfill\supereject\fi\headline={\Headline}\rightheadfalse\footno=0}

% VERBATIM
\def\uncatcodespecials{\def\do##1{\catcode`##1=12 }\dospecials}
\def\setupverbatim{\eighttt\hyphenpenalty=10000\def\par{\leavevmode\endgraf}\obeylines\uncatcodespecials\catcode`"=12\catcode`/=12\def~{\hbox{\eighttt\char'176}}\def/{\hbox{\eighttt\char'057}}\obeyspaces}
{\obeyspaces\global\let =\ }
\def\|{\begingroup\setupverbatim\doverbatim}
\def\doverbatim#1#2{\def\next##1#1#2{##1\endgroup}\next}

% INDEXING
\def\ind#1{\ifindexmode\write\raw{#1, \the\count0 }#1\else#1\fi}
\def\sind#1{\ifindexmode\write\raw{#1, \the\count0 }\fi}
\def\ii#1.{\ifindexmode\write\raw{#1, \the\count0 }{\it#1}%
   \else{\it#1}\fi}
\def\b[#1]{\sind{#1]}[#1]}

% TEXT MACROS
\let\Sec=\S
\newif\ifforward
\def\Medbreak{\forwardtrue\medbreak}
\def\Bigbreak{\ifforward\medbreak\else\bigbreak\fi\forwardfalse}
\def\bul{\vrule height .7ex width .6ex depth -.1ex }

% TEXT OR MATH MACROS
\def\cali#1{\hbox{$\cal#1$}}
\def\bbb#1{\hbox{\bbbold#1}}
\def\san#1{\hbox{\sans#1}}
\def\ro#1{{\rm#1}}
\let\hyphen=\-
\def\-{\relax\hyphen}
\def\bull{\vrule height .9ex width .8ex depth -.1ex }
\def\bul{\vrule height .7ex width .6ex depth -.1ex }
\def\ro#1{{\rm #1}}
\def\T{\hbox{\sans t}}
\def\f{\hbox{\sans f}}

% QEF MACROS
\let\umlaut=\"

% MATH MACROS
\def\teq{\mathop{\tilde=}}
\def\amp{\mathrel{\&}}
\def\tuple#1.{\langle#1\rangle}
\def\.{\cdot}
\def\S{{\rm S}}
\def\Pair(#1,#2){\langle#1,#2\rangle}
\def\rz{\mathrel{\hbox{\sl rz\/}}}
\def\vf{\mathrel{\hbox{\sl vf\/}}}
%\def\ul{\raise2.0pt\hbox{\tenmsa\char"70}}
%\def\ur{\raise2.0pt\hbox{\tenmsa\char"71}}
\def\ul{\hbox{\tenmsa\char"70}\!}
\def\ur{\!\hbox{\tenmsa\char"71}}
\def\'#1'{{}$#1$\hskip1pt}
\def\too{\leftrightarrow}
\let\slash=/
\def\ent{\mathrel{\;\slash\;}}
\def\tneg{\mathrel{\tilde\neg}}
\def\tamp{\mathrel{\tilde\&}}
\def\tto{\mathrel{\tilde\to}}
