\def\@parskip{0pt plus 1pt}
\parskip\@parskip
\def\@beginsmall{\ninepoint\def\@parskip{0pt plus 1pt}\parskip\@parskip
      \ignorespaces}

\@definecounter{interlude}
\def\@co@interlude{\ifnum \@c@interlude >0 \@arabic{\@c@interlude}\else P\fi}
\def\@ca@interlude{{\@c@interlude}}
\def\@cr@interlude#1{\ifnum #1>0\relax\@arabic{#1}\else P\fi}

\def\interludesw{T} %Begins with an interlude.

\def\minvskip#1{\ifdim #1>\the\lastskip\vskip\minusthe\lastskip\vskip #1\fi}

\def\exercises{\par\vspace{25pt}\noindent {\bf Exercises}\par\nopagebreak
\vspace{15pt}}

\def\@beginboxed#1{\[\setbox0=\vbox\lb\hsize #1 \noindent }
\def\@endboxed{\rb \boxit{\box0}\]}


\def\@beginexercise{\par\minvskip{1.5ex}\noindent 
\if\interludesw F\@refstepcounter{exercise}{\bf Exercise \@co@exercise:}\else
\@refstepcounter{iexercise}{\bf Exercise \@co@iexercise:}\fi}

\def\@endexercise{\par\vskip 1.5ex}

\@definecounter{exercise}
\@addtoreset{exercise}{chapter}
\def\@co@exercise{\@co@chapter.\@arabic{\@c@exercise}}
\def\@ca@exercise{{\@c@chapter}{\@c@exercise}}
\def\@cr@exercise#1#2{\@cr@chapter{#1}.\@arabic{#2}}

\@definecounter{iexercise}
\@addtoreset{iexercise}{interlude}
\def\@co@iexercise{\@co@interlude.\@arabic{\@c@iexercise}}
\def\@ca@iexercise{{\@c@interlude}{\@c@iexercise}}
\def\@cr@iexercise#1#2{\@cr@interlude{#1}.\@arabic{#2}}


\def\@beginsolution{\par \minvskip{1.5ex}\noindent\ninepoint
   {\bf Solution to Exercise 
     \if\interludesw F\@co@exercise\else\@co@iexercise\fi:}}
\def\@endsolution{\par\vskip 1.5ex}

\def\@beginquote{\@beginlist{}{\rightmargin{\@d@leftmargin}\topsep
  {1.2ex}}\ninepoint
\abovedisplayskip 2pt plus 1pt minus 1pt%
\belowdisplayskip 2pt plus 1pt minus 1pt%
\abovedisplayshortskip 0pt plus 1pt%
\belowdisplayshortskip 2pt plus 1pt minus 1pt%
\item}
\def\@endquote{\@endlist\vspace{1.2ex}}

\def\qindent{\hspacer{.6em}}
\def\pindent{\hspacer{1em}}

\def\@beginprogram#1{\if\interludesw F\@begininsert{program}{Program}{#1}{lop}%
\else\@begininsert{iprogram}{Program}{#1}{lop}\fi}

\let\@endprogram=\@endfigure


\@definecounter{program}
\@addtoreset{program}{chapter}
\def\@co@program{\@co@chapter.\@arabic{\@c@program}}
\def\@ca@program{{\@c@chapter}{\@c@program}}
\def\@cr@program#1#2{\@cr@chapter{#1}.\@arabic{#2}}

\@definecounter{iprogram}
\@addtoreset{iprogram}{interlude}
\def\@co@iprogram{\@co@interlude.\@arabic{\@c@iprogram}}
\def\@ca@iprogram{{\@c@interlude}{\@c@iprogram}}
\def\@cr@iprogram#1#2{\@cr@interlude{#1}.\@arabic{#2}}


\def\@t@lop{F} % don'T produce .LOP file if no \listofprograms

% The \chapter macro must write a \def\interludesw{F} and the \interlude macro 
% must write \def\interludesw{T} on the .lop file.
% They should also write \def\skipsw{T} on the .lop file.

\def\@tr@lop#1#2#3#4{\if\skipsw T% skip 10 pt between programs
     \vskip 10pt\fi\def%                     % for different chapters
\skipsw{F}\hbox to \columnwidth
      {\hbox to 2.3em{\if\interludesw T\@cr@iprogram{#1}{#2}\else
        \@cr@program{#1}{#2}\fi.\hss}#3\@lead\hbox 
      to 1.5em{\hfil #4}}}

\def\listofprograms{\begin{center}
{\tit PROGRAMS}
\end{center}\par\vskip 10pt\def\@x@chap{-1}\begingroup
\@input{\jobname.lop}\endgroup\par
\if\@tfilesw T\gdef\@t@lop{T}\newwrite\@tf@lop\openout\@tf@lop=\jobname.lop\fi}

\def\chapter#1{\clearpage                     % clear end of chapter
    \@refstepcounter{chapter}                 % step counter
     \warning{\@chapapp\space\@c@chapter.}    % type message
    \if \@t@lop T\write\@tf@lop{\string\def\string\interludesw{F}
    \string\def\string\skipsw{T}}\fi     % write appropriate nonsense on .lop
    \def\interludesw{F}                       % Not an interlude.
     \thispagestyle{newchapter}               % special page style
     \@chapmark{#1}
     \vspacer{50pt}                           % blank space at top of page
     \vbox                                    % chapter heading 
       {\noindent \Tit \@chapapp{} \@co@chapter.}
     \vspace{20pt}
     \vbox {\Tit \noindent #1}
     \@addtableentry{toc}{\string             % add table of contents line
         \@chappage\@ca@chapter{#1}}
     \parskip40pt                             % space in front of first par.
     \def\@nobreak{T}
     \everypar{\parskip\@parskip\@everypar    % first par will restore \parskip
         \def\@nobreak{F}\everypar{\@everypar}}}

\def\interludesection#1{
     \par                                     % end previous paragraph     
     \vspace{25pt}                            % extra vertical space
     \if\@nobreak F\goodpagebreak\fi          % good place for page break if
     \@secmark{#1}                            %    not following \chapter
     \vbox{\noindent{\@mainsize\bf #1}}       % section heading 
     \tableentry{toc}{\hbox{\hskip .25in}#1}  % add table of contents line
     \nobreak                                 % very bad place for page break
     \def\@nobreak{T}
     \parskip15pt                             % space in front of first par.
     \everypar{\parskip\@parskip              % first par will restore \parskip
         \def\@nobreak{F}\everypar{\@everypar}}}

