%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%  CS10 1987 2nd term                                                         %
%  David Gillespie                                                            %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%  CS10 format macros for TeX                                                 %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%  CAVEAT --                                                                  %
%     This library is not designed to be excerpted or modified by anyone      %
%     not <very> familiar with how it works.  Please do not change it         %
%     without <reading> it first!  Thanks, Dave.                              %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%%%%%%%%%%%%%%%%%%%%%%%%%%  Other macro libraries  %%%%%%%%%%%%%%%%%%%%%%%%%%%%

%\input /sashimi/users/lazzaro/etc/tex/inputs/psmac.tex



%%%%%%%%%%%%%%%%%%%%%%%%%%%  Miscellaneous stuff  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Things to make macro definitions easier
%
% NOTE:  Most of the definitions in this file work only in \internaldefs
%        mode.  If you must take part of the file, be sure to put
%        \internaldefs at the beginning, and \normaldefs at the end,
%        of the excerpt.
%
\def\internaldefs{%
\endlinechar=-1%  prevent spurious spaces and \par's
\catcode`\ =9%    ignore spaces
\catcode`\!=10%   substitute space
\catcode`\@=11%   allow @ signs in identifiers
}
\def\normaldefs{%
\endlinechar=13%
\catcode`\ =10%
\catcode`\!=12%
\catcode`\@=12%
}

\internaldefs     % this holds true for most of this file


% Access to special characters
\chardef\other=12
\catcode`\/=0
\catcode`\\=\other
   /def/bsl@sh{\}
   /def/vertb@r{|}
   /def/lth@n{<}
   /def/gth@n{>}
/catcode`/\=0
/catcode`//=\other
\catcode`\ =\other\def\othersp@ce{ }\catcode`\ =9%

\catcode`\<=1
\catcode`\>=2
\catcode`\{=\active \catcode`\}=\active
\def\letbr@ces#1#2<
   \catcode`\{=\active \catcode`\}=\active
   \let{=#1
   \let}=#2
>
\catcode`\{=\other \catcode`\}=\other
\let\lbrpr@nt={ \let\rbrpr@nt=}
\catcode`\{=1 \catcode`\}=2

\catcode`\%=\active
\def\letperc@nt#1{
   \let%=#1
}
\catcode`\%=\other
\let\percpr@nt=%
\catcode`\%=14 \relax

\catcode`\;=\active \def\lets@mi#1{\let;=#1} \catcode`\;=\other
\catcode`\*=\active \def\letst@r#1{\let*=#1} \catcode`\*=\other


% Define active control characters
\catcode`\^^A=0  % alternate escape character
\catcode`\^^X=\active \catcode`\^^F=\active
\catcode`\^^I=\active
\catcode`\|=\active \catcode`\<=\active \catcode`\>=\active


% Declarations
\newcount\obeylinespenalty
\newdimen\normalhsize
\newdimen\exampleindent
\newdimen\exampleskip
\newdimen\examplefudge
\newdimen\olpackedskip
\newdimen\listskip
\newdimen\itemskip
\newdimen\importindent 
\newdimen\importskip
\newdimen\exerciseindent 
\newdimen\exerciseskip
\newdimen\exerciseparskip
\newdimen\titleskip
\newdimen\sectionskip 
\newdimen\aftersectionskip
\newif\ifapple \applefalse



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Handy macros  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Dealing with newlines
\def\activeM{
   \catcode`\^^M=\active
} 
\def\normalM{
   \catcode`\^^M=5
}
\def\Mdef{      % in the body of the \def, ^^M is active
   \activeM
   \afterassignment\normalM
   \def
}


% List munching
\long\def\car#1#2\endlist{#1}
\long\def\cdr#1#2\endlist{#2}


% Debugging output
\long\def\debugout{
   \immediate\write16
}


% Print something in math mode
\def\checkmath#1{
   \relax
   \ifmmode
      {#1}
   \else
      $#1$
   \fi
}

% Print a fraction
\def\frac#1#2{
   \checkmath{\scriptstyle{#1\over#2}}
}


% Usage: \tweak\register by num/den
\def\tweak#1#2/{
   \multiply#1#2
   \toks0={#1}
   \afterassignment\twe@k \count255=
}
\def\twe@k{
   \expandafter\divide\the\toks0\count255
}


% Continue a paragraph in progress
\def\tempendgraf{
   \ifvmode
      \vskip\parskip
   \else
      \par
   \fi
}
\def\continuegraf{
   \begingroup
      \parskip=0pt
      \noindent
   \endgroup
   \ignorespaces
}


% Centered text (can include verbatim and multiple lines)
\def\beginc@nterline{
   \parskip=0pt
   \parindent=0pt
   \leftskip=0pt plus .5\hsize
   \rightskip=\leftskip
   \parfillskip=0pt
   \pretolerance=9999 \tolerance=9999
   \hyphenpenalty=9999 \exhyphenpenalty=9999\relax
}
\def\centerline#{
   \par
   \begingroup
   \beginc@nterline
   \bgroup
      \aftergroup\endc@nterline
      \g@bble  % absorb following {
}
\def\endc@nterline{
   \par
   \endgroup
   \continuegraf
}


% Gobble the following token
\def\g@bble{\let\g@bbled=!}


% Not as strong as \nobreak
\def\badbreak{\penalty500\relax}


% Vertical dots
\def\missinglines{\strut $\vdots$}


% Today's date
\def\monthname#1{
   \ifcase#1
      Zero
      \or January\or February\or March\or April
      \or May\or June\or July\or August
      \or September\or October\or November\or December
   \fi
}
\def\today{\monthname\month\ \number\day,!\number\year}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Fonts  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\def\defptsize#1=#2pt#3pt#4pt#5#6#7#8{
   \def#5{
      #6
      \let\smallsize=#7
      \let\largesize=#8
      \everymath={\myeverym@th}
      {\csname#1it\endcsname   % Force the font to be loaded
       \csname#1bf\endcsname}  %  (at first, these are defined as macros)
      \textfont\itfam=\csname#1it\endcsname
      \textfont\bffam=\csname#1bf\endcsname
   }
   \ifapple
      \expandafter\font\csname#1rm\endcsname=TimesRoman!at#2pt
      \expandafter\font\csname#1it\endcsname=TimesItalic!at#3pt
      \expandafter\font\csname#1bf\endcsname=TimesBold!at#4pt
   \fi
}
\def\myeverym@th{}   % temporary

% Need to preserve fonts, because stupid plaintex preloads so many that
% TeX's memory almost fills up
\defptsize eight    =  8pt  8pt  9pt \eightpt    \eightpoint    \sixpoint   \tenpt
\defptsize nine     =  9pt  9pt  9pt \ninept     \ninepoint     \sevenpoint \twelvept
\defptsize ten      = 10pt 10pt 10pt \tenpt      \tenpoint      \eightpt    \twelvept
\defptsize eleven   = 11pt 11pt 12pt \elevenpt   \elevenpoint   \eightpt    \fourteenpt
\defptsize twelve   = 12pt 12pt 12pt \twelvept   \twelvepoint   \ninept     \fourteenpt
\defptsize fourteen = 14pt 14pt 14pt \fourteenpt \fourteenpoint \tenpt      \eighteenpt
\defptsize eighteen = 18pt 18pt 14pt \eighteenpt \eighteenpoint \twelvept   \eighteenpt


\def\elevenpoint{\def\fsize{eleven}\setfont\let\sfont=\eightpoint%
                  \baselineskip13pt%
                  \setbox\strutbox=\hbox{\vrule height10pt depth4pt width0pt}%
                  \textfont0=\elevenrm \scriptfont0=\ninerm%
                             \scriptscriptfont0=\sevenrm%
                  \scriptscriptfont1=\seveni%
                  \scriptscriptfont2=\sevensy%
                  \def\changes{{\eleveni\ninei\elevensy\ninesy}%
                           \textfont1=\eleveni \scriptfont1=\ninei%
                           \textfont2=\elevensy \scriptfont2=\ninesy}%
               \ifmmode\changes\else\everymath{\changes}%
%                                     \everydisplay{\changes}%
                                     \fi}



\font\elevenrm=cmr10!at!11pt
\font\elevenit=cmti10!at!11pt
\font\elevenbf=cmbx10!at!11pt
\font\eleveni=cmmi10!at!11pt
\font\elevensy=cmsy10!at!11pt
\font\eleventt=cmtt10!at!11pt

\font\twelverm=cmr12
\font\twelveit=cmti12
\font\twelvebf=cmbx12

\font\fourteenit=cmr10!at!14pt    % fake it for now!

\font\eighteenrm=cmr17



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Page Layout  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Tweakable parameters:
\hoffset=.1in           % Horizontal position on the page
\hsize=6.3in            % Width of printed area of the page
\vsize=8.5in            % Height of printed area of the page
\parindent=0pt          % Paragraph indentation
\parskip=4pt            % Space skipped between paragraphs
\exampleindent=20pt     % Indentation distance for examples
\exampleskip=5pt        % Space before and after examples
\examplefudge=.25in     % Distance lines may go past normal right margin
\olpackedskip=8pt       % Size of blank lines in \obeylines\packed mode
\importindent=15pt      % Indentation for procedure descriptions
\importskip=6pt         % Space around imported procedure descriptions
\listskip=5pt           % Space before and after lists
\itemskip=5pt           % Space between items in lists
\exerciseindent=20pt    % Indentation for exercises
\exerciseskip=8pt       % Space before and after exercises
\exerciseparskip=4pt    % Parskip for exercises
\titleskip=.35in        % Space skipped at top of page 1
\sectionskip=.35in      % Space skipped before section header
\aftersectionskip=1pt   % Space skipped after section header

\obeylinespenalty=100   % Penalty between lines in obeylines mode

\def\titlefont{\eighteenpt\rm}         % Main title on page 1
\def\subtitlefont{\fourteenpt\rm}      % Secondary title on page 1
\def\footfont{\eightpt\rm}             % Font used in footline
\def\pagefont{\tenpt\rm}               % Font used in page numbers
\def\captionfont{\tenpt\it}            % Figure captions

%\def\mainfont{\twelvept\rm}            % Font used for general text
\def\mainfont{\elevenpt\rm}            % Font used for general text

\def\examplefont{\tt}                  % Verbatim text
\def\sectionfont{\it}                  % Section headers
\def\commentfont{\it}                  % Pascal comments
\def\exercisefont{\bf}                 % Exercise headers
\def\displayfont{\rm}                  % Non-verbatim displays
\def\lnumfont{\smallsize\rm}           % Line numbers in displays

\def\smallprint{
   \def\mainfont{\tenpt\rm}            % Font used for general text
   \tweak\parskip by10/12
   \tweak\exampleskip by10/12
   \tweak\examplefudge by10/12
   \tweak\listskip by10/12
   \tweak\itemskip by10/12
   \tweak\exerciseskip by10/12
   \tweak\exerciseparskip by10/12
   \tweak\titleskip by10/12
   \tweak\sectionskip by10/12
   \tweak\aftersectionskip by10/12
   \mainfont
}

\raggedbottom
\mainfont
\normalhsize=\hsize

% This defines the header and footer on every page
\headline={\hss}
\footline={
   \baselineskip=10pt
   \hbox to 0pt{
      \hbox to \normalhsize{\pagefont \hfil --\ \folio\ -- \hfil}
      \hss
   }
   \hbox to 0pt{
      \vtop{
         \footfont
         \ifodd\pageno
            \hbox to \normalhsize{\hfil \title}
            \hbox to \normalhsize{\hfil \today}
         \else
            \hbox to \normalhsize{\title \hfil}
            \hbox to \normalhsize{\today \hfil}
         \fi
      }
      \hss
   }
   \footextra
   \hss
}
\let\footextra=\relax

% This should be changed to the actual contents of the desired footer
\def\title{\classn@me}

\def\topofpage{}

\def\firstpage{
   \topofpage
   \vskip\titleskip
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%  Convenient notation  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\myeverym@th{
   \changes    % from HP TeX
   \disobeyspaces
}
\def\disobeyspaces{\catcode`\ =10\relax}

\def\small#{
   \bgroup
   \smallsize
   \g@bble
}

\def\smcaps#1{
   \begingroup
      \smc@ps#1\relax
   \endgroup
}
\def\smc@ps{
   \futurelet\n@xt\smc@psnext
}
\def\next#1{\let\smc@psspace=!#1} \next{!}
\def\smc@psnext{
   \ifx\n@xt\relax
      \let\next=\relax
   \else
      \ifx\n@xt\bgroup
         \let\next=\smc@psgob
      \else
         \ifx\n@xt\egroup
            \let\next=\smc@psgob
         \else
            \ifx\n@xt\smc@psspace
               \let\next=\smc@psgob
            \else
               \let\next=\smc@psdo
            \fi
         \fi
      \fi
   \fi
   \next
}
\def\smc@psgob{
   \n@xt
   \afterassignment\smc@ps
   \g@bble
}
\def\smc@psdo#1{
   \ifcat\noexpand#1\relax          % or try \edef
      #1
   \else
      \ifnum\lccode`#1=`#1\relax
         {\smallsize \uppercase{#1}}
      \else
         #1
      \fi
   \fi
   \smc@ps
}

\def\CAGED{\smcaps{Caged}}
\def\labmac{\smcaps{Labmac}}

\def\arrow{\checkmath{\rightarrow}}
\def\Arrow{\checkmath{\Rightarrow}}
\let\bull@t=\bullet
\def\bullet{\checkmath{\bull@t}}
\def\bull{\vrule height .9ex width .8ex depth -.1ex\relax}

\def\]{{\tt\char`\ }}

\def\neq{\not\mskip1.5mu=}
\let\ne=\neq


% Easy-to-use alternate text modes:
%     <italic-text>
%     <:bold-text>
%     <.smcaps-text.>
%     <+angled-text+>
%     <_angled-text_>
%     <?text?>          calls user's \angleqmark{text}
%     <!text!>          calls user's \anglebang{text}
\def\<{
   \relax
   \ifmmode
      \let\next=\lth@n
   \else
      \let\next=\labr@cket
   \fi
   \next
}
\let<=\<
\def\r@br{
   \relax
   \ifmmode
      \let\next=\gth@n
   \else
      \let\next=\rabr@cket
   \fi
   \next
}
\let>=\r@br

\catcode`\_=\active
\catcode`\!=\other
\def\labr@cket{
   \begingroup
   \catcode`\>=\active \catcode`\.=\other \catcode`\:=\other \catcode43=\other   % 43 = `+'
   \catcode`\_=\active \catcode`\!=\other \catcode`\?=\other
   \futurelet\next\labr@ck@t
}
\def\labr@ck@t{
   \ifx\next.
      \let\n@xt=\lasmc@ps
   \else\ifx\next:
      \let\n@xt=\lab@ld
   \else\ifx\next+
      \let\n@xt=\la@ngle
   \else\ifx\next_
      \let\n@xt=\laul@ne
   \else\ifx\next?
      \let\n@xt=\laqm@rk
   \else\ifx\next!
      \let\n@xt=\lab@ng
   \else
      \let\n@xt=\it
      \let\rabr@cket=\rait@lic
      \catcode`\_=\active
   \fi\fi\fi\fi\fi\fi
   \n@xt
}
\def\rabr@cket{
   \errmessage{Mismatched!angle!brackets.}
}
\def\rait@lic{
   \endgroup
}
\def\lab@ld:#1:>{
   \bf#1
   \endgroup
}
\def\lasmc@ps.#1.>{
   \smcaps{#1}
   \endgroup
}
\def\la@ngle+#1+>{
   $\langle$ #1 $\rangle$
   \endgroup
}
\def\angleqmark#1{
   #1
}
\def\laqm@rk?#1?>{
   \angleqmark{#1}
   \endgroup
}
\def\anglebang#1{
   #1
}
\def\lab@ng!#1!>{
   \anglebang{#1}
   \endgroup
}
\catcode`\!=10\relax

% Underlining
\catcode`\ =\active%
\Mdef\laul@ne{%
\catcode`\ =\active\let =\laul@nespace%
\activeM\let^^M=\laul@nespace%
\la@l@ne%
}%
\catcode`\ =9\relax%
\def\la@l@ne_#1_>{
   \setbox0=\hbox{
      #1
   }
   \dp0=0pt
   $\m@th\underline{\box0}$
   \endgroup
}
\def\laul@nespace{
   \egroup
   \ifdim\wd0=0pt
   \else
      \dp0=0pt
      $\m@th\underline{\box0}$
      \laulinespace
   \fi
   \setbox0=\hbox\bgroup
}
\def\underlinewords{
   \let\laulinespace=\laul@newords
}
\def\underlinefull{
   \let\laulinespace=\laul@nefull
}
\def\laul@newords{
   \space
}
\def\laul@nefull{
   \setbox0=\hbox{
      \underbar{\space}
   }
   \discretionary{}{}{\copy0\rlap{\copy0}}
   \nobreak
   \hskip 0pt plus 1pt
}
\underlinewords     % the default
\catcode`\_=8

% Access to interesting fonts
\newcount\dingbatsize \dingbatsize=18\relax
\def\dingbatfont{ZapfDingbats}
\def\dingbat{
   \afterassignment\dingb@t
   \count255=
}
\def\dingb@t{
   \dimen0=0.8pt\relax
   \multiply\dimen0 by \dingbatsize\relax
   \hbox to \dimen0{
      \special{ps::!save!/\dingbatfont\space findfont!
                    \number\dingbatsize\space scalefont!setfont!
                    1!string!dup!0!\number\count255\space\space put!show!
                    restore}
      \hss
   }
}



%%%%%%%%%%%%%%%%%%%%%%%%%  Plain TeX/HP TeX fixes  %%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Allow _ in normal text
\let\s@bscr=_
\catcode`\_=\active
\def\undersc@re{
   \relax
   \ifmmode
      \s@bscr
   \else
      \leavevmode
      \hbox{\vrule width.3em height0pt depth.1ex}
      \kern.05em\relax
   \fi
}
\let_=\undersc@re


% Fix \obeylines to work correctly
\Mdef\obeylines{
   \activeM
   \let^^M=\olM
   \let\linenumbers=\linen@mbers
   \let\nolinenumber=\nolinen@mber
   \let\packed=\olp@cked
   \let\nodisplay=\nodispl@y
}
\def\olM{
   \null
   \par
   \penalty\obeylinespenalty
}
\newcount\lnumc@unt
\def\linen@mbers{
   \everypar={\linen@mb@rs}
   \lnumc@unt=0\relax
}
\def\nolinen@mber{
   \everypar={\everypar={\linen@mb@rs}}
}
\def\linen@mb@rs{
   \advance\lnumc@unt by 1\relax
   \llap{\lnumfont\number\lnumc@unt.\enskip}
}
\Mdef\eatM^^M{}
\newcount\savespacecode
\def\nodispl@y{
   \savespacecode=\catcode`\ %
   \disobeylines
   \nod@spl@y
}
\def\nod@spl@y#1{
   #1
   \obeylines
   \catcode`\ =\savespacecode
   \eatM
}
\Mdef\olp@cked{
   \let^^M=\olpM
}
\def\olpM{
   \relax
   \ifvmode
      \vskip\olpackedskip
   \else
      \olM
   \fi
}
\let\disobeylines=\normalM


% Fix \obeyspaces to work correctly
\newdimen\sp@ceskip \sp@ceskip=.5em  % default value = 1 enskip
\def\mysp@ce{\hskip\sp@ceskip\relax} 
{\obeyspaces\global\let =\mysp@ce}


% Easier access to multicolumn printing
\def\twocolumns{\c@lumns{two}}
\def\threecolumns{\c@lumns{three}}

\def\c@lumns#1{
   \columnspace=.5in
   \start{#1columns}
   \begingroup
   \def\c@lnum{#1}
   \let\done=\endc@lumns
}
\def\endc@lumns{
   \expandafter\endc@l@mns\c@lnum\relax
}
\def\endc@l@mns#1\relax{
   \endgroup
   \finish{#1columns}
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Index  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newwrite\idxout
\def\idxf@le{index.tex}
\def\idxf@@le{index2.tex}
\def\op@nind@x{
   \immediate\openout\idxout=\idxf@le\relax
   \global\let\op@nindex=\relax
}
\let\op@nindex=\op@nind@x

\def\idxverbatim{
   \catcode`\\=\other \catcode`\_=\other 
   \catcode`\|=\other
   \catcode`\<=\other \catcode`\>=\other
   \catcode`\ =10 \catcode`\"=\other
}
\def\idxunverbatim{
   \catcode`\\=0 \catcode`\_=\active 
   \catcode`\|=\active
   \catcode`\<=\active \catcode`\>=\active
}

\catcode`\~=\other

% Usage:  \indexas{word}{as}   alphabetize according to 'as', but print 'word'
\def\indexas{
   \op@nindex
   \begingroup
   \idxverbatim
   \ind@xas
}
\def\ind@xas#1{
   \def\ind@x@a{#1}
   \ind@xnext
}
\def\ind@xnext{
   \catcode`\ =\other
   \ind@xn@xt
}
\def\ind@xn@xt#1{
   \catcode`\ =10
   \ifx\ind@x@a\index
      \def\ind@x@a{#1}
   \fi
   \let\ind@x@b=\empty
   \ifx\ind@x@a\vindex
      \def\ind@x@a{\vertb@r\vertb@r#1\vertb@r\vertb@r}
      \def\ind@x@c{v}
   \else
      \let\ind@x@c=\empty
   \fi
   \lowercase{\cle@nup#1\relax}
   \count0=\pageno
   \advance\count0 by 1000
   \immediate\write\idxout
      {~idxentry!
       \ifx\ind@x@b\empty
          \edef\ind@x@c{\ind@x@c e}
       \else
          \ind@x@b
       \fi
       \ifx\ind@x@c\empty
       \else
          "\ind@x@c
       \fi
       ""\number\count0
       """\ind@x@a~done}
   \endgroup
   \ignorespaces
}

\def\cle@nup#1#2\relax{
   \ifx#1\relax
      \let\next=\relax
   \else
      \let\next=\cle@nup
      \expandafter\ifx\vertb@r#1
         \edef\ind@x@c{\ind@x@c b}
      \else
         \expandafter\ifx\lth@n#1
            \edef\ind@x@c{\ind@x@c l}
         \else
            \expandafter\ifx\gth@n#1
               \edef\ind@x@c{\ind@x@c g}
            \else
               \expandafter\ifx\bsl@sh#1
                  \edef\ind@x@c{\ind@x@c c}
               \else
                  \ifx#1~
                     \edef\ind@x@c{\ind@x@c t}
                  \else
                     \ifx#1$
                        \edef\ind@x@c{\ind@x@c m}
                     \else
                        \expandafter\ifx\othersp@ce#1
                           \edef\ind@x@c{\ind@x@c s}
                        \else
                           \ifx#1"
                              \edef\ind@x@c{\ind@x@c q}
                           \else
                              \ifx#1.
                                 \edef\ind@x@c{\ind@x@c p}
                              \else
                                 \edef\ind@x@b{\ind@x@b#1}
                              \fi
                           \fi
                        \fi
                     \fi
                  \fi
               \fi
            \fi      % yow
         \fi
      \fi
   \fi
   \next#2\relax\relax
}

% Usage:  \index{word}     add a reference to this word to the index
\def\index{       % {word} must not be {}
   \op@nindex
   \begingroup
   \idxverbatim
   \let\ind@x@a=\index
   \ind@xnext
}

% Usage:  \vindex{word}       index a verbatim word
\def\vindex{
   \op@nindex
   \begingroup
   \idxverbatim
   \let\ind@x@a=\vindex
   \ind@xnext
}


% Close index at the end.  
%   If followed by 2, actually prints the index.
%   If followed by 1, prints but does not sort the index.
%   If followed by 0, does not print index.
\def\doindex#1{
   \immediate\closeout\idxout
   \ifnum#1\gth@n0
      \ifx\op@nindex\relax
         \begingroup
            \catcode`\~=0
            \ifnum#1\gth@n1
               \debugout{Sort-index:}
               \let\oldidx=\idxf@le
               \let\newidx=\idxf@@le
               \idxverbatim
               \s@rtindex
            \else
               \let\newidx=\idxf@le    % too slow to sort all the time
            \fi
            \debugout{Print-index:}
            \pr@ntindex
         \endgroup
      \else
         (Index\ is\ empty.)
      \fi
   \else
      (Insert\ index\ here.)
   \fi
}

% Bubble-sort the index (that's right, it's written in TeX!)
\newif\ifnots@rted
\def\s@rtindex{
   \s@rtind@x
   \ifnots@rted   % then continue the loop
      \let\next=\oldidx
      \let\oldidx=\newidx  % exchange infile with outfile
      \let\newidx=\next
      \let\next=\s@rtindex
   \else
      \let\next=\relax     % file \newidx now contains a sorted index
   \fi
   \next
}

\newif\iflessth@n
\def\s@rtind@x{
   \immediate\openout\idxout=\newidx
   \nots@rtedfalse
   \let\idxprev=\relax
   \let\idxprevhead=\relax
   \let\idxprevword=\relax
   \let\idxentry=\s@rtidxentry
   \input\oldidx
   \immediate\write\idxout{\idxprevhead\idxprev"""\idxprevword~done}
   \immediate\closeout\idxout
}
\def\idxentryhe@d{~idxentry!}
\def\s@rtidxentry#1"""#2\done{
   \def\idxnext{#1}
   \let\idxnexthead=\idxentryhe@d
   \def\idxnextword{#2}
   \ifx\idxprev\relax
      \let\idxprev=\idxnext
      \let\idxprevhead=\idxnexthead
      \let\idxprevword=\idxnextword
   \else
      \expandafter\comp@relines\idxprev\relax#1\relax
   \fi
}

\def\comp@relt#1\relax#2\relax{
   \immediate\write\idxout{\idxprevhead\idxprev"""\idxprevword~done}
   \let\idxprev=\idxnext
   \let\idxprevhead=\idxnexthead
   \let\idxprevword=\idxnextword
}
\def\comp@regt#1\relax#2\relax{
   \immediate\write\idxout{\idxnexthead\idxnext"""\idxnextword~done}
   \nots@rtedtrue
}
\def\comp@reeq#1\relax#2\relax{
   \nots@rtedtrue
}
\def\comp@relines#1#2\relax#3#4\relax{
   \ifnum`#1\lth@n`#3
      \let\next=\comp@relt
   \else
      \ifnum`#1\gth@n`#3
         \let\next=\comp@regt
      \else
         \def\compleft{#2}
         \def\compright{#4}
         \ifx\compright\empty
            \ifx\compleft\empty
               \let\next=\comp@reeq
            \else
               \let\next=\comp@regt
            \fi
         \else
            \ifx\compleft\empty
               \let\next=\comp@relt
            \else
               \let\next=\comp@relines
            \fi
         \fi
      \fi
   \fi
   \next#2\relax#4\relax
}


% Read and print the sorted index
\newcount\idxpageno
\def\pr@ntindex{
   \vfill \supereject
   \centerline{\subtitlefont Index}
   \vskip\titleskip
   \twocolumns
      \let\idxprev=\relax
      \let\idxentry=\pr@ntidxentry
      \parskip=0in
      \parindent=0in
      \input\newidx
      \balance  % from HPTeX
      \vfill \eject
   \done
}
\def\pr@ntidxentry{
   \idxverbatim
   \pr@ntidx@ntry
}
\def\pr@ntidx@ntry#1""#2"""{
   \idxunverbatim
   \def\idxnext{#1}
   \idxpageno=#2\relax
   \advance\idxpageno by -1000\relax
   \ifx\idxprev\idxnext
      \let\next=\pr@ntidxmore
   \else
      \let\idxprev=\idxnext
      \let\next=\pr@ntidxnew
   \fi
   \next
}
\def\pr@ntidxmore#1\done{
   ,\ \number\idxpageno
   \ignorespaces
}
\def\pr@ntidxnew{
   \par
   \hangindent=.4in
   \hangafter=1\relax
   \leavevmode
   \dimen0=\hsize
   \advance\dimen0 by -.6in
   \hbox to \dimen0\bgroup
      \hskip.25in
      \begingroup
         \let\done=\pr@ntidxn@w
}
\def\pr@ntidxn@w{
      \endgroup
      \enskip \dotfill \enskip
   \egroup
   \number\idxpageno
   \ignorespaces
}

\catcode`\~=\active



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Verbatim text  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Enter verbatim mode
\def\verbatim{
   \parindent=0pt
   \parskip=0pt
   \edef\unverb@timfont{\the\font}
   \catcode`\$=\other
   \catcode`\&=\other \catcode`\#=\other \catcode`\~=\other
   \catcode`\^=\other \catcode`\_=\other \catcode`\%=\other
   \catcode`\<=\other \catcode`\>=\other
   \let\|=\vertb@r
   \let\\=\bsl@sh
   \let^^I=\v@rbtab
   \hyphenpenalty=9999
   \exhyphenpenalty=9999
   \examplefont
   \setbox0=\hbox{M} \sp@ceskip=\wd0
   \obeylines 
   \obeyspaces
   \let\pascal=\pascalv@rb
   \let\C=\Cv@rb
   \let\ps=\psv@rb
   \let\asm=\asmv@rb
   \let\olap=\olapv@rb
}
\def\verbbr@ces{
   \catcode`\{=\other 
   \catcode`\}=\other
}
\def\verbvbar{
   \let\|=\ex@mplebar
   \catcode`\|=\other
}
\def\verbbslash{
   \catcode`\\=\other
}
\def\fullverbatim{
   \verbbr@ces
   \verbbslash
}
\def\endverb@tim{
   \endgroup
   \ifvmode
      \continuegraf
   \fi
}
\def\unverb@tim{
   \begingroup
   \unverb@timfont
   \catcode`\$=3
   \catcode`\&=4 \catcode`\#=6 \catcode`\~=\active
   \catcode`\^=7 \catcode`\_=\active \catcode`\%=14
   \catcode`\<=\active \catcode`\>=\active
   \catcode`\\=0 \catcode`\{=1 \catcode`\}=2
   \catcode`\|=\active
   \let|=\verbb@r \let_=\undersc@re \let<=\< \let>=\r@br
   \disobeyspaces
   \disobeylines
}

% Special verbatim mode for Pascal
\def\pascalv@rb{
   \letbr@ces\pascallbr@ce\pascalbrerr@r
}
\def\pascallbr@ce{
   \lbrpr@nt
   \unverb@tim
   \commentfont
   \letbr@ces\pascalbrerr@r\pascalrbr@ce
}
\def\pascalrbr@ce{
   \endgroup
   \rbrpr@nt
}
\def\pascalbrerr@r{
   \errmessage{Bad!nesting!of!braces!in!a!Pascal!example.}
}

% Special verbatim mode for C
\def\Cv@rb{
   \relax
}

% Special verbatim mode for PostScript
\def\psv@rb{
   \catcode`\%=\active
   \letperc@nt\psperc@nt
}
\Mdef\psperc@nt{
   \percpr@nt
   \unverb@tim
   \commentfont
   \activeM
   \let^^M=\pse@l
}
\Mdef\pse@l{
   \endgroup
   ^^M
}

% Special verbatim mode for Assembly Language
\Mdef\asmv@rb{
   \catcode`\;=\active \catcode`\*=\active
   \lets@mi\asms@mi
   \letst@r\asmst@r
}
\Mdef\asms@mi{
   ;
   \unverb@tim
   \commentfont
   \activeM
   \let^^M=\pse@l
}
\Mdef\asmst@r{
   \relax
   \ifvmode
      *
      \unverb@tim
      \commentfont
      \activeM
      \let^^M=\pse@l
   \else
      *
   \fi
}

% Other verbatim-related things
\Mdef\olapv@rb^^M{
   \null
   \par
   \vskip-\baselineskip
}

\def\v@rbtab{
   \hskip8\sp@ceskip\relax     % Not quite right, but close enough
}


% Easy-to-use verbatim stuff, for |normal| or ||full|| verbatim sections
\def\verbb@r{
   \relax
   \ifmmode
      \let\next=\vert
   \else
      \let\next=\verb@tim
   \fi
   \next
}
\let|=\verbb@r
\def\verb@tim{
   \leavevmode
   \begingroup
   \verbatim
   \verbbr@ces
   \futurelet\next\verb@t@m
}
\def\verb@t@m{
   \ifx\next|
      \let\n@xt=\g@bble
      \fullverbatim
      \let|=\endfverb@tim
   \else
      \let\n@xt=\relax
      \let|=\endverb@tim
   \fi
   \let^^X=\endverb@tim
   \let^^F=\endverb@tim
   \n@xt
}
\def\endfverb@tim{
   \futurelet\next\endfverb@t@m
}
\def\endfverb@t@m{
   \ifx\next|
      \let\n@xt=\endfv@rb@t@m
   \else
      \let\n@xt=\relax
      \vertb@r
   \fi
   \n@xt
}
\def\endfv@rb@t@m#1{
   \endverb@tim
}
\let^^X=\verb@tim    % Shorthand: ^^Xnormal^^X
\def^^F{||}          %            ^^Ffull^^F

% Eat a word from text and print in verbatim mode, then do another command.
\long\def\vw@rd#1{
   \begingroup
   \verbatim
   \vw@rd@{#1}
}
\long\def\vw@rd@#1#2{
   #2
   \endgroup
   #1
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Displays  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newskip\displ@yskip \newcount\displ@ypenalty
\def\displayt@pskip#1#2{
   \displ@yskip=#1\relax
   \displ@ypenalty=#2\relax
   \ifvmode
      \ifdim\lastskip=\displ@yskip
      \else
         \penalty\displ@ypenalty
         \skip0=\displ@yskip
         \advance\skip0 by -1pt\relax    % adjust for descenders above
         \vskip\skip0\relax
      \fi
   \else
      \par
      \penalty\displ@ypenalty
      \vskip\displ@yskip\relax
   \fi
}
\def\displayb@tskip{
   \multiply\displ@ypenalty by 2\relax
   \penalty\displ@ypenalty
   \vskip\displ@yskip\relax
}
\def\begindispl@y{
   \parindent=0pt
   \parskip=0pt
   \displayt@pskip\exampleskip{100}
   \advance\leftskip by \exampleindent
   \interlinepenalty=500
   \obeylinespenalty=\interlinepenalty
}
\def\enddispl@y{
   \endgraf
   \displayb@tskip
   \endgroup
   \continuegraf
}


% Begin a text display.
% Usage:  \display declarations ^^M 
%            lines of text 
%         \done
\def\display{
   \begingroup
   \begindispl@y
   \let\done=\enddispl@y
   \obeylines
   \advance\hsize by \examplefudge
   \displayfont
   \displ@@y
}
\Mdef\displ@@y#1^^M{
   #1
   \obeyspaces
}


% Begin an itemized list
% Usage:  \list{left column example}   % sets the width of the left column
%            \preamble{left column header}   % optional
%            \packed                         % optional
%            \indented                       % optional
%            \item{left text} right text ...
%            \itemomit{left text} right text ...   % omits preamble
%         \done
\newdimen\listdim@n
\def\list#{
   \begingroup
   \ifvmode
      \let\it@mskip=\parskip
   \else
      \let\it@mskip=\z@
   \fi
   \displayt@pskip\listskip{0}
   \setbox0=\hbox\bgroup
      \bgroup
         \aftergroup\list@
         \g@bble   % gobble the {
}
\def\list@{
   \egroup
   \listdim@n=\wd0
   \listpre@mble{}
   \advance\leftskip by \listdim@n
   \advance\leftskip by .5em
   \let\done=\enddispl@y
   \let\packed=\listp@cked       % inside list, cancels interitem skip
   \let\preamble=\listpre@mble   % sets the preamble
   \let\indented=\listind@nted   % causes list to be indented by \exampleindent
   \let\item=\listit@m           % starts a new list item
   \let\itemomit=\listit@momit   % starts a list item, preamble omitted
}
\def\listpre@mble#1{\def\listf@rmat{#1}}
\def\listp@cked{\itemskip=\z@\relax}
\def\listind@nted{\advance\leftskip by \exampleindent}

\def\beginit@m{
   \ifdim\it@mskip\gth@n\z@
      \vskip\it@mskip
   \else
      \par
      \penalty300\relax
   \fi
   \let\it@mskip=\itemskip
   \continuegraf
}
\def\endit@m{
   \ignorespaces
}
\def\listit@m#{
   \beginit@m
   \hbox to 0pt\bgroup
      \hss
      \hbox to \listdim@n\bgroup
         \vtop to 0pt\bgroup
            \hsize=\listdim@n
            \leftskip=0pt
            \rightskip=0pt plus .75\listdim@n
            \hskip 0in     % helps hyphenation to work
            \listf@rmat
            \bgroup
               \catcode`\{=1 \catcode`\}=2
               \aftergroup\l@stit@m
               \g@bble   % gobble the {
}
\def\l@stit@m{
            \par
            \vss
         \egroup
         \hss
      \egroup
      \hskip .5em
   \egroup
   \endit@m
}

\long\def\listit@momit#1{   % omit the preamble (\listf@rmat)
   \beginit@m
   \hbox to 0pt{
      \hss
      \hbox to \listdim@n{
         \vtop to 0pt{
            \hsize=\listdim@n
            \leftskip=0pt
            \rightskip=0pt plus .75\listdim@n
            \hskip 0in     % helps hyphenation to work
            #1\par
            \vss
         }
         \hss
      }
      \hskip .5em
   }
   \endit@m
}


% Begin a "verbatim display" terminated by \done
% Usage:  \example declarations ^^M
%            lines of text 
%         \done
\def\example{
   \begingroup
   \begindispl@y
   \activeM
   \ex@mple
}
\Mdef\ex@mple#1^^M{
   \verbatim
   \let|=\ex@mplebar
   \ex@@mple
   #1
}
\def\ex@@mple{
   \verbbr@ces
   \advance\hsize by \examplefudge
   \let\done=\enddispl@y
}
\def\ex@mplebar{
   \unverb@tim
   \let|=\endgroup
}


% Begin a "fully verbatim display" (same syntax as \example)
\def\fvexample{
   \begingroup
   \begindispl@y
   \activeM
   \fvex@mple
}
\Mdef\fvex@mple#1^^M{
   \verbatim
   \advance\hsize by \examplefudge
   #1
   \fullverbatim
   \catcode`\|=\other
   \fvex@@mple
}
\begingroup
   \catcode`\/=0
   \catcode`\\=/other
   /long/global/def/fvex@@mple#1\done{
      #1
      /enddispl@y
   }
/endgroup


% Begin a "BNF notation" display
\let\bnfc@l@n=:
\catcode`\:=\active
\def\bnf{
   \begingroup
   \begindispl@y
   \let\done=\endbnf
   \catcode`\<=\active \let<=\bnflangle
   \catcode`\>=\active \let>=\bnfrangle
   \catcode`\:=\active \let:=\bnfcolon
   \let\eq=\bnfeq
   \let\|=\bnfor
   \global\let\bnfor@=\bnflineor
   \let\par=\bnfskip
   \let\cr=\bnfcr
   \halign\bgroup\qquad\hfil##&\hfil##&~##\hfil \endline   % \endline = \cr
}
\def\bnflangle{
   \begingroup
   $\langle$
}
\def\bnfrangle{
   $\rangle$
   \endgroup
}
\def\bnfcolon{
   \futurelet\next\bnfc@lon
}
\def\bnfc@lon{
   \ifx\next:
      \let\next=\bnfc@lonA
   \else
      \let\next=\bnfc@l@n
   \fi
   \next
}
\def\bnfc@lonA:{
   \futurelet\next\bnfc@lonB
}
\def\bnfc@lonB{
   \ifx\next=
      \let\next=\bnfc@lonC
   \else
      \bnfc@l@n
      \let\next=\bnfc@l@n
   \fi
   \next
}
\def\bnfc@lonC={
   \bnfeq
}
\catcode`\:=\other
\def\bnfeqsymbol{
   $::=$
}
\def\bnfeq{
   \global\let\bnfor@=\bnfintor
   &\bnfeqsymbol&
}
\def\bnfor{
   \bnfor@
   \global\let\bnfor@=\bnfintor
   \ignorespaces
}
\def\bnflineor{
   &$|$&
}
\def\bnfintor{
   $|$
   \space
}
\def\bnfskip{
   \crcr
   \noalign{\medskip}
   \global\let\bnfor@=\bnflineor
}
\def\bnfcr{
   \global\let\bnfor@=\bnflineor
   \endline
}
\def\endbnf{
   \crcr
   \egroup
   \enddispl@y
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Figures  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Usage:  \figure{caption}
%            vertical-mode text 
%         \done
\newbox\capti@nbox
\def\figure#{
   \begingroup
   \setbox\capti@nbox=\vbox\bgroup
      \captionfont
      \beginc@nterline
      \bgroup
         \aftergroup\fig@re
         \g@bble
}
\def\fig@re{
   \egroup
   \midinsert
   \let\done=\endfig@re
   \bigskip
   \hsize=\normalhsize
   \vbox\bgroup
   \let\afterfig@re=\afterfigure
   \afterassignment\afterfig@re
   \global\let\afterfigure=\relax
}
\global\let\afterfigure=\relax
\def\endfig@re{
      \medskip
      \box\capti@nbox
   \egroup
   \bigskip
   \endinsert
   \endgroup
}

% Usage:  \figpic{width height filename}{caption}
\def\figpic#1#2#{       % #2 is blank space before caption
   \def\afterfigure{\figp@c{#1}}
   \figure
}
\def\figp@c#1{
      \hfill \pspic{#1} \hfill \null
   \done
}

% Fix LBL to take a non-restricted argument
\let\oldLBL=\LBL
\def\newLBL#1#2#3#4#5#6#7#{      % #7 is normally blank
   \vbox to 0pt \bgroup
      \ifnum#2=1\let\LBLtemp@=\hss\else\let\LBLtemp@=\relax\fi
      \ifnum#4=1\let\LBLtemp@@=\vss\else\let\LBLtemp@@=\relax\fi
      \def\LBLtemp@@@{#5}
      \def\LBLtemp@@@@{#6}
      \vskip-\y@ff
      \vskip-#6\ysc@le
      \hbox to 0pt \bgroup
         \hskip\x@ff
         \hskip#5\xsc@le
         \psRotate{0}
         \vbox to 0pt \bgroup
            \ifnum#3=1\vss\fi
            \setbox0=\hbox to 0pt \bgroup
               \ifnum#1=1\hss\fi
               \bgroup
                  \aftergroup\newLBL@
                  \g@bble
}
\def\newLBL@#1{
               \LBLtemp@
            \egroup
            \dp0=0pt
            \box0
            \LBLtemp@@
         \egroup
         \hskip1pt
         \psUnRotate
         \hskip-1pt
         \hskip-\LBLtemp@@@\xsc@le
         \hskip-\x@ff
      \egroup
      \vskip\LBLtemp@@@@\ysc@le
      \vskip\y@ff
   \egroup
}

% Use old label system (labels are restricted)
\def\oldlabels{
   \let\LBL=\oldLBL
}

% Use new label system (unrestricted, but rotation not supported)
\def\newlabels{
   \let\LBL=\newLBL
}
\newlabels     % this is the default



%%%%%%%%%%%%%%%%%%%%%%%%%  Other macros for handouts  %%%%%%%%%%%%%%%%%%%%%%%%%

% Usage:  \section{section-title}
\def\section#{
   \begingroup
      \parskip=0in
      \parindent=0in
      \vskip\sectionskip
      \bgroup
         \largesize
         \sectionfont
         \aftergroup\secti@n
         \g@bble
}
\def\secti@n{
      \par
      \nobreak
      \vskip\aftersectionskip
      \nobreak
   \endgroup
}


% Usage:  \imported{declaration} 
%            paragraphs
%         \done
\outer\def\imported{
   \setbox0=\hbox\bgroup
      \bgroup
         \aftergroup\imp@rted
         \it
         \g@bble  % gobble the {
}
\def\imp@rted{
   \egroup
   \begingroup
   \displayt@pskip\importskip{-100}
   \advance\leftskip by \importindent
   \parindent=0in
   \continuegraf
%   \hskip-2\importindent
   \hskip-\importindent
   \llap{$\Rightarrow$ \space}
   \box0
   \hfill \break
   \let\done=\enddispl@y
   \ignorespaces
}


% Putting things in boxes
\def\inbox#1{
   \hbox{
      \lower1pt\hbox{
         \vrule
         \vbox{
            \hrule
            \kern 1pt
            \hbox{
               \kern 1pt
               #1
               \kern 1pt
            }
            \kern 1pt
            \hrule
         }
         \vrule
      }
      \kern 1pt
   }
}
% Put text in a box hanging out to the left
\def\hangbox#1{
   \leavevmode
   \llap{\inbox{#1}\hskip.8em\relax}
   \hskip0pt\relax
}


% Usage:  \exercise 
%            paragraphs
%         \done
\newcount\ex@rciseno \ex@rciseno=0
\outer\def\exercise{
   \advance\ex@rciseno by 1
   \doexercise{Exercise\ \number\ex@rciseno}
}
\def\doexercise#1{
   \begingroup
   \tempendgraf
   \parindent=0in
   \parskip=0in
   \displayt@pskip\exerciseskip{-100}
   \advance\leftskip\exerciseindent
   \hskip-\exerciseindent
   \llap{\Arrow\enspace}
   {\exercisefont #1:\hskip.8em}
   \parskip=\exerciseparskip
   \let\done=\enddispl@y
   \ignorespaces
}
\def\exerciseno#1{{\exercisefont #1}}
\def\lastexercise{\exerciseno{\number\ex@rciseno}}



%%%%%%%%%%%%%%%%%%%%%%%%%%%  Generic Handout format  %%%%%%%%%%%%%%%%%%%%%%%%%%

% Usage:  \class{class-name}        (default is CS10)
\def\class#1{
   \def\classn@me{#1}
   \ifx\classn@me\empty
      \let\classn@mequad=\empty
      \let\classn@mesp=\empty
   \else
      \def\classn@mequad{#1\quad}
      \def\classn@mesp{#1\ }
   \fi
}
\class{CS10}


% Usage:  \handout{short-title}{full-title}
\def\handout#1#2{
   \def\title{\classn@mequad #1}
   \centerline{\titlefont #2}
   \firstpage
}


% Usage:  \handoutx{short-title}{full-title}{sub-title}
\def\handoutx#1#2#3{
   \def\title{\classn@mequad #1}
   \centerline{\titlefont #2}
   \smallskip
   \centerline{\subtitlefont #3}
   \firstpage
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Lab Handout format  %%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Usage:  \assignment{short-title}{full-title}
\def\assignment#1#2{
   \def\title{\classn@mequad #1}
   \centerline{\titlefont \classn@mesp #1}
   \smallskip
   \centerline{\subtitlefont #2}
   \firstpage
}


% Usage:  \notes{short-title}{full-title}
\def\notes#1#2{
   \def\title{\classn@mequad #1}
   \centerline{\subtitlefont \classn@mesp #1}
   \medskip
   \centerline{\titlefont #2}
   \firstpage
}


% Usage:  \lab{lab-number}{full-title}
\outer\def\lab#1#2{
   \assignment{Lab\ #1}{#2}
}


% Usage:  \extra{extra-number}{full-title}
\outer\def\extra#1#2{
   \assignment{Extra\ Credit\ \##1}{#2}
}


% Usage:  \quiz{quiz-number}{full-title}
\outer\def\quiz#1{
   \vbox to0pt{
      \vskip-.55in
      \line{Your!name:\quad\hbox{\vrule height0pt depth.4pt width 2in}
            \qquad Your!section:\quad\hbox{\vrule height0pt depth.4pt width.5in}\hfil}
      \vss
   }
   \def\title{\classn@mequad Quiz\ #1}
   \centerline{\titlefont \classn@mesp Quiz\ #1}
   \firstpage
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Clean up after macro definitions
\normaldefs


% End of labmac.

%%%%%%%%%%%%%%%%%
