% This should be compiled with plain TeX
\vsize = 25cm
\magnification=\magstephalf
\parskip=6pt plus 1pt minus 1pt

\newcount\chapno
\newcount\secno
\newcount\subsecno
\newcount\subsubsecno
\newwrite\toc
\newwrite\index

\openout\toc=\jobname.toc
\openout\index=\jobname.idx
\chapno=0

\def\sref#1{{\write\index{!#1!\the\pageno!}}}
\def\ref#1{\sref{#1}#1}
\def\hwrite#1#2{{\let\the=0\edef\next{\write#1{#2}}\next}} %cf TeXBook Exercice 21.10

\def\title#1{\ifodd\pageno\else\hbox{}\vfill\eject\fi
             \hwrite\toc{#1\string\dotfill\the\pageno}
             \centerline{#1}\vskip1cm}
\def\sectitle#1{\hwrite\toc{\hskip0.5cm#1\string\dotfill\the\pageno}
             \medskip\medskip\noindent{\bf{#1}}\medskip\nobreak}
\def\subsectitle#1{\hwrite\toc{{\sevenrm\hskip1cm#1\string\dotfill\the\pageno}}
             \smallskip{\bf{#1}}\nobreak}
\def\subsubsectitle#1{\hwrite\toc{{\sevenrm\hskip1.5cm#1\string\dotfill\the\pageno}}
             \smallskip{\bf{#1}}\nobreak}

\def\chapter#1{
    \advance\chapno by1\secno=0
    \title{Chapter \number\chapno: #1}}
\def\section#1{
    \advance\secno by1\subsecno=0
    \sectitle{\number\chapno.\number\secno\ #1}}
\def\subsec#1{
    \advance\subsecno by 1\subsubsecno=0
    \subsectitle{\number\chapno.\number\secno.\number\subsecno\ #1}}
\def\subsubsec#1{
    \advance\subsubsecno by1
    \subsubsectitle{\number\chapno.\number\secno.\number
    \subsecno.\number\subsubsecno\ #1}}

\def\subsecref#1{\sref{#1}\subsec{#1}}
\def\subsubsecref#1{\sref{#1}\subsubsec{#1}}

\def\Bbb#1{{\bf #1}}
\def\curl{\cal}
\def\mod{\,{\rm mod}\,}
\def\varprojlim{{\displaystyle\lim_{\textstyle\longleftarrow}}}
\def\text#1{{\rm#1}}
\def\teb#1{{\bf\ref{#1}}}
\def\dfrac#1#2{{{#1}\over{#2}}}
\def\binom#1#2{\pmatrix{{#1}\cr{#2}}}

{
\nopagenumbers
\input titlepage
}
\pageno=1
\input usersch1
\input usersch2
\input usersch3
\input usersch4
\input appa
\input appb
\input appc
\input appd

\immediate\write\toc{Index\string\dotfill73}
\immediate\closeout\toc
\pageno=-1
\def\dotfill{\leaders\hbox to 3truemm{\hfil.\hfil}\hfill}
\title {Table of Contents}
\parskip=0pt plus 1pt
\parindent=0pt
\obeylines
\input\jobname.toc

\write\index{The End}
\closeout\index
\end

