%
%  Automatic numberer: \EQ for regular equations, \EQQ for several
%    numbered equations in \eqalign sequence.
%  Format of the equation label is (c.e), right justified,
%    where 'c' is the chapter number \Chapno 
%    and 'e' the equation number \Eqno. You should set \Chapno at the
%    beginning of the file.
% 
\newcount\Eqno
\Eqno=0
\def \EQ   {\global\advance\Eqno by 1\eqno{(\number\Chapno .\number\Eqno)}}
\def \EQQ  {\global\advance\Eqno by 1 &{ (\number\Chapno.\number\Eqno)}}
%
%  Examples:
%
%  $$ x = 3 + i \EQ$$
%  $$ \eqalign {x & = 30 \EQQ \cr
%               y & = 50 \EQQ \cr} $$
%
%
%  Retrieval of an equation number: save it in a box.
%  After display mode, say "\key `number' `space'". Then to retrieve 
%    the words "Eq. c.e" do "\copy `number'" or "\box `number'" if you
%    only need to remember it once. The dummy `number' can be any number
%    from 0 to 150, it is not the same as \Eqno. YOU must remember how
%    you keyed a particular equation. The key remains the same, even if
%    you change the order of the equations.
%
\def \key #1 {\setbox#1=\hbox{Eq. \number\Chapno .\number\Eqno}}
%
%  Example: $$ x = y + z \EQ$$ \key71
%           \par As seen above in \copy71, this is a very blah, ...
%
%
%        FIGURES
%
\newcount\Figno
\newcount\FIGNO
\newcount\Figpgno
%
%  Make a numbered page that is blank except for "Figure c.f" at the bottom.
%
\def \figpage {\par \null \vfill \par \centerline {Figure \number \Chapno 
           \global \advance \Figpgno by1.\number\Figpgno}\eject}
%
%  Refer to a new figure in the text for the first time.
%
\def \Fig {\global \advance \Figno by1 Figure~\number
           \Chapno .\number\Figno}
%
%  The figure caption always follows \FIG.
%
\def \FIG {\par \noindent \global \advance \FIGNO by1 {\bf FIG. \number
              \Chapno .\number \FIGNO}: }
%
%  Refer to more than one figure in the text for the first time.
%  ... as seen in Figures 5.3-6 ...
%  (I am not sure this works.)
%
\def \Figs #1{{\advance\Figno by1 Figures \number\Chapno
         .\number\Figno}$-$ \global\advance\Figno by#1\number\Figno}
%
%       TABLES
%
\newcount\Tablno
\newcount\rno
%
%  Start each single table out with \Table.
%
\def \Table  {\global \advance \Tablno by1\par \noindent 
             {\bf Table \number\Chapno-\number\Tablno}: }
%
%       Tables a, b, c: There is a separate macro for the first one,
%       \Tablea. For all subsequent tables use \Tableb. It uses the 
%       same table number as the previous table. 
%
\def \Tablea {\global \advance \Tablno by1\par \noindent 
             {\bf Table \number\Chapno-\number\Tablno a}: }
\def \Tableb #1:{\par \noindent 
             {\bf Table \number\Chapno-\number\Tablno #1}: }
%
%  Refer to a table for the first time in the text. \TABLE
%  ... Table c--n ...
%
\def \TABLE {\global \advance \Tablno by1Table~\number \Chapno --\number
             \Tablno} 
%
%  Use \skiptable to skip over a sideways table, but keep numbering correct.
%  It also leaves a single blank, numbered page.
%
\def \skiptable {\global \advance \Tablno by1\null \eject}
%
%  Make two lines across, slightly separated. 
%
\def \linet {\smallskip \hrule \nobreak \smallskip \hrule \smallskip}
%
%     CHAPTERS
%
\newcount\Chapno
\Chapno=0
%
%  To start a new chapter: \Chapno should be set at zero for the first 
%    chapter, one for chapter 2, etc. because \Chap increments \Chapno.
%    It also initializes the figure, table, and reference counters.
%
\def \Chap #1{\global \Eqno=0\global \rno=0
   \global \Figno=0
   \global \FIGNO=0
   \global \Figpgno=0
   \global \Tablno=0
   \global \advance \Chapno by1\null \vskip 1in 
   \global \Tablno=0\global \Figno=0\global \rno=0
   \line {\bf CHAPTER \number \Chapno \hfil}
   \bigskip
   \line {\bf #1\hfil} \vskip2pc}
%
%        SECTIONS
%
%   Follow \sect with the section label and title. These macros are NOT
%     automatic numberers.
%
\def \sect #1{\vskip20pt \par\noindent{\bf #1}\vskip10pt\nobreak\par\nobreak}
\def \subsect #1{\vskip10pt \par\noindent{\bf #1}\vskip10pt\nobreak\par\nobreak}
%
%        REFERENCES
%
%   \genref
%   General references - for cases that don't fit into the special macros 
%     defined below, there is always this one.
%
%   Note the format of the argument list. This is very important. The argument
%     comes after a left parenthesis, and before a right parenthesis that is
%     immediately followed by a blank space. A right parenthesis followed by 
%     a carriage return will not do.
%
\def \genref (#1) {{\global\advance\rno by1{}$^{\number\rno}$
         \advance\rno by 150\global \setbox\number\rno =\vtop
         {\advance\rno by -150\item{\number\rno. }{\rm #1}.}}}
%
%  \ref
%  Regular references. (Multiple authors; one journal; volume; page; year) 
%
\def \ref (#1;#2;#3;#4;#5) {\genref ({{\rm #1}, {\sl #2}, {\bf #3}, 
{\rm #4 (#5)}}) }
%
%  book references - underlines the title
%  \refb (author; title; publisher; city(optionally, state); year; misc) 
%
%  The title is in math mode so one has to put the spaces between words 
%    in with "\ " or smaller ones with "\,"
\def \refb (#1;#2;#3;#4;#5;#6) {{\global\advance\rno by1{}$^{\number\rno}$
       \advance\rno by 150\global \setbox\number\rno =\vtop
       {\advance\rno by -150\item{\number\rno. }{\rm #1}, 
       $\underline{\rm #2}$, (#3, #4, #5) \rm #6.}}}
%
%  In a book references - underlined
%  This is for when the person quoted only wrote a part of a book.
%
\def \refi (#1;#2;#3;#4;#5;#6;#7;#8) {{\global\advance\rno by1{}$^{\number\rno}$
    \advance\rno by 150\global \setbox\number\rno =\vtop
    {\advance\rno by -150\item{\number\rno. }{\rm #1, in:}
    $\underline{\rm #2}$, Vol. #3, ed. #4 (#5, #6, #7), #8.}}}
%
% in a book references - italicized. It is easier to italicize than underline,
%   especially when the title is very long.
%
\def \refit(#1;#2;#3;#4;#5;#6;#7;#8){{\global\advance\rno by1{}$^{\number\rno}$
    \advance\rno by 150\global \setbox\number\rno =\vtop
    {\advance\rno by -150\item{\number\rno. }{\rm #1, in:}
    {\it #2}, Vol. #3, ed. #4 (#5, #6, #7), #8.}}}
%
%  comma references - When two papers are referenced at the same time, this
%    will put a comma before the second number in the superscript.
%
\def \refc (#1;#2;#3;#4;#5) {{\global\advance\rno by1$\! \!^{,\number\rno}$
   \advance\rno by 150\global \setbox\number\rno =\vtop
   {\advance\rno by -150\item{\number\rno. }{\rm #1}, {\sl 
   #2}, {\bf #3}, {\rm #4 (#5)}.}}}
%
%  Several references, a, b, c. Use with \genref.
%  Example (using _ to point out the required space bars): 
%       "\genref (\refabc (a)(author1;journal1;vol1;page1;year1)_;_ 
%            \refabc (b)(author2;journal2;vol2;page2;year2)_)_"
%
%  It is good to put the semicolon in between reference (a) and (b).
%  This can't be part of the macro because then the reference would 
%    end with a semicolon.
%
\def \refabc (#1)(#2;#3;#4;#5;#6) {{\rm #1) #2}, {\sl #3}, {\bf #4}, 
               {\rm #5 (#6)}}
%
% 2 part Multi-referencer
%
%  Refer to a group of papers in the text, with a hyphen in between, 
%    as in 18-22.  \multiref does not store the references at the end.
%    One needs to use \genrefnoi, in general, or \refbox, for simple
%    cases, for that.
%
\def\multiref #1{{\advance \rno by1{}$^{\number \rno 
                -{\advance \rno by#1\number\rno}}$}}
%
%  \refbox 
%  This will put a reference in the list at the end without having 
%    to refer to it in the text. This is useful if you have references in
%    tables.
%
\def \refbox (#1;#2;#3;#4;#5) {\genrefnoi ({{\rm #1}, {\sl #2}, {\bf #3}, 
     {\rm #4 (#5)}}) }
%
% \genrefnoi does not put a superscript in the text. This is useful if
%   you need references in the list, but you refer to them in some outside
%   part, such as a table.
%
\def\genrefnoi (#1) {{\global \advance \rno by 1 \advance \rno by 
               150\global \setbox \number \rno=\vtop {\advance 
               \rno by -150\item {\number \rno. }{\rm #1}.}}}
