% Macros for the `general' DTD.
% Gary Houston.

\input{gftext.sty}
\input{gfhead.sty}
\input{gfdisplay.sty}
\input{gffig.sty}
\input{gfstructure.sty}
\input{gflink.sty}

\setcounter{secnumdepth}{2}

% Start each \part and \section on a new page.
\def\part{\cleardoublepage\par     % New paragraph
   \addvspace{4ex}           % Adds vertical space above title.
   \@afterindentfalse        % Suppresses indent in first paragraph.  Change
   \secdef\@part\@spart}     % to \@afterindenttrue to have indent.

\def\section{\clearpage\@startsection {section}{1}{\z@}{-3.5ex plus -1ex minus 
    -.2ex}{2.3ex plus .2ex}{\Large\bf}}

% Table of contents.
\def\gftoc{\cleardoublepage\tableofcontents}
\def\gflof{\cleardoublepage\listoffigures}

\def\address#1{{\small#1\par}}

% Command for printing the index.
\def\printindex{\@input{\jobname.ind}}

\def\titlepage{
  \bgroup % keep definitions local
  \clearpage\thispagestyle{docnum}\c@page\z@
  \let\footnotesize\small \let\footnoterule\relax
  \null\vfil\begin{center}}

\def\endtitlepage{\end{center}\vfil\null\clearpage
  \pagestyle{plain}\pagenumbering{roman}
  \if@twoside\thispagestyle{empty}\c@page\z@\fi
  \egroup}

% Other titlepage elements.
\def\title#1{\LARGE #1\par}
\def\author#1{\large#1\par}
\def\date#1{\large #1\par} 

% Body of the document.
\def\body{
  \cleardoublepage
  \thispagestyle{plain}
  \pagenumbering{arabic}}

% Headings in various places.
\def\titlepheading#1{\par{\large\bf#1}\par}
\def\abstractheading#1{\par{\large\bf#1}\par}
\def\prefaceheading#1{\par{\large\bf#1}\par}
\def\frontheading#1{\clearpage{\large\bf#1}\par}
\def\backheading#1{\clearpage{\large\bf#1}\par}
\def\subheading#1{\par{\bf#1}\par}

% Topics
\long\def\topone{\par}
\long\def\endtopone{\par}
\long\def\toptwo{\par}
\long\def\endtoptwo{\par}
\long\def\topthree{\par}
\long\def\endtopthree{\par}
\long\def\topfour{\par}
\long\def\endtopfour{\par}

\def\topheading#1{\par{\bf#1}\par}

% Abstract in title page.
\def\tabstract{\vfil}
\def\endtabstract{\vfil}
  
% Abstract elsewhere.
\def\abstract{\cleardoublepage\null\vfil\begin{center}}
\def\endabstract{\end{center}\null\vfil}

% Preface.
\def\preface{\cleardoublepage}
\def\endpreface{}

% Bibliography.
\def\bibliog{\cleardoublepage}
\def\endbibliog{}

% Glossary.
\def\gfglossary{\cleardoublepage}
\def\endgfglossary{}
\def\glossaryline{\newline}

% Glossary list.
\long\def\glosslist{\par}
\long\def\endglosslist{\par}
\long\def\glossitem[#1]#2{{\bf#1}\newline#2\par}

% Citations.
\def\cit#1{\em#1}

% Definition list.
\def\dlinit{% initialize the temporary dimensions to zero
  \dimen1=\z@\dimen2=\z@\dimen3=\z@\dimen4=\z@\dimen5=\z@\dimen6=\z@
  \dimen7=\z@\dimen8=\z@\dimen9=\z@}
\def\dlheadtest#1#2{\setbox0=\hbox{\quad\bf#2}\ifdim\wd0>\dimen#1\dimen#1=\wd0\fi}
\def\dltest#1#2{\setbox0=\hbox{\quad#2}\ifdim\wd0>\dimen#1\dimen#1=\wd0\fi}
\def\dltitletag#1#2{\hbox to \dimen#1{\quad\bf#2\hfil}}
\long\def\dltitletext#1{\hbox{\quad}\vtop{\noindent\hsize=\dimen0\bf\ignorespaces#1\strut}}
\def\dltag#1#2{\hbox to \dimen#1{\quad#2\hfil}}
\long\def\dltext#1{\hbox{\quad}\vtop{\noindent\hsize=\dimen0\ignorespaces#1\strut}}
\def\dl{\par\noindent
  \dimen0=\hsize
  \advance\dimen0 by -\dimen1
  \advance\dimen0 by -\dimen2
  \advance\dimen0 by -\dimen3
  \advance\dimen0 by -\dimen4
  \advance\dimen0 by -\dimen5
  \advance\dimen0 by -\dimen6
  \advance\dimen0 by -\dimen7
  \advance\dimen0 by -\dimen8
  \advance\dimen0 by -\dimen9
  \advance\dimen0 by -1em% em == quad
}
\def\enddl{}

% Put text in a box: from the TeXbook, Chapter 21.
% Used for framing figures.
\def\boxit#1{\vbox{\hrule\hbox{\vrule\kern3pt
  \vbox{\kern3pt#1\kern3pt}\kern3pt\vrule}\hrule}}

% Put top and bottom rules around text.
% Used for framing figures.
\def\ruleit#1{\vbox{\hrule\hbox{\kern3pt
  \vbox{\kern3pt#1\kern3pt}\kern3pt}\hrule}}

% Create an empty box: used for <artwork>.
\def\emptybox#1#2{\dimen0=#1\divide\dimen0 by 2\vbox to \dimen0{\vss
  \vtop to \dimen0{\vss\hbox to #2{}}}}

% Table elements.

% Macros to store and replace a few line-breaking parameters.
\def\storeskips{\dimen2=\the\baselineskip
\dimen3=\the\lineskip \dimen4=\the\lineskiplimit}

\def\oldskips{\baselineskip=\dimen2
\lineskip=\dimen3 \lineskiplimit=\dimen4}

% Highlight a row heading.
\def\rowhead#1{\hpone{#1}}

% Counter with number of columns in table.
\newcount\gencols

% Create a horizontal rule.
\def\rowrule{\multispan{\the\gencols}\hrulefill\cr}

% Start the table. The parameter specifies the number of columns.
\long\def\gentable#1{%
  \par\noindent
  % calculate the widths of the columns
  \dimen1=\hsize
  \divide\dimen1 by #1
  \advance\dimen1 by -2em	% Separate columns from lines with \quad.
  \storeskips			% Save line break parameters.
  % Calculate total number of columns, including vrules.
  \gencols=#1
  \multiply\gencols by 2
  \advance\gencols by 1
  \begingroup
  \offinterlineskip		% No interline space: fixes vertical lines.
  \halign\bgroup\vline##&&\quad\vtop{\noindent\hsize=\dimen1\oldskips##\strut}\quad&##\vline\cr
}

% End the table.
\long\def\endgentable{%
  \egroup
  \endgroup
  \par\noindent
}

\def\linespar{\@par}
{\catcode`\^^M=\active % these lines must end with %
  \gdef\setlines{\catcode`\^^M\active \let^^M\linespar %
}}

\def\lines{\leavevmode\newline
  \begingroup
  \parskip = 0pt
  \parindent = 0pt
  \emergencystretch = 0pt
  \setlines
  \@gobble}
\def\endlines{\endgroup}

\def\xmp{\leavevmode\newline
  \begingroup
  \tt
  \parskip = 0pt
  \parindent = 0pt
  \emergencystretch = 0pt
  \setlines
  \@gobble}
\def\endxmp{\endgroup}

