%%% ====================================================================
%%% @LaTeX-file{
%%%   filename  = "amsdtx.dtx",
%%%   version   = "2.02",
%%%   date      = "1999/12/13",
%%%   time      = "13:59:36 EST",
%%%   author    = "Michael J Downes",
%%%   copyright = "Copyright 1996, 1999 American Mathematical Society,
%%%                all rights reserved.  Copying of this file is
%%%                authorized only if either:
%%%                (1) you make absolutely no changes to your copy,
%%%                including name; OR
%%%                (2) if you do make changes, you first rename it
%%%                to some other name.",
%%%   email     = "tech-support@ams.org (Internet)",
%%%   address   = "American Mathematical Society,
%%%                Technical Support,
%%%                Electronic Products and Services,
%%%                P. O. Box 6248,
%%%                Providence, RI 02940,
%%%                USA",
%%%   telephone = "401-455-4080 or (in the USA and Canada)
%%%                800-321-4AMS (321-4267)",
%%%   FAX       = "401-331-3842",
%%%   checksum  = "30978 936 2987 31802",
%%%   keywords  = "latex, amslatex, ams-latex, user documentation",
%%%   supported = "yes",
%%%   abstract  = "This is the source for two document classes used
%%%                to produce AMS user documentation or technical
%%%                documentation.",
%%%   docstring = "The checksum field above contains a CRC-16
%%%                checksum as the first value, followed by the
%%%                equivalent of the standard UNIX wc (word
%%%                count) utility output of lines, words, and
%%%                characters.  This is produced by Robert
%%%                Solovay's checksum utility.",
%%% }
%%% ====================================================================
%
% \iffalse
%    The following section of code makes this file self-printable.
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\documentclass{amsdtx}
\newcommand{\rp}{\let\PBS\\\raggedright\let\\\PBS}
\begin{document}
\title{The \cls{amsldoc} and \cls{amsdtx} document classes}
\author{American Mathematical Society\\Michael Downes}
\date{Version \fileversion, \filedate}
\hDocInput{amsdtx.dtx}
\end{document}
%</driver>
% \fi
%
%^^A If this file is printed by itself the \fileversion and \filedate
%^^A information will come from the file header rather than from the
%^^A \ProvidesClass command. See \hDocInput.
% \maketitle
%
% \MakeShortVerb\|
% \section{Introduction}
%    This file is the source for two documentclasses, \cls{amsldoc}
%    (used for the \amslatex/ user's guide) and \cls{amsdtx} (used for
%    printing AMS \fn{.dtx} files). The generic \cls{book} class is used
%    as a base, but the \cls{amsdtx} class is modified to serve as an
%    article-type class. This affects the form of documentation files
%    mainly in the use of \cn{maketitle} and \cn{chapter}.
%
% \begin{table}
% \caption{Features of the \cls{amsldoc} and \cls{amsdtx} classes}
% \newcommand{\rpth}{\rp{.75}}
% \centering
% \begin{tabular}{lp{.65\columnwidth}}
% Command Name& Purpose\\
% \hline
% \cn{cn}& \rp To print a user command name: \verb"\cn{title}"; leading
%   backslash can be optionally included for control symbols:
%   \verb"\cn{\%}". The \cn{cn} command works properly even in macro
%   arguments (compare to, e.g., \cn{verb}\verb"'\newif'"). But beware
%   of a fragile control symbol (are there any?) in a moving argument.\\
% \cn{cs}& \rp `Control sequence': to print an internal command name,
%   not intended for the end user\\
% \cn{env}& \rp To print an environment name: \verb"\env{table}"\\
% \cn{pkg}& \rp To print a package name: \verb"\pkg{eufrak}"\\
% \cn{cls}& \rp To print a class name: \verb"\cls{book}"\\
% \cn{opt}& \rp To print the name of a class or package option:
%   \verb"\opt{twocolumn}"\\
% \cn{fn}& \rp To print a file name or font name: \verb"\fn{T1enc.def}",
%   \verb"\fn{cmsy10}"\\
% \cn{qc}& \rp To quote a single character: \verb"\qc{\%}";
%   this works properly for special characters, even in macro
%   arguments, unlike e.g., \verb"\verb'%'"\\
% \cn{latex/} etc.& \rp Convenient forms of \cn{LaTeX}, \cn{TeX},
%   \cn{BibTeX}, etc. that are easier to type and have a trailing slash
%   to eliminate the following-space problem (without needing different
%   markup in different contexts)
% \end{tabular}
% \end{table}
%
% \StopEventually{}
%
%    Standard starting pieces. (Note: the reason each \cn{ProvidesClass}
%    command is placed on a line by itself, with separate begin and end
%    guards for docstripping, is to make automatic update of file date
%    and version slightly easier and more robust.)
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
[1994/12/01]% LaTeX date must be December 1994 or later
%<*amsldoc>
\ProvidesClass{amsldoc}[1999/12/13 v2.02]
%</amsldoc>
%<*amsdtx>
\ProvidesClass{amsdtx}[1999/12/13 v2.02]
%</amsdtx>
%    \end{macrocode}
%
% \section{Implementation}
%    Start with the generic book class as a base.
%    \begin{macrocode}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}
\ProcessOptions
\LoadClass{book}
%    \end{macrocode}
%
%    \begin{macrocode}
\IfFileExists{url.sty}{%
  \RequirePackage{url}\relax
  \@gobble
}{%
  \@firstofone
}
{
  \DeclareRobustCommand{\url}[1]{%
    \def\@tempa{#1}%
    \texttt{\urlsetup $\expandafter\strip@prefix\meaning\@tempa$}%
  }%
  \def\urlsetup{%
    \check@mathfonts \textfont\@ne\the\font \textfont\z@\the\font
    \urlfix +\urlfix\=\urlfix\:\urlfix\-\urlfix\.\urlfix\,\urlfix\;%
    \urlbreak\&\urlbreak\/\urlbreak\?%
  }%
  \def\urlbreak#1{%
    \mathcode`#1="8000
    \begingroup \lccode`\~=`#1 \lowercase{\endgroup \edef~}%
    {\mathchar\number`#1\penalty\hyphenpenalty}%
  }%
  \def\urlfix#1{%
    \mathcode`#1=`#1\relax
  }%
}
%    \end{macrocode}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%    \begin{macrocode}
\providecommand{\qq}[1]{\textquotedblleft#1\/\textquotedblright}
\providecommand{\mdash}{\textemdash}
\providecommand{\ndash}{\textendash}
%    \end{macrocode}
%
%    Some functions to support \cn{cn} etc. For most of these commands
%    we don't really want them to be \cs{long}! But in some early
%    releases of LaTeX 2e the \verb'*' form of \cn{newcommand} was not
%    yet available.
%
%    We use the name \cn{bslchar} instead of \cn{bslash} to avoid
%    potential conflict with the \pkg{doc} package \cn{bslash} command.
%    Unlike \cn{bslash}, \cn{bslchar} survives unlimited
%    writing/expansion because it is a chardef.
%    \begin{macrocode}
\chardef\bslchar=`\\ % p. 424, TeXbook
\newcommand{\addbslash}{\expandafter\@addbslash\string}
\def\@addbslash#1{\bslchar\@nobslash#1}
\newcommand{\nobslash}{\expandafter\@nobslash\string}
\def\@nobslash#1{\ifnum`#1=\bslchar\else#1\fi}
%    \end{macrocode}
%
%    We define some macros to do automatic indexing of control
%    sequences, environments, options, and file names.
%    \begin{macrocode}
\newcommand{\autoindex}{\index}
%    \end{macrocode}
%    To avoid font substitution warnings we make the tt font always
%    print in the normal weight and shape.
%    \begin{macrocode}
\newcommand{\ntt}{\normalfont\ttfamily}
%    \end{macrocode}
%
%  \begin{macro}{\@boxorbreak}
%    Start up for a \cn{cs} or \cn{cn} command, adds an \cs{hbox} if in
%    math, or an allowbreak penalty if the preceding item is not a space.
%    (In case two such commands are used side-by-side.)
%    \begin{macrocode}
\def\@boxorbreak{\leavevmode
  \ifmmode\hbox\else\ifdim\lastskip=\z@\penalty9999 \fi\fi}
%    \end{macrocode}
%  \end{macro}
%
%    Control sequence. The function \cn{addbslash} makes this command
%    also usable for some special control sequences like \cn{\%} \cn{\}}
%    \cn{\{}: instead of writing |\cs{%}| which doesn't work, you can
%    write |\cs{\%}|.
%    \begin{macrocode}
\DeclareRobustCommand{\cs}[1]{\@boxorbreak{\ntt\addbslash#1\@empty
  \autoindex{\nobslash#1@\string\cs{\string#1\@empty}}}}
%    \end{macrocode}
%
%    Allow distinguishing non-private `command names' that will be
%    visible to the user from internal (mostly private) `control
%    sequences'.
%    \begin{macrocode}
\DeclareRobustCommand{\cn}[1]{\@boxorbreak{\ntt\addbslash#1\@empty
%    \end{macrocode}
%    The \cn{nobslash} function here removes the leading backslash (for
%    sorting purposes only) so that command names after sorting will be
%    interspersed with regular words. The final \cs{@empty} is just to
%    avoid bad errors if an empty argument is accidentally given; the
%    printed results will be nonsense.
%    \begin{macrocode}
  \autoindex{\nobslash#1@\string\cn{\string#1\@empty}}}}
%    \end{macrocode}
%
%    The following items should not normally appear in math mode so they
%    don't need to call \cs{@boxorbreak}.
%
%    \latex/ documentclass name.
%    \begin{macrocode}
\DeclareRobustCommand{\cls}[1]{{\ntt#1}%
  \autoindex{#1@\string\cls{#1} class}}
%    \end{macrocode}
%
%    \latex/ package name.
%    \begin{macrocode}
\DeclareRobustCommand{\pkg}[1]{{\ntt#1}%
  \autoindex{#1@\string\pkg{#1} package}}
%    \end{macrocode}
%
%    \latex/ option name.
%    \begin{macrocode}
\DeclareRobustCommand{\opt}[1]{{\ntt#1}%
  \autoindex{#1@\string\opt{#1} option}}
%    \end{macrocode}
%
%    Environment name.
%    \begin{macrocode}
\DeclareRobustCommand{\env}[1]{{\ntt#1}%
  \autoindex{#1@\string\env{#1} environment}}
%    \end{macrocode}
%
%    File name.
%    \begin{macrocode}
\DeclareRobustCommand{\fn}[1]{{\ntt#1}%
   \autoindex{#1@\string\fn{#1}}}
%    \end{macrocode}
%
%    \bibtex/ style.
%    \begin{macrocode}
\DeclareRobustCommand{\bst}[1]{{\ntt#1}\autoindex{#1@{\string\ntt{}#1
  bibliography style}}}
%    \end{macrocode}
%
%    To index a control sequence without printing it. Note non-long.
%    \begin{macrocode}
\newcommand{\indexcs}[1]{\autoindex{#1@\string\cs{#1}}}
%    \end{macrocode}
%
%    With long command names or file names we sometimes prefer to allow
%    hyphenation in the tt font (in combination with suitable
%    \cn{hyphenation} statements for individual documents). To make this
%    work we must turn off the feature of \latex/ that disables the
%    hyphenchar of the tt fonts.
%
%    The method shown here depends on the assumption that OT1 encoding
%    will be used for the tt fonts. An encoding-independent method would
%    be more awkward: You'd have to explicitly load the relevant
%    fonts, let's say by using \cn{AtBeginDocument}, and undo the
%    hyphenchar change individually for each font.
%
%    Instead we force loading, or possibly reloading (depending on the
%    preload options used locally for creating the LaTeX format file),
%    of the \fn{OT1/cmtt} fd file, and then clear the macro
%    \cs{OT1+cmtt} which contains code to execute whenever a font of
%    this family is first loaded. The default value is to turn off the
%    hyphenchar, and that's what we don't want.
%
%    This method is not especially palatable but other methods that
%    don't involve loading the fd file are significantly less reliable.
%    \begin{macrocode}
\def\allowtthyphens{\begingroup
  \fontencoding{OT1}\fontfamily{cmtt}%
%    \end{macrocode}
%    Undefine the csname that \cs{try@load@fontshape} tests to determine
%    whether the fd file needs loading. Then call
%    \cs{try@load@fontshape}. Then we can remove the `turn off
%    hyphenation' code, which as it happens resides in the same csname
%    that was tested.
%    \begin{macrocode}
  \expandafter\let\csname OT1+cmtt\endcsname\relax
  \try@load@fontshape
  \endgroup
  \expandafter\let\csname OT1+cmtt\endcsname\@empty
}
%    \end{macrocode}
%
%    We allow some slop at the right margin because we have some
%    long control sequence names and verbatim text to deal with. Also
%    ignore underfull hboxes and vboxes unless they are really bad.
%    \begin{macrocode}
\hfuzz2pc
\vbadness9999 \hbadness5000
%    \end{macrocode}
%
%    \begin{macrocode}
\def\AmS{{\protect\usefont{OMS}{cmsy}{m}{n}%
  A\kern-.1667em\lower.5ex\hbox{M}\kern-.125emS}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\latex/{{\protect\LaTeX}}
\def\amslatex/{{\protect\AmS-\protect\LaTeX}}
\def\tex/{{\protect\TeX}}
\def\amstex/{{\protect\AmS-\protect\TeX}}
\def\bibtex/{{Bib\protect\TeX}}
%    \end{macrocode}
%
%    \cn{makeindex} command is already used for other purposes.
%    \begin{macrocode}
\def\makeindx/{MakeIndex}
%    \end{macrocode}
%
%    Don't allow a break after the hyphen:
%    \begin{macrocode}
\def\xypic/{XY\mbox{-}pic}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\Textures}{\textit{Textures}}
%    \end{macrocode}
%
%    `Meta' macro.
%    \begin{macrocode}
\def\<#1>{\textit{$\langle$#1\/$\rangle$}}
%    \end{macrocode}
%
%    Reduce itemsep in lists.
%    \begin{macrocode}
\def\@listi{%
  \leftmargin\leftmargini
  \topsep 3\p@ \@plus2\p@ \@minus\p@
  \parsep \p@ \@plus\p@ \itemsep\parsep
}
\let\@listI\@listi
\@listi
\def\@listii{%
  \leftmargin\leftmarginii
  \labelwidth\leftmarginii \advance\labelwidth-\labelsep
  \topsep\p@\@plus\p@ \@minus\p@
  \parsep\z@skip \itemsep\z@skip
}
\def\@listiii{%
  \leftmargin\leftmarginiii
  \labelwidth\leftmarginiii \advance\labelwidth-\labelsep
  \topsep\z@skip \parsep\z@skip \itemsep\z@skip
}
%    \end{macrocode}
%
%    An environment to encapsulate remarks relevant to old versions but
%    not essential for the current version.
%    \begin{macrocode}
\newenvironment{histnote}{%
  \trivlist\item[\hspace{\labelsep}\bfseries Historical Note:]%
}{%
  \endtrivlist
}
%    \end{macrocode}
%
%    Turn off \cs{autoindex} during \cn{tableofcontents} or similar.
%    \begin{macrocode}
\def\@starttoc#1{\begingroup
  \let\autoindex\@gobble
  \makeatletter
  \@input{\jobname.#1}\if@filesw
  \expandafter\newwrite\csname tf@#1\endcsname
             \immediate\openout
                 \csname tf@#1\endcsname \jobname.#1\relax
  \fi \global\@nobreakfalse \endgroup}
%    \end{macrocode}
%
%    Make glossary commands a no-op for the moment. [mjd,1994/10/03]
%    Provide a \cn{secref} command for section references.
%    \begin{macrocode}
%<*amsldoc>
\newcommand{\gloss}[1]{}
\newcommand{\secref}[1]{\S\ref{#1}}
%</amsldoc>
%    \end{macrocode}
%
%    We can write |\qc{\%}| to quote a single
%    character in situations where |\verb"%"| would not work, mainly
%    when text is read as a macro argument (e.g., footnotes).
%    \begin{macrocode}
\newcommand{\qc}[1]{}% check for prior definition
\edef\qc#1{\noexpand\protect\expandafter\noexpand\csname qc \endcsname
  \noexpand\protect#1}
%    \end{macrocode}
%    For this function the first argument is \cn{protect} and just needs
%    to be discarded. The method for removing a leading backslash is to
%    turn off \cs{escapechar}; this is more forgiving of variations like
%    |\qc{$}|. If the argument is |\ | we print a cmtt visible-space
%    character.
%    \begin{macrocode}
\@namedef{qc }#1#2{\begingroup\ntt
  \ifx\ #2\char`\ \else\escapechar\m@ne\string#2\fi\endgroup}
%    \end{macrocode}
%    Declare a few character names to avoid e.g., indexing difficulties.
%    \begin{macrocode}
\DeclareRobustCommand{\qcat}{\qc\@}%
\DeclareRobustCommand{\qcamp}{\qc\&}%
\DeclareRobustCommand{\qcbang}{\qc\!}%
%    \end{macrocode}
%
%  \begin{macro}{\arg}
%    Change \cn{arg} to print a macro argument number:
%    \begin{macrocode}
\DeclareRobustCommand{\arg}[1]{{\ntt\##1}}
%    \end{macrocode}
%  \end{macro}
%
%    We need to emulate the \pkg{amsthm} \cn{qedsymbol} for the
%    \amslatex/ user's guide.
%    \begin{macrocode}
%<*amsldoc>
\newcommand{\openbox}{\leavevmode
  \hbox to.77778em{%
  \hfil\vrule
  \vbox to.675em{\hrule width.6em\vfil\hrule}%
  \vrule\hfil}}
\newcommand{\qedsymbol}{\openbox}
%</amsldoc>
%    \end{macrocode}
%
%    Logical markup for e-mail address:
%    \begin{macrocode}
%<amsldoc>\def\mail{\texttt}
%    \end{macrocode}
%
%    Shorthand for indexing:
%    \begin{macrocode}
%<*amsldoc>
\def\*#1{\def\@tempa{#1}\def\@tempb{*}%
  \ifx\@tempa\@tempb \expandafter\index
  \else #1\index{#1}\fi}
%</amsldoc>
%    \end{macrocode}
%
%    Non-indexed \cn{cn} (maybe call this |\cn*|?)
%    \begin{macrocode}
\def\ncn#1{{\let\index\@gobble\cn{#1}}}
%    \end{macrocode}
%    Indexing difficulties with !, @.
%    \begin{macrocode}

\DeclareRobustCommand{\cnbang}{%
  \ncn{\!}\index{"!@{\ntt\bslchar\qcbang}}}
\DeclareRobustCommand{\cnat}{%
  \ncn{\!}\index{"@@{\ntt\bslchar\qcat}}}
%    \end{macrocode}
%
%    Shorthand for a discouraged, but not forbidden, line break:
%    \begin{macrocode}
\def\5{\penalty500 }
%    \end{macrocode}
%
%    Environment for error message examples. Use \cs{meaning} to allow
%    reading the error message text as an ordinary brace-delimited arg
%    but still be able to print embedded braces; and first change the
%    backslash catcode to prevent extra spaces after control words.
%    \begin{macrocode}
%<*amsldoc>
\newenvironment{error}{%
  \begingroup\catcode`\\=12 \expandafter\endgroup\errora
}{%
  \endtrivlist
}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\errora}[1]{%
  \trivlist
  \item[\hskip\labelsep\errorbullet\enspace
    \ntt\frenchspacing\def\@tempa{#1}%
    \expandafter\strip@prefix\meaning\@tempa]\leavevmode\par
}
%    \end{macrocode}
%    \cs{errorbullet} is just an attempt at a simple graphic device that
%    doesn't require any special fonts.
%    \begin{macrocode}
\newcommand{\errorbullet}{\rule[-.5pt]{2.5pt}{7.5pt}%
  \rule[-.5pt]{5pt}{2.5pt}\kern-2.5pt%
  \rule[4.5pt]{2.5pt}{2.5pt}}
%</amsldoc>
%    \end{macrocode}
%    A couple of subheading commands:
%    \begin{macrocode}
\newcommand{\errexa}{\par\noindent\textit{Example}:\ }
\newcommand{\errexpl}{\par\noindent\textit{Explanation}:\ }
%    \end{macrocode}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{\cls{amsldoc} style modifications for sectioning commands}
%    The following section deals with book commands (part, chapter,
%    frontmatter, \dots).
%    \begin{macrocode}
%<*amsldoc>
%    \end{macrocode}
%
%    Modifications of sectioning commands from \fn{book.cls}, mostly
%    reducing font sizes and vertical spacing.
%    \begin{macrocode}
\renewcommand\frontmatter{\clearpage
            \@mainmatterfalse\pagenumbering{roman}}
\renewcommand\mainmatter{\clearpage
       \@mainmattertrue\pagenumbering{arabic}}
\renewcommand\backmatter{\clearpage \@mainmatterfalse}
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand\part{\clearpage
                 \thispagestyle{plain}%
                 \if@twocolumn
                     \onecolumn
                     \@tempswatrue
                   \else
                     \@tempswafalse
                 \fi
                 \hbox{}\vfil
                 \secdef\@part\@spart}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >-2\relax
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    \markboth{}{}%
    {\centering
     \interlinepenalty \@M
     \reset@font
     \ifnum \c@secnumdepth >-2\relax
       \Large\bfseries \partname~\thepart
       \par
       \vskip 20\p@
     \fi
     \Large \bfseries #2\par}%
    \@endpart}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@spart#1{%
    {\centering
     \interlinepenalty \@M
     \reset@font
     \Large \bfseries #1\par}%
    \@endpart}
\def\@endpart{\vfil\newpage
              \if@twoside
                \hbox{}%
                \thispagestyle{empty}%
                \newpage
              \fi
              \if@tempswa
                \twocolumn
              \fi}
%</amsldoc>
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand\chapter{\par \@afterindentfalse
                    \secdef\@chapter\@schapter}
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                       \if@mainmatter
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline{\thechapter}#1}%
                       \else
                         \addcontentsline{toc}{chapter}{#1}\fi
                    \else
                      \addcontentsline{toc}{chapter}{#1}
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@makechapterhead#1{%
  \vspace{1.5\baselineskip}%
  {\parindent \z@ \raggedright \reset@font
    \ifnum \c@secnumdepth >\m@ne
      \large\bfseries \@chapapp\space\thechapter
      \par\nobreak
      \vskip.5\baselineskip\relax
    \fi
    #1\par\nobreak
    \vskip\baselineskip
  }}
\def\@schapter#1{\if@twocolumn
                   \@topnewpage[\@makeschapterhead{#1}]%
                 \else
                   \@makeschapterhead{#1}%
                   \@afterheading
                 \fi}
\def\@makeschapterhead#1{%
  \vspace*{1.5\baselineskip}%
  {\parindent \z@ \raggedright
    \reset@font
    \large \bfseries  #1\par\nobreak
    \vskip\baselineskip
  }}
%    \end{macrocode}
%
%    Add Donald Arseneau's \cs{@removefromreset}; used to decouple the
%    footnote counter from \cn{chapter}, since chapters here do not
%    automatically start on a new page.  [bnb, 1999/09/27]
%  \begin{verbatim}
%    \@removefromreset{FOO}{BAR} : Removes counter FOO from the list of
%                       counters \cl@BAR to be reset when counter BAR
%                       is stepped.  The opposite of \@addtoreset.
%  \end{verbatim}
%    \begin{macrocode}
\def\@removefromreset#1#2{\let\@tempb\@elt
   \expandafter\let\expandafter\@tempa\csname c@#1\endcsname
   \def\@elt##1{\expandafter\ifx\csname c@##1\endcsname\@tempa\else
         \noexpand\@elt{##1}\fi}%
   \expandafter\edef\csname cl@#2\endcsname{\csname cl@#2\endcsname}%
   \let\@elt\@tempb}
\@removefromreset{footnote}{chapter}
%    \end{macrocode}
%
%    Change running head font to \cn{footnotesize}, nonslanted.
%    \begin{macrocode}
%<*amsldoc>
\def\ps@headings{%
  \let\@oddfoot\@empty\let\@evenfoot\@empty
  \def\@evenhead{\thepage\hfil{\footnotesize\leftmark{}{}}}%
  \def\@oddhead{{\footnotesize\rightmark{}{}}\hfil\thepage}%
  \let\@mkboth\markboth
  \def\chaptermark##1{%
    \markboth {\uppercase{\ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \@chapapp\ \thechapter. \ \fi
      \fi
        ##1}}{}}%
  \def\sectionmark##1{%
    \markright {\uppercase{\ifnum \c@secnumdepth >\z@
        \thesection. \ \fi
        ##1}}}}
%</amsldoc>
%    \end{macrocode}
%
%
% \section{\cls{amsdtx} style modifications for sectioning commands}
%    These definitions for \cn{maketitle} are from \fn{article.cls}.
%    \begin{macrocode}
%<*amsdtx>
\renewcommand\maketitle{\par
  \begingroup
    \renewcommand\thefootnote{\fnsymbol{footnote}}%
    \def\@makefnmark{\hbox to\z@{$\m@th^{\@thefnmark}$\hss}}%
    \long\def\@makefntext##1{\parindent 1em\noindent
            \hbox to1.8em{\hss$\m@th^{\@thefnmark}$}##1}%
    \if@twocolumn
      \ifnum \col@number=\@ne
        \@maketitle
      \else
        \twocolumn[\@maketitle]%
      \fi
    \else
      \newpage
      \global\@topnum\z@   % Prevents figures from going at top of page.
      \@maketitle
    \fi
    \thispagestyle{plain}\@thanks
  \endgroup
  \setcounter{footnote}{0}%
  \let\thanks\relax
  \let\maketitle\relax\let\@maketitle\relax
  \gdef\@thanks{}\gdef\@author{}\gdef\@title{}}
%
\def\@maketitle{%
  \newpage
  \null
  \vskip 2em%
  \begin{center}%
    {\LARGE \@title \par}%
    \vskip 1.5em%
    {\large
      \lineskip .5em%
      \begin{tabular}[t]{c}%
        \@author
      \end{tabular}\par}%
    \vskip 1em%
    {\large \@date}%
  \end{center}%
  \par
%    \end{macrocode}
%    Put the title into both running heads.
%    \begin{macrocode}
  \uppercase\expandafter{\expandafter\toks@\expandafter{\@title}}%
  \edef\@tempa{\noexpand\markboth{\the\toks@}{\the\toks@}}%
  \@tempa
  \vskip 1.5em}
%</amsdtx>
%    \end{macrocode}
%
%    Edit the sectioning commands.
%    \begin{macrocode}
\renewcommand\section{\@startsection {section}{1}{\z@}%
                                   {-.6\baselineskip \@plus -3\p@}%
                                   {.4\baselineskip}
                                   {\reset@font\normalsize\bfseries}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-.3\baselineskip\@plus -2\p@}%
                                     {.2\baselineskip}%
                                     {\reset@font\normalsize\bfseries}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                     {-.2\baselineskip\@plus -2\p@}%
                                     {.2\baselineskip}%
                                     {\reset@font\normalsize\bfseries}}
%    \end{macrocode}
%    Change index environment to turn off \cn{autoindex}.
%    \begin{macrocode}
\renewenvironment{theindex}{%
  \if@twocolumn \@restonecolfalse \else \@restonecoltrue \fi
  \columnseprule \z@ \columnsep 35\p@
  \let\autoindex\@gobble
%<amsdtx>  \twocolumn[\section*{\indexname}]%
%<amsldoc>  \twocolumn[\@makeschapterhead{\indexname}]%
  \addcontentsline{toc}{chapter}{\indexname}%
  \@mkboth{\uppercase{\indexname}}{\uppercase{\indexname}}%
  \thispagestyle{plain}\parindent\z@
  \parskip\z@ \@plus .3\p@\relax
  \let\item\@idxitem
}{%
  \if@restonecol\onecolumn\else\clearpage\fi
}
%    \end{macrocode}
%
%    Take out \cn{thechapter} from \cn{thesection}.
%    \begin{macrocode}
%<amsdtx>\renewcommand{\thesection}{\arabic{section}}
%    \end{macrocode}
%
%    Change the style of captions slightly. Also incorporate some
%    caption improvements from Donald Arseneau (\fn{comp.text.tex}, 11
%    Oct 1994).
%    \begin{macrocode}
\long\def\@makecaption#1#2{%
  \addvspace\abovecaptionskip
  \begingroup
    \countdef\@parcycles=8 % local count register
    \@parcycles\z@
    \@setpar{\advance\@parcycles\@ne \ifnum\@parcycles>999
      \@@par\@parcycles\z@\fi
      \ifhmode \unskip\hskip\parfillskip\penalty-\@M\fi}%
    \@hangfrom{\textbf{#1.} }\vadjust{\penalty\m@ne}#2%
  \endgroup
  \ifhmode\unpenalty\fi\par
  \ifnum\lastpenalty=\m@ne % only one line in the caption
    \unpenalty \setbox\@tempboxa\lastbox
    \nointerlineskip
    \hbox to\hsize{\hfill\unhbox\@tempboxa\unskip\hfill}%
  \fi
  \nobreak\vskip\belowcaptionskip
}
%    \end{macrocode}
%    For table captions, assume top captions and so put space below the
%    caption rather than above:
%    \begin{macrocode}
\renewenvironment{table}{%
  \belowcaptionskip\abovecaptionskip \abovecaptionskip\z@skip
  \@float{table}%
}{%
  \end@float
}
\renewenvironment{table*}{%
  \belowcaptionskip\abovecaptionskip \abovecaptionskip\z@skip
  \@dblfloat{table}%
}{%
  \end@dblfloat
}
%    \end{macrocode}
%
% \section{Float placement parameters}
%    These control the placing of floating objects like tables and
%    figures. The values here, which are much more tolerant than the
%    \latex/ defaults, are more or less copied from \fn{amsclass.dtx}.
%    \begin{macrocode}
\setcounter{topnumber}{4}\setcounter{bottomnumber}{4}
\setcounter{totalnumber}{4}\setcounter{dbltopnumber}{4}
\renewcommand{\topfraction}{.97}\renewcommand{\bottomfraction}{.97}
\renewcommand{\textfraction}{.03}\renewcommand{\floatpagefraction}{.9}
\renewcommand{\dbltopfraction}{.97}
\renewcommand{\dblfloatpagefraction}{.9}
\setlength{\floatsep}{8pt plus6pt}
\setlength{\textfloatsep}{10pt plus8pt}
\setlength{\intextsep}{8pt plus6pt}
\setlength{\dblfloatsep}{8pt plus6pt}
\setlength{\dbltextfloatsep}{10pt plus8pt}
\setlength{\@fptop}{0pt}\setlength{\@fpsep}{8pt}%
\setlength{\@fpbot}{0pt plus 1fil}
\setlength{\@dblfptop}{0pt}\setlength{\@dblfpsep}{8pt}%
\setlength{\@dblfpbot}{0pt plus 1fil}
%    \end{macrocode}

%    \begin{macrocode}
\pagestyle{headings}
%    \end{macrocode}
%
%    Make \verb"|...|" shorthand for verbatim fragments. In the case of
%    the \cls{amsldoc} class, we avoid requiring an extra package
%    (\pkg{doc} or \pkg{shortvrb}), to reduce the possibility of package
%    files not being found at run time.
%    \begin{macrocode}
%<*amsldoc>
\AtBeginDocument{\catcode`\|=\active }
\def\activevert{\verb|}
\expandafter\gdef\expandafter\dospecials\expandafter
  {\dospecials \do\|}%
\expandafter\gdef\expandafter\@sanitize\expandafter
  {\@sanitize \@makeother\|}
\begingroup\catcode`\|=\active \gdef|{\protect\activevert{}}\endgroup
%</amsldoc>
%    \end{macrocode}
%
%  \begin{macro}{\arrayargpatch}
%    If the column-specs arg of array or tabular contains a vert bar
%    character, and we have made vert bars active, it will cause
%    trouble. The following command, used in the ctab environment,
%    prevents the trouble.
%    \begin{macrocode}
\newcommand{\arrayargpatch}{%
  \let\@oldarray\@array
  \edef\@array[##1]##2{\catcode\number`\|=\number\catcode`\|
    \catcode\number`\@=\number\catcode`\@ \relax
    \let\noexpand\@array\noexpand\@oldarray
    \noexpand\@array[##1]{##2}}%
  \catcode`\|=12 \catcode`\@=12 \relax
}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{environment}{ctab}
%    An environment for centered tables.
%    \begin{macrocode}
\newenvironment{ctab}{%
  \par\topsep\medskipamount
  \trivlist\centering
  \item[]%
  \arrayargpatch
  \begin{tabular}%
}{%
  \end{tabular}%
  \endtrivlist
}
%    \end{macrocode}
%  \end{environment}
%
%    Load \pkg{doc} package, reset \cn{AltMacroFont} to be the same as
%    \cn{MacroFont} (when there are large sections of conditional
%    code I think it looks better not to have it all slanted).
%    \begin{macrocode}
%<*amsdtx>
\RequirePackage{doc}
\def\AltMacroFont{\MacroFont}
%    \end{macrocode}
%
%    Ordinary \cn{DocInput} doesn't handle standardized file headers
%    unless you enclose them in \cs{iffalse} \dots\ \cs{fi} which I
%    don't care to do. So instead here's an alternate version of
%    \cn{DocInput}, called \cn{hDocInput}.
%    \begin{macrocode}
\def\hDocInput#1{\MakePercentIgnore
  \begingroup
%    \end{macrocode}
%    Define active \qc{\@} which should be the first non-percent,
%    non-equal-sign character when a file header is present. (If a file
%    header is not present, \cn{hDocInput} should not be used.)
%    \begin{macrocode}
  \begingroup \lccode`\~=`\@
  \lowercase{\endgroup\long\def ~}##1##{%
    \catcode`\==12 \skipfileheader{##1}}%
  \catcode`\@=\active \catcode`\==14 % comment
  \def\filename{#1}%
  \@@input#1 \MakePercentComment}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\skipfileheader#1#2 {\endgroup
  \hGetFileInfo#2 version = "??" date = "??"\@nil
  \begingroup\catcode`\==9 \catcode`\ =9 \futurelet\0\endgroup
}
%    \end{macrocode}
%
%    \begin{macrocode}
\long\def\hGetFileInfo#1 version = "#2"#3 date = "#4"#5\@nil{%
  \def\fileversion{#2}\def\filedate{#4}}
%</amsdtx>
%    \end{macrocode}
%
%    The usual \cs{endinput} to ensure that random garbage at the end of
%    the file doesn't get copied by \fn{docstrip}.
%    \begin{macrocode}
\endinput
%    \end{macrocode}
%
% \changes{v1.2b}{1995/02/15}{Added {}{} after rightmark, leftmark to
%   handle no-maketitle case}
% \changes{v1.2b}{1995/02/15}{Added frenchspacing in error env heading}
%
% \changes{v1.2c}{1996/10/28}{Update version number, date for new release}
%
% \changes{v1.2d}{1997/03/13}{Fixed up loading method for OT1cmtt fd file}
%
% \CheckSum{1150}
% \Finale
