summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/source/latex/amslatex/ams-c1.ins80
-rw-r--r--Master/texmf-dist/source/latex/amslatex/ams-m1.ins69
-rw-r--r--Master/texmf-dist/source/latex/amslatex/ams-r1.ins43
-rw-r--r--Master/texmf-dist/source/latex/amslatex/amsbsy.dtx251
-rw-r--r--Master/texmf-dist/source/latex/amslatex/amscd.dtx333
-rw-r--r--Master/texmf-dist/source/latex/amslatex/amsclass.dtx5204
-rw-r--r--Master/texmf-dist/source/latex/amslatex/amsdtx.dtx1192
-rw-r--r--Master/texmf-dist/source/latex/amslatex/amsgen.dtx396
-rw-r--r--Master/texmf-dist/source/latex/amslatex/amsmath.dtx5829
-rw-r--r--Master/texmf-dist/source/latex/amslatex/amsmidx.dtx241
-rw-r--r--Master/texmf-dist/source/latex/amslatex/amsopn.dtx254
-rw-r--r--Master/texmf-dist/source/latex/amslatex/amsrefs.dtx8030
-rw-r--r--Master/texmf-dist/source/latex/amslatex/amstext.dtx314
-rw-r--r--Master/texmf-dist/source/latex/amslatex/amsxport.dtx1822
-rw-r--r--Master/texmf-dist/source/latex/amslatex/amsxtra.dtx136
-rw-r--r--Master/texmf-dist/source/latex/amslatex/ifoption.dtx170
-rw-r--r--Master/texmf-dist/source/latex/amslatex/mathscinet.dtx595
-rw-r--r--Master/texmf-dist/source/latex/amslatex/pcatcode.dtx359
-rw-r--r--Master/texmf-dist/source/latex/amslatex/rkeyval.dtx1116
-rw-r--r--Master/texmf-dist/source/latex/amslatex/textcmds.dtx283
-rw-r--r--Master/texmf-dist/source/latex/amslatex/upref.dtx151
21 files changed, 26868 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/amslatex/ams-c1.ins b/Master/texmf-dist/source/latex/amslatex/ams-c1.ins
new file mode 100644
index 00000000000..3145608a278
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/ams-c1.ins
@@ -0,0 +1,80 @@
+%%% ====================================================================
+%%% @LaTeX-file{
+%%% filename = "ams-c1.ins",
+%%% version = "2.20",
+%%% date = "2004/08/03",
+%%% time = "14:18:09 EDT",
+%%% checksum = "43968 80 304 2992",
+%%% author = "American Mathematical Society",
+%%% 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",
+%%% copyright = "Copyright 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@math.ams.org (Internet)",
+%%% codetable = "ISO/ASCII",
+%%% keywords = "latex, amsart, amsbook, amsproc, amsthm, install",
+%%% supported = "yes",
+%%% abstract = "This is an installation file that will generate
+%%% loadable package and class files when run
+%%% through \LaTeX{}.",
+%%% 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.",
+%%% }
+%%% ====================================================================
+\def\batchfile{ams-c1.ins}
+\input docstrip.tex
+\preamble
+\endpreamble
+
+\keepsilent
+
+\csname newtoks\endcsname\filesmsg
+\def\dofile#1#2#3{\generateFile{#1}{f}{\from{#2}{#3}}%
+ \filesmsg\expandafter{\the\filesmsg
+ \Msg{* \space\space#1}}}
+
+% Packages
+\dofile{amsthm.sty}{amsclass.dtx}{amsthm}
+\dofile{upref.sty}{upref.dtx}{}
+\dofile{amsmidx.sty}{amsmidx.dtx}{}
+
+% Document class amsart:
+\dofile{amsart.cls}{amsclass.dtx}{amsart,classes}
+% Document class amsbook:
+\dofile{amsbook.cls}{amsclass.dtx}{amsbook,classes}
+% Document class amsproc:
+\dofile{amsproc.cls}{amsclass.dtx}{amsproc,classes}
+
+% Document class for printing AMS documentation files:
+\dofile{amsdtx.cls}{amsdtx.dtx}{amsdtx}
+
+\ifToplevel{
+\Msg{******************************************************************}
+\Msg{*}
+\Msg{* To get documentation for the amsart, amsbook, and amsproc}
+\Msg{* documentclasses, run LaTeX on instr-l.tex.}
+\Msg{*}
+\Msg{* To get documentation for the amsthm package, run LaTeX on}
+\Msg{* amsthdoc.tex; see also thmtest.tex.}
+\Msg{*}
+\Msg{******************************************************************}
+}
+
+\endinput
+}
diff --git a/Master/texmf-dist/source/latex/amslatex/ams-m1.ins b/Master/texmf-dist/source/latex/amslatex/ams-m1.ins
new file mode 100644
index 00000000000..a03642e51a7
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/ams-m1.ins
@@ -0,0 +1,69 @@
+%%% ====================================================================
+%%% @LaTeX-file{
+%%% filename = "ams-m1.ins",
+%%% version = "1.05",
+%%% date = "2000/05/25",
+%%% time = "16:28:35 EDT",
+%%% checksum = "13352 69 258 2600",
+%%% author = "American Mathematical Society",
+%%% 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",
+%%% email = "tech-support@math.ams.org (Internet)",
+%%% supported = "yes",
+%%% copyright = "Copyright 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.",
+%%% keywords = "latex, amsmath, ams-latex, installation",
+%%% abstract = "This is an installation file that will generate
+%%% loadable package and class files when run
+%%% through \LaTeX{}.",
+%%% 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.",
+%%% }
+%%% ====================================================================
+\def\batchfile{ams-m1.ins}
+\input docstrip.tex
+\preamble
+\endpreamble
+
+\keepsilent
+
+\csname newtoks\endcsname\filesmsg
+\def\dofile#1#2#3{\generateFile{#1}{f}{\from{#2}{#3}}%
+ \filesmsg\expandafter{\the\filesmsg
+ \Msg{* \space\space#1}}}
+
+% Math packages
+\dofile{amsmath.sty}{amsmath.dtx}{}
+\dofile{amsgen.sty}{amsgen.dtx}{}
+\dofile{amstext.sty}{amstext.dtx}{}
+\dofile{amsopn.sty}{amsopn.dtx}{}
+\dofile{amsbsy.sty}{amsbsy.dtx}{}
+\dofile{amscd.sty}{amscd.dtx}{}
+\dofile{amsxtra.sty}{amsxtra.dtx}{}
+
+\ifToplevel{
+\Msg{******************************************************************}
+\Msg{*}
+\Msg{* To produce the User's Guide for amsmath, run amsldoc.tex through}
+\Msg{* LaTeX.}
+\Msg{*}
+\Msg{******************************************************************}
+}
+
+\endinput
diff --git a/Master/texmf-dist/source/latex/amslatex/ams-r1.ins b/Master/texmf-dist/source/latex/amslatex/ams-r1.ins
new file mode 100644
index 00000000000..c4a552ebcba
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/ams-r1.ins
@@ -0,0 +1,43 @@
+%%% ====================================================================
+%%% @LaTeX-file{
+%%% filename = "ams-r1.ins",
+%%% version = "1.04",
+%%% date = "2001/12/24",
+%%% time = "12:50:14 EST",
+%%% author = "Michael J Downes",
+%%% address = "American Mathematical Society,
+%%% Publications Technical Group,
+%%% PO Box 6248,
+%%% Providence, RI 02940,
+%%% USA",
+%%% email = "tech-support@ams.org",
+%%% URL = "http://www.ams.org/",
+%%% abstract = "A docstrip batch file for the amsrefs package",
+%%% checksum = "21160 39 121 1555",
+%%% docstring = "The checksum field, produced by Robert Solovay's
+%%% checksum utility, gives CRC-16 checksum, lines,
+%%% words, and characters.",
+%%% }
+%%% ====================================================================
+\def\batchfile{ams-r1.ins}
+\input docstrip.tex
+\preamble
+\endpreamble
+\keepsilent
+\generateFile{pcatcode.sty}{f}{\from{pcatcode.dtx}{}}
+\generateFile{ifoption.sty}{f}{\from{ifoption.dtx}{}}
+\generateFile{rkeyval.sty}{f}{\from{rkeyval.dtx}{}}
+\generateFile{amsrefs.sty}{f}{\from{amsrefs.dtx}{pkg}}
+\generateFile{textcmds.sty}{f}{\from{textcmds.dtx}{pkg}}
+\generateFile{mathscinet.sty}{f}{\from{mathscinet.dtx}{}}
+%\generateFile{amsjpa.sty}{f}{\from{amsjpa.dtx}{}}
+% Remove \endinput from postamble
+\postamble
+\endpostamble
+\generateFile{amsrn.bst}{f}{\from{amsxport.dtx}{bst,sort,plain}}
+\generateFile{amsru.bst}{f}{\from{amsxport.dtx}{bst,plain}}
+\generateFile{amsra.bst}{f}{\from{amsxport.dtx}{bst,sort,alpha}}
+\generateFile{amsry.bst}{f}{\from{amsxport.dtx}{bst,sort,alpha,y2k}}
+\generateFile{amsrs.bst}{f}{\from{amsxport.dtx}{bst,sort,short}}
+%\generateFile{amsj.bib}{f}{\from{amsxport.dtx}{abbrevs}}
+\endinput
diff --git a/Master/texmf-dist/source/latex/amslatex/amsbsy.dtx b/Master/texmf-dist/source/latex/amslatex/amsbsy.dtx
new file mode 100644
index 00000000000..30c4dee1bbf
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/amsbsy.dtx
@@ -0,0 +1,251 @@
+%%% ====================================================================
+%%% @LaTeX-file{
+%%% filename = "amsbsy.dtx",
+%%% version = "1.2d",
+%%% date = "1999/11/29",
+%%% time = "14:26:42 EST",
+%%% author = "American Mathematical Society",
+%%% copyright = "Copyright 1995 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.",
+%%% 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 = "08988 251 1238 9625",
+%%% email = "tech-support@ams.org (Internet)",
+%%% codetable = "ISO/ASCII",
+%%% keywords = "latex, bold symbol, pmb",
+%%% supported = "yes",
+%%% abstract = "This is a \LaTeX{} package that provides a command
+%%% for producing bold math symbols when appropriate
+%%% fonts exist, and a `poor man's bold' command that
+%%% can be applied when no appropriate bold font
+%%% is available.",
+%%% 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
+%<*driver>
+\documentclass{amsdtx}
+\usepackage{amsbsy}
+\begin{document}
+\title{The \pkg{amsbsy} package}
+\author{Frank Mittelbach\and Rainer Sch\"opf\and Michael Downes}
+\date{Version \fileversion, \filedate}
+\hDocInput{amsbsy.dtx}
+\end{document}
+%</driver>
+%\fi
+%
+% \maketitle
+%
+% \MakeShortVerb\|
+%
+% \section{Introduction}
+%
+% The package \texttt{amsbsy}, first written in 1989, implements a
+% few commands for producing \textbf{bold} characters in the `normal'
+% \emph{math version}.
+% \begin{quote}\em
+% Note: It is recommended nowadays to use the \pkg{bm} package, which
+% became available in 1997.
+% \end{quote}
+%
+% If we have bold fonts which contain the character in question then
+% we will use these fonts to produce the wanted character. But
+% sometimes math fonts are only available in a certain weight
+% (e.g.\ the AMS symbol fonts).
+% \DescribeMacro\pmb
+% For these cases we provide a command which is called \verb+\pmb+ (an
+% acronym for \textbf{p}oor \textbf{m}an's \textbf{b}old) with one argument.
+% The bolder weight is achieved by copying the argument three times in
+% slightly different positions which is better than nothing but no
+% match for a real bold font.
+%
+% \DescribeMacro\boldsymbol
+% There also exists the \verb+\boldsymbol+ command which is better in
+% all cases where bold fonts exists. This command will internally
+% switch to the corresponding `bold' \emph{math version} typeset its
+% argument in this version.
+%
+% Both commands will preserve the nature of their arguments, i.e.\ if
+% they get a relational atom their result will again be a relation as
+% far as \tex/'s mathspacing is concerned.
+%
+% Since it is good policy to make at least a small test we try to
+% typeset the infinity sign ($\infty$) first with \verb+\pmb+ and then
+% with \verb+\boldsymbol+.
+% \[
+% \pmb{\infty} = \boldsymbol{\infty} \quad ?
+% \]
+% \StopEventually{}
+%
+% Standard package info.
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
+[1994/12/01]% LaTeX date must December 1994 or later
+\ProvidesPackage{amsbsy}[1999/11/29 v1.2d]
+% \end{macrocode}
+%
+% \section{The implementation}
+%
+% We need some functions from the \pkg{amsgen} package.
+% \begin{macrocode}
+\RequirePackage{amsgen}
+% \end{macrocode}
+%
+%\begin{macro}{\boldsymbol}
+% In implementing boldsymbol, we must take into account \tex/'s
+% limitation of only 16 mathgroups (math families, in Knuth's
+% terminology). If we wanted to maintain mathgroups for both the bold
+% and non-bold version of each math font, it would not take long to
+% run out of mathgroups. Therefore what we do instead for a bold
+% symbol is embed it in an \verb|\hbox|; inside that \verb|\hbox|,
+% when we start another math formula, we can change all the
+% mathgroups to their bold equivalents.
+%
+% However, to get the correct math style inside the hbox (display,
+% text, script or scriptscript) we have to use \verb|\mathchoice|.
+% Since \verb|\mathversion{bold}| has a lot of overhead, and
+% \verb|\mathchoice| typesets the argument text four times, we would
+% rather not put the \verb|\mathversion| command inside each
+% \verb|\hbox| in the \verb|\mathchoice|; on the other hand,
+% \verb|\mathversion| gives an error message if it's used in math
+% mode. Therefore if we want to execute \verb|\mathversion{bold}|
+% before starting the \verb|\mathchoice| we have to temporarily
+% disable the \verb|\@nomath| error. (The error message is intended
+% to keep people from accidentally emboldening a preceding part of a
+% math formula, since only the mathgroups defined at the end of a
+% math formula will determine the fonts used in that formula; but we
+% are going to typeset our bold symbol not in the current formula but
+% in an embedded formula, so that this danger doesn't apply here.)
+% \begin{macrocode}
+\DeclareRobustCommand{\boldsymbol}[1]{%
+% \end{macrocode}
+% Start a group to localize the change of \verb|\@nomath|:
+% \begin{macrocode}
+ \begingroup
+% \end{macrocode}
+% Disable \verb|\@nomath| so that we don't have to leave math
+% mode before executing \verb|\mathversion|:
+% \begin{macrocode}
+ \let\@nomath\@gobble \mathversion{bold}%
+% \end{macrocode}
+% \cs{math@atom} is a test macro which looks at its argument and
+% produces a math atom of the proper class.
+% \begin{macrocode}
+ \math@atom{#1}{%
+% \end{macrocode}
+% Although it is tempting to use \verb|\text| here, to save some
+% main memory, that caused a bug in the past due to some internal
+% interactions with \verb|\mathversion|.
+% \begin{macrocode}
+ \mathchoice%
+ {\hbox{$\m@th\displaystyle#1$}}%
+ {\hbox{$\m@th\textstyle#1$}}%
+ {\hbox{$\m@th\scriptstyle#1$}}%
+ {\hbox{$\m@th\scriptscriptstyle#1$}}}%
+% \end{macrocode}
+% End the group we started earlier.
+% \begin{macrocode}
+ \endgroup}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\math@atom}
+% The macro \verb+\math@atom+ looks at its argument and produce a
+% correct math atom, i.e.\ a primitive like \verb+\mathopen+.
+% Until the day we have a real implementation for all cases we use
+% the \verb+\binrel@+ command from \amstex/ which can distinguish
+% between binary, relation and ord atoms.
+% \begin{macrocode}
+\def\math@atom#1#2{%
+ \binrel@{#1}\binrel@@{#2}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\pmb}
+% Poor man's bold command, works by typesetting multiple copies of
+% the given argument with small offsets.
+% \begin{macrocode}
+\DeclareRobustCommand{\pmb}{%
+ \ifmmode\else \expandafter\pmb@@\fi\mathpalette\pmb@}
+% \end{macrocode}
+%
+% \cs{pmb@@} is called by \cn{pmb} in the non-math-mode case.
+% Discard the first two arguments which are for the math-mode case.
+% \begin{macrocode}
+\def\pmb@@#1#2#3{\leavevmode\setboxz@h{#3}%
+ \dimen@-\wdz@
+ \kern-.5\ex@\copy\z@
+ \kern\dimen@\kern.25\ex@\raise.4\ex@\copy\z@
+ \kern\dimen@\kern.25\ex@\box\z@
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newdimen\pmbraise@
+% \end{macrocode}
+% Note: because of the use of \cs{mathpalette}, if \cs{pmb@} is applied to a
+% single math italic character (or a single character from some other
+% slanted math font), the italic correction will be added. This will
+% cause subscripts to fall too far away from the character in some
+% cases, e.g., $\pmb{T}_1$ or $\pmb{\mathcal{T}}_1$.
+% \begin{macrocode}
+\def\pmb@#1#2{\setbox8\hbox{$\m@th#1{#2}$}%
+ \setboxz@h{$\m@th#1\mkern.5mu$}\pmbraise@\wdz@
+ \binrel@{#2}%
+ \dimen@-\wd8 %
+ \binrel@@{%
+ \mkern-.8mu\copy8 %
+ \kern\dimen@\mkern.4mu\raise\pmbraise@\copy8 %
+ \kern\dimen@\mkern.4mu\box8 }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\def\binrel@#1{\begingroup
+ \setboxz@h{\thinmuskip0mu
+ \medmuskip\m@ne mu\thickmuskip\@ne mu
+ \setbox\tw@\hbox{$#1\m@th$}\kern-\wd\tw@
+ ${}#1{}\m@th$}%
+% \end{macrocode}
+% The \cn{noexpand} here should be unnecessary, but just in case
+% \ldots
+% \begin{macrocode}
+ \edef\@tempa{\endgroup\let\noexpand\binrel@@
+ \ifdim\wdz@<\z@ \mathbin
+ \else\ifdim\wdz@>\z@ \mathrel
+ \else \relax\fi\fi}%
+ \@tempa
+}
+% \end{macrocode}
+% For completeness, assign a default value for \cs{binrel@@}.
+% \begin{macrocode}
+\let\binrel@@\relax
+% \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}
+%
+% \CheckSum{131}
+% \Finale
diff --git a/Master/texmf-dist/source/latex/amslatex/amscd.dtx b/Master/texmf-dist/source/latex/amslatex/amscd.dtx
new file mode 100644
index 00000000000..7dd765109d1
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/amscd.dtx
@@ -0,0 +1,333 @@
+%%% ====================================================================
+%%% @LaTeX-file{
+%%% filename = "amscd.dtx",
+%%% version = "2.0",
+%%% date = "1999/11/29",
+%%% time = "14:30:07 EST",
+%%% author = "American Mathematical Society",
+%%% copyright = "Copyright 1995, 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.",
+%%% 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 = "07428 333 1152 12117",
+%%% email = "tech-support@ams.org (Internet)",
+%%% codetable = "ISO/ASCII",
+%%% keywords = "latex, commutative diagram",
+%%% supported = "yes",
+%%% abstract = "This is a \LaTeX{} package that adapts the
+%%% commutative diagram macros of AMS-\TeX{} for
+%%% use in \LaTeX{}",
+%%% 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
+%<*driver>
+\documentclass{amsdtx}
+\usepackage{amscd}
+% Dummy citation to avoid error in an example.
+\bibcite{fre:cichon}{C}
+\begin{document}
+\title{The \pkg{amscd} package}
+\author{Frank Mittelbach\and Rainer Sch\"opf\and Michael Downes}
+\date{Version \fileversion, \filedate}
+\hDocInput{amscd.dtx}
+\end{document}
+%</driver>
+%\fi
+%
+% \maketitle
+%
+% \MakeShortVerb\|
+% \newcommand{\operatorname}[1]{\mathop{\mathrm{#1}}}
+% \newcommand{\per}{\operatorname{per}}
+% \newcommand{\cov}{\operatorname{cov}}
+% \newcommand{\non}{\operatorname{non}}
+% \newcommand{\cf}{\operatorname{cf}}
+% \newcommand{\add}{\operatorname{add}}
+% \newcommand{\End}{\operatorname{End}}
+%
+% \section{Introduction}
+%
+% The \pkg{amscd} package provides a \env{CD} environment that
+% emulates the commutative diagram capabilities of \amstex/ version
+% 2.x. This means that only simple rectangular diagrams are
+% supported, with no diagonal arrows or more exotic features. Many
+% users will be better served by one of the more powerful diagram
+% packages such as \pkg{diagram}, \pkg{xypic}, or \pkg{kuvio}.
+%
+% Example:
+% \begin{equation}\begin{CD}
+% S^{{\mathcal{W}}_\Lambda}\otimes T @>j>> T\\
+% @VVV @VV{\End P}V\\
+% (S\otimes T)/I @= (Z\otimes T)/J
+% \end{CD}\end{equation}
+% \begin{verbatim}
+% \begin{equation}\begin{CD}
+% S^{{\mathcal{W}}_\Lambda}\otimes T @>j>> T\\
+% @VVV @VV{\End P}V\\
+% (S\otimes T)/I @= (Z\otimes T)/J
+% \end{CD}\end{equation}
+% \end{verbatim}
+% (assuming \cn{End} is defined as an `operator name'.
+%
+% Another example:
+%
+% We will make liberal use of Cichon's Diagram \cite{fre:cichon}:
+% \begin{equation}
+% \begin{CD}
+% \cov(\mathcal{L}) @>>> \non(\mathcal{K}) @>>> \cf(\mathcal{K}) @>>>
+% \cf(\mathcal{L})\\
+% @VVV @AAA @AAA @VVV\\
+% \add(\mathcal{L}) @>>> \add(\mathcal{K}) @>>> \cov(\mathcal{K}) @>>>
+% \non(\mathcal{L})
+% \end{CD}\end{equation}
+% \begin{verbatim}
+% \begin{equation}\begin{CD}
+% \cov(\mathcal{L}) @>>> \non(\mathcal{K}) @>>> \cf(\mathcal{K}) @>>>
+% \cf(\mathcal{L})\\
+% @VVV @AAA @AAA @VVV\\
+% \add(\mathcal{L}) @>>> \add(\mathcal{K}) @>>> \cov(\mathcal{K}) @>>>
+% \non(\mathcal{L})
+% \end{CD}\end{equation}
+% \end{verbatim}
+%
+% \StopEventually{}
+%
+% Standard package info.
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
+[1994/12/01]% LaTeX date must December 1994 or later
+\ProvidesPackage{amscd}[1999/11/29 v2.0]
+% \end{macrocode}
+% \begin{macrocode}
+\RequirePackage{amsgen}
+% \end{macrocode}
+% Better not to redefine \verb|\math@cr| if it is already defined,
+% because for CD use only we want to omit the part of the code
+% related to \verb|\dspbrk@lvl| (see \fn{amsmath.sty}).
+%
+% [mjd,1999/11/04] These definitions have gone somewhat obsolete; but
+% we had probably better leave them as they are for backward
+% compatibility.
+% \begin{macrocode}
+\@ifundefined{math@cr}{%
+ \def\math@cr{{\ifnum0=`}\fi
+ \@ifstar{\global\@eqpen\@M\math@cr@}%
+ {\global\@eqpen\interdisplaylinepenalty \math@cr@}}
+% \end{macrocode}
+% The following section merely duplicates some code from the
+% \pkg{amsmath} package, in case the \pkg{amscd} package is used by
+% itself. For documentation of the code refer to \fn{amsmath.dtx}.
+% \begin{macrocode}
+ \def\math@cr@{\new@ifnextchar[\math@cr@@{\math@cr@@[\z@]}}
+ \def\math@cr@@[#1]{\ifnum0=`{\fi}\math@cr@@@
+ \noalign{\vskip#1\relax}}
+ \def\restore@math@cr{\def\math@cr@@@{\cr}}
+}{}
+\restore@math@cr
+% \end{macrocode}
+% [mjd,1999/11/04] These definitions too are somewhat obsolete;
+% but we had probably better leave them as they are for backward
+% compatibility.
+% \begin{macrocode}
+\@ifundefined{rightarrowfill@}{
+ \def\rightarrowfill@#1{\m@th\setboxz@h{$#1-$}\ht\z@\z@
+ $#1\copy\z@\mkern-6mu\cleaders
+ \hbox{$#1\mkern-2mu\box\z@\mkern-2mu$}\hfill
+ \mkern-6mu\mathord\rightarrow$}
+ \def\leftarrowfill@#1{\m@th\setboxz@h{$#1-$}\ht\z@\z@
+ $#1\mathord\leftarrow\mkern-6mu\cleaders
+ \hbox{$#1\mkern-2mu\copy\z@\mkern-2mu$}\hfill
+ \mkern-6mu\box\z@$}
+ \def\leftrightarrowfill@#1{\m@th\setboxz@h{$#1-$}\ht\z@\z@
+ $#1\mathord\leftarrow\mkern-6mu\cleaders
+ \hbox{$#1\mkern-2mu\box\z@\mkern-2mu$}\hfill
+ \mkern-6mu\mathord\rightarrow$}
+}{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\atdef@#1{\expandafter\def\csname\space @\string#1\endcsname}
+\@ifundefined{Iat}{%
+ \DeclareRobustCommand{\Iat}{\FN@\at@}
+}{}
+\begingroup \catcode`\@=\active
+% \end{macrocode}
+% Define math \qc{\@} to replicate its mathcode-dictated behavior.
+% This is in case \qc{\@} occurs outside of \env{CD}.
+% \begin{macrocode}
+\csname if\string @compatibility\endcsname
+\else \fam=\mathcode`\@
+ \xdef @{\mathchar\number\fam\space }
+\fi
+\gdef\CDat{\let @=\Iat}
+\endgroup
+\mathcode`\@="8000 % make @ pseudo-active in math
+\def\at@{\let\next@\at@@
+ \ifcat\noexpand\next a\else
+ \ifcat\noexpand\next0\else
+ \ifcat\noexpand\next\relax\else
+ \let\next@\at@@@\fi\fi\fi\next@}
+\def\at@@#1{\expandafter
+ \ifx\csname\space @\string#1\endcsname\relax
+ \DN@{\at@@@#1}%
+ \else
+ \DN@{\csname\space @\string#1\endcsname}%
+ \fi\next@}%
+% \end{macrocode}
+% The following items should be defined only if they are not
+% already defined, either to leave the package name untouched (in
+% the case of \cs{PackageError}) or to avoid redundant allocation
+% of token or dimen registers.
+% \begin{macrocode}
+\@ifundefined{default@tag}{%
+ \def\default@tag{%
+ \def\tag{\PackageError{amscd}{\protect\tag\space not allowed
+ here}\@eha}}%
+}{}%
+\@ifundefined{at@@@}{%
+ \def\at@@@{\PackageError{amscd}{\Invalid@@ @}{\the\athelp@}\char64\relax}
+}{}
+\@ifundefined{athelp@}{\csname newhelp\endcsname\athelp@
+{Only certain combinations beginning with @ make sense to me.^^J%
+I'll assume you wanted @@ for a printed @.}}{}
+\@ifundefined{minaw@}{\newdimen\minaw@}{}
+\@ifundefined{bigaw@}{\newdimen\bigaw@}{}
+% \end{macrocode}
+%
+% Assignment of a couple of dimensions, and initialization of
+% \verb=\ampersand@=. We check to see if we need to define
+% \verb=\minaw@= and \verb=\bigaw@=.
+% \begin{macrocode}
+\minaw@11.111pt
+\newdimen\minCDarrowwidth
+\minCDarrowwidth2.5pc
+\newif\ifCD@
+\let\ampersand@\relax
+% \end{macrocode}
+%
+% Added \verb|\restore@math@cr\default@tag| to fix line numbering
+% problems, 7-JUN-1991. Suggested by I.~Zakharevich.
+% \begin{macrocode}
+\newenvironment{CD}{%
+ \CDat
+ \bgroup\relax\iffalse{\fi\let\ampersand@&\iffalse}\fi
+ \CD@true\vcenter\bgroup\let\\\math@cr\restore@math@cr\default@tag
+ \tabskip\z@skip\baselineskip20\ex@
+ \lineskip3\ex@\lineskiplimit3\ex@\halign\bgroup
+ &\hfill$\m@th##$\hfill\crcr
+}{%
+ \crcr\egroup\egroup\egroup
+}
+% \end{macrocode}
+%
+% \begin{macro}{\CD@check}
+% This check is used by all macros that must not appear outside the
+% \env{CD} environment. The first argument is the symbol to be used
+% after \verb+@+, the second one the action to be performed.
+%
+% Once again we use the trick of defining a temporary control
+% sequence \verb+\next@+ and calling it after the final \verb+\fi+.
+% This is not absolutely necessary, but it ensures that the
+% conditional text is processed in one and the same column
+% of the enclosing alignment.
+% \begin{macrocode}
+\def\CD@check#1#2{\ifCD@\DN@{#2}\else
+ \DN@{\PackageError{amscd}{@\protect#1 not
+ allowed outside of the CD environment}\@eha}%
+ \fi\next@}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\atdef@>#1>#2>{\ampersand@
+ \ifCD@ \global\bigaw@\minCDarrowwidth \else \global\bigaw@\minaw@ \fi
+ \setboxz@h{$\m@th\scriptstyle\;{#1}\;\;$}%
+ \ifdim\wdz@>\bigaw@\global\bigaw@\wdz@\fi
+% \end{macrocode}
+% If \verb|#2| is empty we can save some work.
+% \begin{macrocode}
+ \@ifnotempty{#2}{\setbox\@ne\hbox{$\m@th\scriptstyle\;{#2}\;\;$}%
+ \ifdim\wd\@ne>\bigaw@\global\bigaw@\wd\@ne\fi}%
+ \ifCD@\enskip\fi
+ \mathrel{\mathop{\hbox to\bigaw@{\rightarrowfill@\displaystyle}}%
+ \limits^{#1}\@ifnotempty{#2}{_{#2}}}%
+ \ifCD@\enskip\fi \ampersand@}
+%
+\atdef@<#1<#2<{\ampersand@
+ \ifCD@ \global\bigaw@\minCDarrowwidth \else \global\bigaw@\minaw@ \fi
+ \setboxz@h{$\m@th\scriptstyle\;\;{#1}\;$}%
+ \ifdim\wdz@>\bigaw@ \global\bigaw@\wdz@ \fi
+ \@ifnotempty{#2}{\setbox\@ne\hbox{$\m@th\scriptstyle\;\;{#2}\;$}%
+ \ifdim\wd\@ne>\bigaw@ \global\bigaw@\wd\@ne \fi}%
+ \ifCD@\enskip\fi
+ \mathrel{\mathop{\hbox to\bigaw@{\leftarrowfill@\displaystyle}}%
+ \limits^{#1}\@ifnotempty{#2}{_{#2}}}%
+ \ifCD@\enskip\fi \ampersand@}
+% \end{macrocode}
+%
+% Variants of the above two arrows, using \verb|(| and \verb|)|
+% characters instead of \verb|<| and \verb|>| characters, are
+% provided for those whose keyboards don't have the latter.
+% \begin{macrocode}
+\begingroup \catcode`\~=\active \lccode`\~=`\@
+\lowercase{%
+ \global\atdef@)#1)#2){~>#1>#2>}
+ \global\atdef@(#1(#2({~<#1<#2<}
+}% end lowercase
+\endgroup
+% \end{macrocode}
+%
+% \begin{macrocode}
+\atdef@ A#1A#2A{\CD@check{A..A..A}{\llap{$\m@th\vcenter{\hbox
+ {$\scriptstyle#1$}}$}\Big\uparrow
+ \rlap{$\m@th\vcenter{\hbox{$\scriptstyle#2$}}$}&&}}
+%
+\atdef@ V#1V#2V{\CD@check{V..V..V}{\llap{$\m@th\vcenter{\hbox
+ {$\scriptstyle#1$}}$}\Big\downarrow
+ \rlap{$\m@th\vcenter{\hbox{$\scriptstyle#2$}}$}&&}}
+%
+\atdef@={\CD@check={&\enskip\mathrel
+ {\vbox{\hrule\@width\minCDarrowwidth\vskip2\ex@\hrule\@width
+ \minCDarrowwidth}}\enskip&}}
+%
+\atdef@|{\CD@check|{\Big\Vert&&}}
+%
+\atdef@\vert{\CD@check\vert{\Big\Vert&&}}
+%
+\atdef@.{\CD@check.{&&}}
+% \end{macrocode}
+%
+% The \cn{pretend} command has weird syntax that doesn't fit well
+% with standard \latex/ syntax so we leave it undone, at least for
+% now. [mjd,1994/10/27]
+% \begin{macrocode}
+%\def\pretend#1\haswidth#2{\setboxz@h{$\m@th\scriptstyle{#2}$}\hbox
+% to\wdz@{\hfill$\m@th\scriptstyle{#1}$\hfill}}
+% \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}
+%
+% \CheckSum{459}
+% \Finale
diff --git a/Master/texmf-dist/source/latex/amslatex/amsclass.dtx b/Master/texmf-dist/source/latex/amslatex/amsclass.dtx
new file mode 100644
index 00000000000..956b379d23a
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/amsclass.dtx
@@ -0,0 +1,5204 @@
+%%% ====================================================================
+%%% @LaTeX-file{
+%%% filename = "amsclass.dtx",
+%%% version = "2.20",
+%%% date = "2004/08/06",
+%%% time = "13:03:53 EDT",
+%%% checksum = "53558 5204 20497 185872",
+%%% author = "American Mathematical Society",
+%%% copyright = "Copyright 1995, 1999, 2004
+%%% 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.",
+%%% address = "American Mathematical Society,
+%%% Technical Support,
+%%% Publications Technical Group,
+%%% 201 Charles Street,
+%%% Providence, RI 02904,
+%%% USA",
+%%% telephone = "401-455-4080 or (in the USA and Canada)
+%%% 800-321-4AMS (321-4267)",
+%%% FAX = "401-331-3842",
+%%% email = "tech-support@ams.org (Internet)",
+%%% codetable = "ISO/ASCII",
+%%% keywords = "latex, AMS, documentclass, theorem",
+%%% supported = "yes",
+%%% abstract = "This is the source for the amsthm package and three
+%%% AMS document classes: amsart, amsproc, and amsbook.
+%%% They are designed for use with LaTeX.",
+%%% 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
+%<*driver>
+\documentclass{amsdtx}
+
+\CodelineIndex
+
+\begin{document}
+\title{%
+ The \cls{amsart}, \cls{amsproc}, and \cls{amsbook} document~classes}
+\author{American Mathematical Society\\Michael Downes\\
+ updated by Barbara Beeton}
+\date{Version \fileversion, \filedate}
+\hDocInput{amsclass.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \maketitle
+%
+% \MakeShortVerb\|
+%
+% \section{Introduction}
+% This file (\fn{amsclass.dtx}) is the master file for three \latex/
+% document classes, \cls{amsart}, \cls{amsproc}, and \cls{amsbook},
+% which are intended for articles and books containing mathematical
+% research. They produce output that follows the style conventions of
+% American Mathematical Society publications. The theorem setup
+% features of these document classes are also available in a separate
+% package, \pkg{amsthm}.
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+%
+% Three document class files and one package file (\fn{amsthm.sty})
+% are produced from this source. Most of the code of the \fn{amsthm}
+% package is used in all four derived files. Most of the remaining
+% code is used in all three document class files. Fine tuning is done
+% with additional docstrip guards.
+%
+% The usual name, date, and version information. (Note: the reason
+% each \cs{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)
+[1995/06/01]% LaTeX date must be June 1995 or later
+%<*amsart>
+\ProvidesClass{amsart}[2004/08/06 v2.20]
+%</amsart>
+%<*amsproc>
+\ProvidesClass{amsproc}[2004/08/06 v2.20]
+%</amsproc>
+%<*amsbook>
+\ProvidesClass{amsbook}[2004/08/06 v2.20]
+%</amsbook>
+% \end{macrocode}
+% For \pkg{amsthm} we need to guard against redundant loading via
+%\begin{verbatim}
+% \documentclass{amsart}
+% \usepackage{amsthm}
+%\end{verbatim}
+% because in that case the usual \cs{RequirePackage} mechanism for
+% avoiding redundant loading will not apply. We need to simulate the
+% loading of the \pkg{amsthm} package.
+% \begin{macrocode}
+%<*classes>
+\global\expandafter\let\csname ver@amsthm.sty\expandafter\endcsname
+ \csname ver@\@currname.\@currext\endcsname
+%</classes>
+%<*amsthm>
+\ProvidesPackage{amsthm}[2004/08/06 v2.20]
+%</amsthm>
+% \end{macrocode}
+%
+% The following code is shared by the classes and the \pkg{amsthm}
+% package. Cf.~\fn{amsgen.sty}.
+% \begin{macrocode}
+\let\@xp=\expandafter
+\let\@nx=\noexpand
+\def\@oparg#1[#2]{\@ifnextchar[{#1}{#1[#2]}}
+\long\def\@ifempty#1{\@xifempty#1@@..\@nil}
+\long\def\@xifempty#1#2@#3#4#5\@nil{%
+ \ifx#3#4\@xp\@firstoftwo\else\@xp\@secondoftwo\fi}
+\long\def\@ifnotempty#1{\@ifempty{#1}{}}
+\def\setboxz@h{\setbox\z@\hbox}
+\def\@addpunct#1{%
+ \relax\ifhmode
+ \ifnum\spacefactor>\@m \else#1\fi
+ \fi}
+% \end{macrocode}
+% \cn{nopunct} should have a value for \cn{spacefactor} that is
+% not used for \cn{frenchspacing}.
+% \begin{macrocode}
+\def\nopunct{\spacefactor 1007 }
+\def\frenchspacing{\sfcode`\.1006\sfcode`\?1005\sfcode`\!1004%
+ \sfcode`\:1003\sfcode`\;1002\sfcode`\,1001 }
+% \end{macrocode}
+%
+% If this class is loaded by a parent document class, then we want
+% to use the name of the parent class. Otherwise the name of the
+% current class file.
+% \begin{macrocode}
+%<*classes>
+\def\@tempa#1#2\@nil{\edef\@classname{#1}}
+\expandafter\@tempa\@currnamestack{}{}{}\@nil
+\ifx\@classname\@empty \edef\@classname{\@currname}\fi
+% \end{macrocode}
+%
+% \subsection{Support for conditional text}
+%
+% [This needs to be documented in the users' guide, including the
+% idea of using \verb'\for{5ed}{\linebreak}' to mark edition-specific
+% line and page breaks. [mjd,1999/12/27]]
+%
+% We would sometimes like to be able to mark fragments of text to be
+% conditionally discarded or typeset. For example in the title of a
+% section if we want to add a linebreak but prevent this linebreak
+% from also taking effect in the table of contents.
+%
+% Certain kinds of switches need to be built into the low-level
+% structure of our document class in order to be useful. For example,
+% inside the toc we need to arrange for an \qq{in-toc?} test to yield
+% true.
+%
+% \begin{macrocode}
+\def\@True{00}
+\def\@False{01}
+\newcommand\newswitch[2][False]{%
+ \expandafter\@ifdefinable\csname ?@#2\endcsname{%
+ \global\expandafter\let\csname ?@#2\expandafter\endcsname
+ \csname @#1\endcsname
+ }%
+}
+\newcommand{\setFalse}[1]{%
+ \expandafter\let\csname ?@#1\endcsname\@False
+}
+\newcommand{\setTrue}[1]{%
+ \expandafter\let\csname ?@#1\endcsname\@True
+}
+% \end{macrocode}
+% The empty switch is by default false; i.e., if you write
+%\begin{verbatim}
+% \for{}{...}
+%\end{verbatim}
+% the material will be discarded.
+% \begin{macrocode}
+\newswitch{}
+% \end{macrocode}
+%
+% To get a line break in a section title but not in the table of
+% contents line for that section, use
+% \verb'\except{toc}{\linebreak}'. (Presumably you are already giving
+% a shortened running head version separately, if applicable.)
+% \begin{macrocode}
+\DeclareRobustCommand{\except}[1]{%
+ \if\csname ?@#1\endcsname \expandafter\@gobble
+ \else \expandafter\@firstofone
+ \fi
+}
+\DeclareRobustCommand{\for}[1]{%
+ \if\csname ?@#1\endcsname \expandafter\@firstofone
+ \else \expandafter\@gobble
+ \fi
+}
+% \end{macrocode}
+%
+% The \cn{forany} command needs to run through a comma-separated list
+% of switch names and print its second argument if any of the
+% switches are true.
+% \begin{macrocode}
+\DeclareRobustCommand{\forany}[1]{%
+ \csname for@any@01\endcsname#1,?,\@nil
+}
+\@namedef{for@any@\@False}#1,{%
+ \csname for@any@%
+ \csname ?@\zap@space#1 \@empty\endcsname
+ \endcsname
+}
+\@namedef{?@?}{x}
+\@namedef{for@any@\@True}#1\@nil#2{#2}
+\def\for@any@x{\@car\@gobble}
+% \end{macrocode}
+%
+% \subsection{Options}
+% \subsubsection{Notes}
+% Options will be processed in the order they are declared;
+% cf.~\cs{ProcessOptions}.
+%
+% \subsubsection{Paper size}
+%
+% The option \opt{letterpaper} (default) sets the target paper width
+% and height to U.S. letter size, 8.5 in x 11 in. An option
+% \opt{a4paper} is also supported, but we don't include some of the
+% more unusual paper options (\opt{legalpaper}, \opt{a5paper},
+% \opt{executivepaper}) of the generic \cls{article} class. For A4
+% paper we not only change the paper size but also add 4pc to the
+% normal textheight of 50.5pc (the difference between 297mm and 11in
+% is 50pt).
+% \begin{macrocode}
+\DeclareOption{a4paper}{\paperheight 297mm\paperwidth 210mm
+ \textheight 54.5pc }
+\DeclareOption{letterpaper}{\paperheight 11in\paperwidth 8.5in }
+% \end{macrocode}
+%
+% The options \opt{landscape} and \opt{portrait} swap paper height
+% and width.
+% \begin{macrocode}
+\DeclareOption{landscape}{\@tempdima\paperheight
+ \paperheight\paperwidth \paperwidth\@tempdima}
+\DeclareOption{portrait}{}
+% \end{macrocode}
+%
+% \subsubsection{Two-sided or one-sided printing}
+%
+% For two-sided printing we set the switch \cs{if@twoside} which
+% will cause the margins to be adjusted so that the type blocks of
+% back-to-back pages will line up. The \cs{if@mparswitch} makes margin
+% paragraphs print in the outside margin.
+% \begin{macrocode}
+\DeclareOption{oneside}{\@twosidefalse \@mparswitchfalse}
+\DeclareOption{twoside}{\@twosidetrue \@mparswitchtrue}
+% \end{macrocode}
+%
+% \subsubsection{Draft or final version}
+%
+% The \opt{draft} option causes overfull lines to be marked with
+% a black slug in the right margin.
+% \begin{macrocode}
+\DeclareOption{draft}{\overfullrule5\p@
+ \ClassWarningNoLine{\@classname}{%
+ When the draft option is used, the
+ \protect\includegraphics\MessageBreak
+ command will print blank placeholder boxes\MessageBreak
+ for the graphics}%
+}
+\DeclareOption{final}{\overfullrule\z@ }
+% \end{macrocode}
+%
+% \subsubsection{Posting date}
+%
+% The date when an article is officially posted to the WWW is recorded
+% in a variable \cs{@dateposted} with the \cn{dateposted} command.
+%
+% \begin{macrocode}
+\def\dateposted#1{\def\@dateposted{#1}}%
+\let\@dateposted\@empty
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*amsart>
+\def\@setdateposted{%
+ \newline Article electronically published on \@dateposted}
+%</amsart>
+% \end{macrocode}
+%
+% \subsubsection{Logos}
+%
+% The following logo is used for regular journal articles. The one
+% for proceedings articles and the one for e-only journals are given
+% separately.
+% \begin{macrocode}
+%<*amsart>
+\def\article@logo{%
+ \set@logo{%
+ \publname
+% \end{macrocode}
+% Current volume might be empty when an article is first posted to
+% the WWW. In that case leave out the issue-specific info.
+% \begin{macrocode}
+ \ifx\@empty\currentvolume
+ \else \newline\volinfo, \pageinfo
+ \fi
+ \newline \@PII
+ \ifx\@empty\@dateposted \else \@setdateposted\fi
+ }%
+}
+\def\eonly@logo{%
+ \set@logo{%
+ \publname
+ \newline\volinfo, \pageinfo
+ \ifx\@empty\@dateposted \else \@setdateposted\fi
+ \newline \@PII
+ }%
+}
+%</amsart>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\@logofont{\fontsize{6}{7\p@}\selectfont}
+\long\def\set@logo#1{%
+ \vbox to\headheight{%
+ \@parboxrestore \@logofont
+ \noindent#1\par\vss
+ }%
+}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*amsproc>
+\def\procart@logo{%
+ \set@logo{\publname
+ \ifx\@empty\volinfo \else\newline\volinfo\fi}%
+}
+%</amsproc>
+% \end{macrocode}
+%
+% \subsubsection{E-only journal}
+%
+% Electronic-only journals (for \cls{amsart} only) have different
+% information in the series logo than paper-only or dual journals.
+% Only the volume number is reported (no issue or year), and the
+% posting date is added following the page numbers. [bnb, 1996/10/31]
+%
+% This option will be invoked only from publication-specific \fn{.cls}
+% files.
+% \begin{macrocode}
+%<*amsart>
+\DeclareOption{e-only}{%
+ \def\volinfo{Volume \currentvolume}%
+ \dateposted{Xxxx XX, XXXX}%
+ \def\@setdateposted{\ (\@dateposted)}%
+ \let\article@logo\eonly@logo
+}
+%</amsart>
+% \end{macrocode}
+%
+% \subsubsection{Title page}
+%
+% The title and related information can optionally be printed on a
+% separate page.
+% \begin{macrocode}
+\newif\if@titlepage
+\DeclareOption{titlepage}{\@titlepagetrue}
+\DeclareOption{notitlepage}{\@titlepagefalse}
+% \end{macrocode}
+%
+% \subsubsection{Start on right- or left-hand page}
+%
+% For some book series, it's permissible to start chapters on a
+% left-hand page. Default to `openright', the usual AMS book style.
+% \begin{macrocode}
+%<*amsbook>
+\newif\if@openright
+\DeclareOption{openright}{\@openrighttrue}
+\DeclareOption{openany}{\@openrightfalse}
+\@openrighttrue
+%</amsbook>
+% \end{macrocode}
+%
+% \subsubsection{Two-column printing}
+%
+% Two-column layout is handled through a predefined internal switch.
+% \begin{macrocode}
+\DeclareOption{onecolumn}{\@twocolumnfalse}
+\DeclareOption{twocolumn}{\@twocolumntrue}
+% \end{macrocode}
+%
+% \subsubsection{The nomath option}
+%
+% The \opt{nomath} option causes most of the extra math features to
+% be omitted. Some utility functions will be defined below if this
+% option is specified.
+% \begin{macrocode}
+\DeclareOption{nomath}{}
+% \end{macrocode}
+%
+% \subsubsection{Some font options}
+%
+% The \opt{noamsfonts} option means to avoid declaring math alphabets
+% or symbol fonts for the extra math fonts in the AMSFonts set. If
+% these fonts are declared, it means that the corresponding \fn{.tfm}
+% files are required even for documents that do not use any symbols
+% from those fonts. So we allow optionally to not declare them, for
+% convenience of users who don't have those fonts on their system and
+% don't want the hassle of getting them.
+% \begin{macrocode}
+\DeclareOption{noamsfonts}{}
+% \end{macrocode}
+% The \opt{psamsfonts} option, passed on to the \pkg{amsfonts} package,
+% means that alternative \fn{.fd} files should be used that do not
+% refer to \fn{.tfm} files for sizes 6,8,9 (which are not present in
+% the PostScript (Type 1) AMS fonts set from Y\&Y/Blue Sky Research).
+% This should also trigger the \opt{cmex10} option of \pkg{amsmath},
+% to avoid trying to load sizes 7--9 of \fn{cmex}.
+% \begin{macrocode}
+\DeclareOption{psamsfonts}{%
+ \PassOptionsToPackage{psamsfonts}{amsfonts}%
+ \PassOptionsToPackage{cmex10}{amsmath}}
+% \end{macrocode}
+%
+% \subsubsection{Equation numbering on the left or right}
+%
+% The option \opt{leqno}---equation numbers on the left---is the
+% default in AMS styles. Therefore we provide also a \opt{reqno}
+% option.
+% \begin{macrocode}
+\newif\iftagsleft@
+\DeclareOption{leqno}{%
+ \tagsleft@true \PassOptionsToPackage{leqno}{amsmath}}
+\DeclareOption{reqno}{%
+ \tagsleft@false \PassOptionsToPackage{reqno}{amsmath}}
+% \end{macrocode}
+%
+% \subsubsection{Vertical centering of equation numbers}
+% For multiline equations the equation number is by default centered
+% vertically on the total height of the equation. To make the
+% equation number print on the first line (for left-hand
+% numbers) or the last line (right-hand numbers), there is a
+% \opt{tbtags} option `top/bottom tags'.
+% \begin{macrocode}
+\newif\ifctagsplit@
+\DeclareOption{centertags}{%
+ \ctagsplit@true \PassOptionsToPackage{centertags}{amsmath}}
+\DeclareOption{tbtags}{%
+ \ctagsplit@false \PassOptionsToPackage{tbtags}{amsmath}}
+% \end{macrocode}
+%
+% \subsubsection{Flush left displays}
+%
+% The option \opt{fleqn} causes displayed equations to print
+% aligned on the left instead of centered, with an indentation
+% of \cs{mathindent} from the prevailing left margin. If the
+% \pkg{amsmath} package is loaded, most of this code will be
+% overridden, but it seems we need it anyway because of the
+% possibility of the \opt{nomath} class option.
+%
+% \begin{macrocode}
+\DeclareOption{fleqn}{}%
+% \end{macrocode}
+%
+% \subsubsection{Dealing with font sizes}
+%
+% \begin{macro}{\@mainsize}
+% \begin{macro}{\@ptsize}
+% Instead of the miserly \cs{@ptsize} variable from \latex/'s
+% ancient history that contains only the last digit of the main
+% typesize, we set up a proper variable \cs{@mainsize} that
+% contains all the digits of the main typesize. Just in case it is
+% needed for someone using an old package, we will keep
+% \cs{@ptsize} also.
+% \begin{macrocode}
+\newcommand{\@mainsize}{10}
+\newcommand{\@ptsize}{0}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\larger}
+% \begin{macro}{\smaller}
+% This function is an easy byproduct of the work done to fold
+% typesize-specific code into the main class file. The range of font
+% sizes is \cn{normalsize}, \cn{small}, \cn{Small}, \cn{SMALL},
+% \cn{tiny}, \cn{Tiny}, \cn{large}, \cn{Large}, \cn{LARGE},
+% \cn{huge}, \cn{Huge}. Spaces are left at either end of the case
+% statement to accommodate adding \cn{TINY} and \cn{HUGE} in the
+% future but it's not clear that they're really needed.
+% \begin{macrocode}
+\newcommand{\larger}[1][1]{%
+ \count@\@currsizeindex \advance\count@#1\relax
+ \ifnum\count@<\z@ \count@\z@ \else\ifnum\count@>12 \count@12 \fi\fi
+% \end{macrocode}
+% The various size-changing commands \cn{normalsize}, etc., will take
+% care of updating \cs{@currsizeindex}.
+% \begin{macrocode}
+ \ifcase\count@
+ \Tiny\or\Tiny\or\tiny\or\SMALL\or\Small\or\small
+ \or\normalsize
+ \or\large\or\Large\or\LARGE\or\huge\or\Huge\else\Huge
+ \fi
+}
+\newcommand{\smaller}[1][1]{\larger[-#1]}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% The \cs{@adjustvertspacing} function adapts some vertical spacing
+% amounts to the current type size. We don't expect large sections of
+% vertical text to occur in the extraordinarily small or large type
+% sizes, so the \cs{@adjustvertspacing} function is only called in
+% the range between `footnote' size and `Large' size. Notice that no
+% shrinkability is used.
+% \begin{macrocode}
+\def\@adjustvertspacing{%
+% \end{macrocode}
+% \cs{big/med/smallskipamount} are generic space values that will be
+% used by the commands \cn{bigskip}, \cn{medskip}, \cn{smallskip}. We
+% also link the spacing around displayed equations to these amounts.
+% \begin{macrocode}
+ \bigskipamount.7\baselineskip plus.7\baselineskip
+ \medskipamount\bigskipamount \divide\medskipamount\tw@
+ \smallskipamount\medskipamount \divide\smallskipamount\tw@
+ \abovedisplayskip\medskipamount
+ \belowdisplayskip \abovedisplayskip
+% \end{macrocode}
+% The above-display short space is zero but with the same
+% stretchability as the above-display normal space. And the
+% below-display short space is similar, but has a base value equal to
+% \cs{smallskipamount}. Use of the multiplier |1| is an arcane \TeX{}
+% trick that coerces the skip value to a dimen value, i.e., gives us
+% the base value of the skip register without the stretch or shrink
+% values.
+% \begin{macrocode}
+ \abovedisplayshortskip\abovedisplayskip
+ \advance\abovedisplayshortskip-1\abovedisplayskip
+ \belowdisplayshortskip\abovedisplayshortskip
+ \advance\belowdisplayshortskip 1\smallskipamount
+% \end{macrocode}
+% The traditional value for \cs{jot} is 3pt, which we generalize
+% to \cs{baselineskip}/4. This is used to adjust interline spacing in
+% multiline displayed equations.
+% \begin{macrocode}
+ \jot\baselineskip \divide\jot 4 \relax
+}
+% \end{macrocode}%
+%
+% We fill out the range of typesize changing commands to a full
+% eleven: five large/huge commands and five small/tiny commands. (The
+% capitalization of the command names suggests that there should
+% actually be thirteen---add \cn{TINY} and \cn{HUGE}---but let's be
+% conservative and leave those out until a real need for them is
+% known to exist.) An unavoidable side effect is that \cn{tiny} now
+% selects 6pt instead of 5pt by default.
+%
+% In version 1.1 of \cls{amsart} and \cls{amsbook} \cn{small} was
+% the same as \cn{footnotesize} (\cls{amsproc} didn't exist in v. 1.1).
+%
+% The only size-changing command that is predefined by \latex/ is
+% \cn{normalsize}; that's why it's the only one for which we use
+% \cn{renewcommand} below.
+% \begin{macrocode}
+\renewcommand\normalsize{\@xsetfontsize\normalsize 6%
+ \@adjustvertspacing \let\@listi\@listI}
+\DeclareRobustCommand{\Tiny}{\@xsetfontsize\Tiny 1}
+\DeclareRobustCommand{\tiny}{\@xsetfontsize\tiny 2}
+\DeclareRobustCommand{\SMALL}{\@xsetfontsize\SMALL 3}
+\DeclareRobustCommand{\Small}{\@xsetfontsize\Small 4%
+ \@adjustvertspacing
+ \def\@listi{\topsep\smallskipamount \parsep\z@skip \itemsep\z@skip
+ \leftmargin=\leftmargini
+ \labelwidth=\leftmargini \advance\labelwidth-\labelsep
+ }%
+}
+\DeclareRobustCommand{\small}{\@xsetfontsize\small 5\@adjustvertspacing}
+% \end{macrocode}
+% For backward compatibility we had better define \cn{footnotesize}
+% and \cn{scriptsize}. Also there is the small discrepancy with
+% \cn{tiny} to worry about.
+% \begin{macrocode}
+\def\footnotesize{\Small}
+\def\scriptsize{\SMALL}
+% \end{macrocode}
+%
+% The sizes above 10pt use magstep values, stored in the functions
+% \cs{@xipt}, \cs{@xiipt}, etc.
+% \begin{macrocode}
+\DeclareRobustCommand{\large}{\@xsetfontsize\large 7\@adjustvertspacing}
+\DeclareRobustCommand{\Large}{\@xsetfontsize\Large 8\@adjustvertspacing}
+\DeclareRobustCommand{\LARGE}{\@xsetfontsize\LARGE 9}
+\DeclareRobustCommand{\huge}{\@xsetfontsize\huge{10}}
+\DeclareRobustCommand{\Huge}{\@xsetfontsize\Huge{11}}
+%\DeclareRobustCommand\HUGE{\@xsetfontsize\HUGE{12}}
+% \end{macrocode}
+%
+% So now we had better define the \cs{@xsetfontsize} function.
+% The size-changing commands use \cs{@setfontsize} instead of
+% \cn{fontsize} to (a)~give an error message if used in math mode and
+% (b)~set the \cs{@currsize} variable.
+% \begin{macrocode}
+\def\@xsetfontsize#1#2{%
+ \chardef\@currsizeindex#2\relax
+ \edef\@tempa{\@nx\@setfontsize\@nx#1%
+ \@xp\ifcase\@xp\@currsizeindex\@typesizes
+% \end{macrocode}
+% Add nonsense values 99/99 at the end just in case some extreme
+% error turns up.
+% \begin{macrocode}
+ \else{99}{99}\fi}%
+ \@tempa
+}
+% \end{macrocode}
+% For the record let's initialize \cs{@currsizeindex}.
+% \begin{macrocode}
+\chardef\@currsizeindex=6
+% \end{macrocode}
+%
+% Set page-breaking penalties to prevent all widows, orphans, and
+% hyphens at the end of a page.
+% \begin{macrocode}
+\widowpenalty=10000
+\clubpenalty=10000
+\brokenpenalty=10000
+% \end{macrocode}
+%
+% Set some default linespacing values. The variable \cs{linespacing}
+% is usually the normal interline space in the main text. It is used
+% to specify vertical space for elements such as section heads and
+% theorems in proportion to the normal interline space.
+% \begin{macrocode}
+\newdimen\linespacing
+\lineskip=1pt \lineskiplimit=1pt
+\normallineskip=1pt \normallineskiplimit=1pt
+\let\baselinestretch=\@empty
+% \end{macrocode}
+%
+% Settings for \cn{textheight} and \cn{textwidth}. We start with the
+% value 50.5pc specified in AMS journal specifications as the total
+% height of the type block and then subtract the running head height
+% and adjust for \cs{topskip} to get the proper value for the text
+% block.
+% \begin{macrocode}
+\headheight=8pt \headsep=14pt
+%<amsbook>\footskip=18pt
+%<amsart|amsproc>\footskip=12pt
+\textheight=50.5pc \topskip=10pt
+\textwidth=30pc
+\columnsep=10pt \columnseprule=0pt
+% \end{macrocode}
+% Some settings for marginpars.
+% \begin{macrocode}
+\marginparwidth=90pt
+\marginparsep=11pt
+\marginparpush=5pt
+% \end{macrocode}
+% To avoid setting text before begin-document, we postpone the
+% setting of \cs{footnotesep} using \cs{AtBeginDocument}.
+% \begin{macrocode}
+\AtBeginDocument{\settoheight{\footnotesep}{\footnotesize M$^1$}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\skip\footins=7pt plus11pt
+\skip\@mpfootins=\skip\footins
+% \end{macrocode}
+%
+% \begin{macrocode}
+\fboxsep=3pt \fboxrule=.4pt
+% \end{macrocode}
+%
+% \begin{macrocode}
+\arrayrulewidth=.4pt \doublerulesep=2pt
+\labelsep=5pt \arraycolsep=\labelsep
+\tabcolsep=\labelsep \tabbingsep=\labelsep
+% \end{macrocode}
+%
+% \begin{macrocode}
+\floatsep=15pt plus 12pt \dblfloatsep=15pt plus 12pt
+\textfloatsep=\floatsep \dbltextfloatsep=15pt plus 12pt
+\intextsep=\floatsep
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@fptop=0pt plus1fil \@dblfptop=0pt plus1fil
+\@fpbot=0pt plus1fil \@dblfpbot=0pt plus1fil
+\@fpsep=8pt plus2fil \@dblfpsep=8pt plus2fil\relax
+% \end{macrocode}
+% Note that \cs{parskip} gets no stretch; this is at variance with
+% the generic \latex/ classes.
+% \begin{macrocode}
+\parskip=0pt \relax
+% \end{macrocode}
+%
+% \cs{@parboxrestore}, used by \cs{@footnotetext}, sets
+% \cs{parindent} to |0pt|; since this is not what we want, we
+% make a new dimen \cs{normalparindent} and after calling
+% \cs{@parboxrestore}, \cs{@footnotetext} resets
+% \cs{parindent} back to normal.
+% \begin{macrocode}
+\newdimen\normalparindent
+%<amsart>\normalparindent=12pt
+%<amsproc|amsbook>\normalparindent=18pt
+\parindent=\normalparindent
+% \end{macrocode}
+%
+% \begin{macrocode}
+\partopsep=0pt \relax \parsep=0pt \relax \itemsep=0pt \relax
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@lowpenalty=51 \@medpenalty=151 \@highpenalty=301
+\@beginparpenalty=-\@lowpenalty
+\@endparpenalty=-\@lowpenalty
+\@itempenalty=-\@lowpenalty
+% \end{macrocode}
+%
+% \subsubsection{Typesize-specific code}
+%
+% The class option \opt{12pt} sets the main typesize to 12 pt and
+% makes various adaptations, primarily sliding the size-changing
+% commands up the scale of magsteps. This makes it more likely that
+% someone with bitmapped fonts will have all the fonts and sizes
+% that they need. The \opt{8pt} option is for those who like to
+% conserve paper.
+%
+% By parameterizing some aspects it is possible to make a great deal
+% of the typesize-specific code automatically adapt to the selected
+% size. Then there is so little typesize-specific code remaining
+% that it no longer makes sense to put the code in separate \fn{.clo}
+% files. So instead of analogs for the generic \fn{size10,11,12.clo}
+% files we have the code for those options entirely contained in the
+% \fn{.cls} file in the form of declared options.
+%
+% Some miscellaneous remarks.
+%
+% ---If PostScript fonts are used, it may seem a little strange to
+% use fonts following the magstep'd point sizes 10.95, 14.4, 17.28,
+% 20.74, 24.88 instead of simply 11, 14, 17, 21, 25. But it is not
+% easy for us to make that distinction here in the document class
+% definitions of the fontsize changing commands. So we don't try.
+%
+% \begin{macrocode}
+\DeclareOption{10pt}{\def\@mainsize{10}\def\@ptsize{0}%
+ \def\@typesizes{%
+% \end{macrocode}
+% There should be 11 typesize/baselineskip pairs: five below
+% \cn{normalsize} and five above.
+% \begin{macrocode}
+ \or{5}{6}\or{6}{7}\or{7}{8}\or{8}{10}\or{9}{11}%
+ \or{10}{12}% normalsize
+ \or{\@xipt}{13}\or{\@xiipt}{14}\or{\@xivpt}{17}%
+ \or{\@xviipt}{20}\or{\@xxpt}{24}}%
+ \normalsize \linespacing=\baselineskip
+}
+%
+\DeclareOption{11pt}{\def\@mainsize{11}\def\@ptsize{1}%
+ \def\@typesizes{%
+ \or{6}{7}\or{7}{8}\or{8}{10}\or{9}{11}\or{10}{12}%
+ \or{\@xipt}{13}% normalsize
+ \or{\@xiipt}{14}\or{\@xivpt}{17}\or{\@xviipt}{20}%
+ \or{\@xxpt}{24}\or{\@xxvpt}{30}}%
+ \normalsize \linespacing=\baselineskip
+}
+%
+\DeclareOption{12pt}{\def\@mainsize{12}\def\@ptsize{2}%
+ \def\@typesizes{%
+ \or{7}{8}\or{8}{10}\or{9}{11}\or{10}{12}\or{\@xipt}{13}%
+ \or{\@xiipt}{14}% normalsize
+ \or{\@xivpt}{17}\or{\@xviipt}{20}\or{\@xxpt}{24}%
+ \or{\@xxvpt}{30}\or{\@xxvpt}{30}}%
+ \normalsize \linespacing=\baselineskip
+}
+%
+\DeclareOption{8pt}{\def\@mainsize{8}\def\@ptsize{8}%
+ \def\@typesizes{%
+ \or{5}{6}\or{5}{6}\or{5}{6}\or{6}{7}\or{7}{8}%
+ \or{8}{10}% normalsize
+ \or{9}{11}\or{10}{12}\or{\@xipt}{13}%
+ \or{\@xiipt}{14}\or{\@xivpt}{17}}%
+ \normalsize \linespacing=\baselineskip
+}
+%
+\DeclareOption{9pt}{\def\@mainsize{9}\def\@ptsize{9}%
+ \def\@typesizes{%
+ \or{5}{6}\or{5}{6}\or{6}{7}\or{7}{8}\or{8}{10}%
+ \or{9}{11}% normalsize
+ \or{10}{12}\or{\@xipt}{13}\or{\@xiipt}{14}%
+ \or{\@xivpt}{17}\or{\@xviipt}{20}}%
+ \normalsize \linespacing=\baselineskip
+}
+% \end{macrocode}
+%
+% \subsubsection{Running heads}
+% The normal application of pagestyle functions \cs{ps@xxx} is to
+% determine the contents of running heads and feet. The function
+% \cs{@mkboth} is used internally by commands \cn{chapter},
+% \cn{section}, and the like to set the running heads.
+% \begin{macrocode}
+\def\ps@empty{\let\@mkboth\@gobbletwo
+ \let\@oddhead\@empty \let\@evenhead\@empty
+ \let\@oddfoot\@empty \let\@evenfoot\@empty
+% \end{macrocode}
+% The current implementation in \cls{amsart}/\cls{amsproc}/\cls{amsbook}
+% of the vertical space at the top of an opening page uses \cs{topskip},
+% which means that we need to do some resetting here.
+% \begin{macrocode}
+ \global\topskip\normaltopskip}
+% \end{macrocode}
+% Pagestyle `plain' has the page numbers in the running feet.
+% \begin{macrocode}
+\def\ps@plain{\ps@empty
+ \def\@oddfoot{\normalfont\scriptsize \hfil\thepage\hfil}%
+ \let\@evenfoot\@oddfoot}
+% \end{macrocode}
+%
+% Pagestyle `headings' uses text from sectioning commands for
+% running heads. Empty running feet.
+% \begin{macrocode}
+\newswitch{runhead}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\ps@headings{\ps@empty
+ \def\@evenhead{%
+ \setTrue{runhead}%
+ \normalfont\scriptsize
+ \rlap{\thepage}\hfil
+ \def\thanks{\protect\thanks@warning}%
+ \leftmark{}{}\hfil}%
+ \def\@oddhead{%
+ \setTrue{runhead}%
+ \normalfont\scriptsize \hfil
+ \def\thanks{\protect\thanks@warning}%
+ \rightmark{}{}\hfil \llap{\thepage}}%
+ \let\@mkboth\markboth
+%<*amsbook>
+ \def\partmark{\@secmark\markboth\partrunhead\partname}%
+ \def\chaptermark{%
+ \@secmark\markboth\chapterrunhead{}}%
+ \def\sectionmark{%
+ \@secmark\markright\sectionrunhead\sectionname}%
+%</amsbook>
+}
+% \end{macrocode}
+%
+% \begin{macro}{\sectionname}
+% \begin{macro}{\subsectionname}
+% \begin{macro}{\subsubsectionname}
+% \begin{macro}{\paragraphname}
+% \begin{macro}{\subparagraphname}
+% Initialize section headings.
+% \begin{macrocode}
+\let\sectionname\@empty
+\let\subsectionname\@empty
+\let\subsubsectionname\@empty
+\let\paragraphname\@empty
+\let\subparagraphname\@empty
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% The default definitions of \cs{leftmark}, \cs{rightmark} are not
+% what we want: the section title (or whatever) reported in the
+% right-hand running head should report the section that is current
+% at the bottom of the right-hand page. And the left-hand running
+% head should report the status at the top of the page.
+% Cf.~\fn{amsppt.sty}.
+% \begin{macrocode}
+\def\leftmark{\expandafter\@firstoftwo\topmark{}{}}
+\def\rightmark{\expandafter\@secondoftwo\botmark{}{}}
+% \end{macrocode}
+%
+% Journal and Proceedings articles require an indication of the first
+% page so the logo and copyright line can appear.
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\ps@firstpage{\ps@plain
+ \def\@oddfoot{\normalfont\scriptsize \hfil\thepage\hfil
+% \end{macrocode}
+% Stick in the reset of \cs{topskip} here so it only gets executed
+% after the first page is completed.
+% \begin{macrocode}
+ \global\topskip\normaltopskip}%
+ \let\@evenfoot\@oddfoot
+ \def\@oddhead{\@serieslogo\hss}%
+ \let\@evenhead\@oddhead % in case an article starts on a left-hand page
+}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% \begin{macro}{\@nilgobble}
+% Something that apparently doesn't exist in the kernel?
+% \begin{macrocode}
+\long\def\@nilgobble#1\@nil{}
+% \end{macrocode}
+% \end{macro}
+%
+% A general section-marking function. Arg 1 is either \cn{markright}
+% or \cn{markboth} indicating which kind of marking action is desired
+% (this gives us some string pool/hash table savings by allowing the
+% \cs{@secmark} function to serve for both cases). Arg 2 is the
+% function that should be called in the running head to process the
+% remaining three args. Arg 3 is normally \cs{xxxname} (but could be
+% empty). Arg 4 is the section-title text. Assumption: whenever
+% \cs{@secmark} is called, the section-number variable
+% \cs{@secnumber} has been set to the value of the current section
+% number (possibly empty, in the case of a |*| section for example).
+% \begin{macrocode}
+%<*amsbook>
+\def\@secmark#1#2#3#4{%
+% \end{macrocode}
+% We want to apply expansion to \cs{xxxname} and \cs{thexxx} but not
+% to the other elements.
+% \begin{macrocode}
+ \begingroup \let\protect\@unexpandable@protect
+ \edef\@tempa{\endgroup \toks@{\protect#2{#3}{\@secnumber}}}%
+ \@tempa
+ \toks@\@xp{\the\toks@{#4}}%
+% \end{macrocode}
+% If a \cn{markright} operation is called for, use the current
+% left-mark via \cs{@temptokena}.
+% \begin{macrocode}
+ \afterassignment\@nilgobble\@temptokena\@themark{}\@nil
+ \edef\@tempa{\@nx\@mkboth{%
+ \ifx\markright#1\the\@temptokena\else\the\toks@\fi}{\the\toks@}}%
+ \@tempa}
+% \end{macrocode}
+% Init \cs{@secnumber}.
+% \begin{macrocode}
+\let\@secnumber\@empty
+%</amsbook>
+% \end{macrocode}
+%
+% Fix \cn{markboth} so that \cs{@secmark} can work without too much
+% thrashing.
+% \begin{macrocode}
+\def\markboth#1#2{%
+ \begingroup
+ \@temptokena{{#1}{#2}}\xdef\@themark{\the\@temptokena}%
+ \mark{\the\@temptokena}%
+ \endgroup
+ \if@nobreak\ifvmode\nobreak\fi\fi}
+% \end{macrocode}
+%
+% With the myheadings pagestyle, no automatic running heads will be
+% provided by the document class; only running heads specified by
+% the user through explicit \cn{markboth} or \cn{markright}
+% commands will be used.
+% \begin{macrocode}
+\def\ps@myheadings{\ps@headings \let\@mkboth\@gobbletwo}
+% \end{macrocode}
+%
+% Save normal topskip value in a skip register.
+% \begin{macrocode}
+\newskip\normaltopskip
+\normaltopskip=10pt \relax
+% \end{macrocode}
+%
+% We also want to turn off all section marks. First-level section
+% heads will be defined in \cs{ps@headings}.
+% \begin{macrocode}
+\let\sectionmark\@gobble
+\let\subsectionmark\@gobble
+\let\subsubsectionmark\@gobble
+\let\paragraphmark\@gobble
+% \end{macrocode}
+
+% \subsubsection{Unrecognized options}
+%
+% The \opt{makeidx} option is redundant; everything that it does in
+% the generic \latex/ classes is already done anyway in this class.
+% \begin{macrocode}
+\DeclareOption{makeidx}{}
+%</classes>
+% \end{macrocode}
+%
+% Unrecognized options for \pkg{amsthm} are treated as references
+% to auxiliary theorem setup (\fn{.thm}) files. This allows a user
+% to create theorem styles using internal commands (with |@| signs)
+% without having to be concerned about category coding.
+%
+% Here is an example from the file \fn{thmtest.tex} which is part
+% of this collection. See that file for further information.
+%\begin{verbatim}
+% \begin{filecontents}{exercise.thm}
+% \def\th@exercise{%
+% \normalfont % body font
+% \thm@headpunct{:}%
+% }
+% \end{filecontents}
+%\end{verbatim}
+%
+% This facility is available only when \pkg{amsthm} is used as an
+% independent package, not as part of an AMS document class.
+% \begin{macrocode}
+%<*amsthm>
+\DeclareOption*{\input{\CurrentOption .thm}}
+\ProcessOptions
+%</amsthm>
+% \end{macrocode}
+%
+% \subsection{Process options}
+%
+% Black boxes for overfull lines are turned off by default (the
+% \opt{final} option). This can be overridden with the \opt{draft}
+% option.
+% \begin{macrocode}
+%<*classes>
+\ExecuteOptions{leqno,centertags,letterpaper,portrait,%
+ 10pt,twoside,onecolumn,final}
+% \end{macrocode}
+% Options will be processed in the order of the associated
+% \cs{DeclareOption} commands.
+% \begin{macrocode}
+\ProcessOptions\relax
+% \end{macrocode}
+%
+% In compatibility mode, we want to load the frozen version of
+% \fn{amstex.sty} instead of the \pkg{amsmath} package. This is
+% rather a horrible kluge but I can't see anything better at the
+% moment. [mjd,1995/01/27]
+% \begin{macrocode}
+\if@compatibility
+ \def\@tempa{\RequirePackage{amstex}\relax}%
+\else
+ \@ifclasswith{\@classname}{nomath}{%
+ \let\@tempa\relax
+ }{%
+ \def\@tempa{\RequirePackage{amsmath}\relax}%
+ }%
+\fi
+\@tempa % load amstex.sty or amsmath.sty
+% \end{macrocode}
+% If the \opt{nomath} option was specified, then \cn{numberwithin}
+% and \cs{@emptytoks} remain to be defined.
+% \begin{macrocode}
+\@ifundefined{numberwithin}{%
+ \newcommand{\numberwithin}[3][\arabic]{%
+ \@ifundefined{c@#2}{\@nocounterr{#2}}{%
+ \@ifundefined{c@#3}{\@nocnterr{#3}}{%
+ \@addtoreset{#2}{#3}%
+ \@xp\xdef\csname the#2\endcsname{%
+ \@xp\@nx\csname the#3\endcsname .\@nx#1{#2}}}}%
+ }
+ \csname newtoks\endcsname\@emptytoks
+}{}
+% \end{macrocode}
+%
+% If the \opt{noamsfonts} option was called for, skip the
+% \pkg{amsfonts} package load.
+% \begin{macrocode}
+\if@compatibility
+\else
+ \@ifclasswith{\@classname}{noamsfonts}{%
+ % amsfonts package is not wanted
+ }{%
+ % amsfonts package IS wanted; test whether a recent enough version
+ % seems to be installed
+ \begingroup \fontencoding{U}\fontfamily{msa}\try@load@fontshape\endgroup
+ \global\@xp\let\csname U+msa\endcsname\relax % reset
+ \@ifundefined{U/msa/m/n}{%
+ \ClassError{\@classname}{%
+ Package `amsfonts' not installed, or version too old?\MessageBreak
+ Unable to get font info for the `msam' fonts in the expected form%
+ }{%
+ The amsfonts package will not be loaded, to avoid probable\MessageBreak
+ incompatibility problems. You can (a) use the `noamsfonts'
+ documentclass\MessageBreak
+ option next time, or (b) check that the amsfonts package is
+ installed\MessageBreak
+ correctly, and is not too old to be compatible.%
+ }%
+ }{%
+ \RequirePackage{amsfonts}[1995/01/01]\relax
+ }%
+ }
+\fi % end yesamsfonts branch
+% \end{macrocode}
+%
+% \subsection{Basic AMS style features}
+%
+% AMS style requires that blank pages between chapters be \emph{really}
+% blank: no running heads, no page numbers. To accomplish this,
+% redefine \cn{cleardoublepage} to do the right thing. [bnb, 1999/07/17]
+% \begin{macrocode}
+\let\cleardouble@page\cleardoublepage
+% \end{macrocode}
+% Postpone the redefinition of \cs{cleardoublepage} to begin-document
+% to work around difficulties with old versions of \fn{gsm-l.cls}.
+% \begin{macrocode}
+\AtBeginDocument{%
+ \ifx\cleardouble@page\cleardoublepage
+ \def\cleardoublepage{\clearpage{\pagestyle{empty}\cleardouble@page}}
+ \fi
+}
+% \end{macrocode}
+%
+% Now a utility macro to do \cn{uppercase} but sidestep any math, to
+% prevent uppercasing math variables. In order to be handled properly
+% the |$...$| or |\(...\)| must be on the outer level (not
+% enclosed in braces). We did not try to handle the possibility
+% |\begin{math}| |...| |\end{math}| in a title at the present time (too
+% complicated). Also we increase inter-word space in the uppercase
+% text.
+%
+% One other little problem: uppercasing of a few special characters
+% like the German {\ss} (\cn{ss}) and the undotted i and j (\cn{i}
+% and \cn{j}), used sometimes with accents. We redefine them to be
+% uppercase equivalents. (Undotted \cn{i} and \cn{j} in math would be
+% typed as \cn{imath} and \cn{jmath}.)
+%
+% Spaceskip is changed in accordance with recommendations for
+% increased interword spacing in all-caps text by e.g.\ `Words into
+% Type'.
+% \begin{macrocode}
+\newcommand{\uppercasenonmath}[1]{\toks@\@emptytoks
+% Insert an extra \@empty to avoid removing braces around arg \arg{1}.
+ \@xp\@skipmath\@xp\@empty#1$$%
+% \end{macrocode}
+% The \cs{protect} here is in case the shorttitle gets used for
+% shortauthors and we get redundant application of \cn{MakeUppercase}.
+% Double braces limit the scope so that later elements in title block
+% aren't uppercased, e.g., \cn{i} in an address. [bnb, 2004/04/01]
+% \begin{macrocode}
+ \edef#1{{\@nx\protect\@nx\@upprep\the\toks@}}%
+}
+% \end{macrocode}
+%
+% \begin{macro}{\@upprep}
+% Preparations for printing all-caps text.
+% \begin{macrocode}
+\newcommand{\@upprep}{%
+ \spaceskip1.3\fontdimen2\font plus1.3\fontdimen3\font
+ \upchars@}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\upchars@}
+% In all-caps text, esszet should print as SS, dotless i should print
+% as normal cap I, Mc should print with a small-caps (not lowercase)
+% c, and so forth.
+% \begin{macrocode}
+\newcommand{\upchars@}{%
+ \def\ss{SS}\def\i{I}\def\j{J}\def\ae{\AE}\def\oe{\OE}%
+ \def\o{\O}\def\aa{\AA}\def\l{\L}\def\Mc{M{\scshape c}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Mc}
+% The use of \cn{Mc} makes it possible for `Mc' to get special
+% treatment when uppercasing is applied.
+% \begin{macrocode}
+\providecommand{\Mc}{Mc}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@skipmath}
+% \begin{macro}{\@xskipmath}
+% \cs{@skipmath} searches for |$...$| in order to keep from applying
+% \cn{uppercase} to the contents. Then it calls \cs{@xskipmath} to
+% search for |\(...\)|.
+% \begin{macrocode}
+\newcommand{\@skipmath}{}
+\long\def\@skipmath#1$#2${%
+ \@xskipmath#1\(\)%
+ \@ifnotempty{#2}{\toks@\@xp{\the\toks@$#2$}\@skipmath\@empty}}%
+%
+\newcommand{\@xskipmath}{}
+\long\def\@xskipmath#1\(#2\){%
+% Expand away the added \@empty
+ \uppercase{\toks@\@xp\@xp\@xp{\@xp\the\@xp\toks@#1}}%
+ \@ifnotempty{#2}{\toks@\@xp{\the\toks@\(#2\)}\@xskipmath\@empty}}%
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\altucnm}
+% \begin{macrocode}
+\def\altucnm#1{%
+ \MakeTextUppercase{\toks@{#1}}%
+ \edef#1{\the\toks@}%
+}
+\AtBeginDocument{%
+ \@ifundefined{MakeTextUppercase}{}{\let\uppercasenonmath\altucnm}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% For older versions of \latex/ this might be needed too:
+% \begin{macrocode}
+\@ifundefined{MakeUppercase}{\let\MakeUppercase\uppercase}{}%
+% \end{macrocode}
+%
+% \begin{macro}{\today}
+% The command \cn{today} produces today's date in the form most
+% commonly used in the U.S.
+% \begin{macrocode}
+\newcommand{\today}{%
+ \relax\ifcase\month\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
+ \space\number\day, \number\year}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Old font commands}
+% The \cn{em} command is not redefined here (let's say, to give an
+% `obsolete' warning and recommend instead \cn{emph}) because there
+% is no alternative internal command \cs{emshape}.
+% \begin{macrocode}
+\DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm}
+\DeclareOldFontCommand{\sf}{\normalfont\sffamily}{\mathsf}
+\DeclareOldFontCommand{\tt}{\normalfont\ttfamily}{\mathtt}
+\DeclareOldFontCommand{\bf}{\normalfont\bfseries}{\mathbf}
+\DeclareOldFontCommand{\it}{\normalfont\itshape}{\mathit}
+\DeclareOldFontCommand{\sl}{\normalfont\slshape}{\@nomath\sl}
+\DeclareOldFontCommand{\sc}{\normalfont\scshape}{\@nomath\sc}
+% \end{macrocode}
+%
+% This warning might have been a good idea back in 1995 but I don't
+% think we can add it now [mjd,2000/03/10].
+%\begin{verbatim}
+%%\if@compatibility
+%%\else
+%% \def\@obsolete@fontswitch#1#2#3{%
+%% \@latex@warning@no@line{%
+%% Command {\string#1...}\on@line\space is obsolete;\MessageBreak
+%% the LaTeX2e equivalent is \string#3{...}}%
+%% \gdef#1{\@fontswitch\relax#3}%
+%% }
+%% \DeclareRobustCommand*\cal{%
+%% \@xp\@obsolete@fontswitch\csname cal \endcsname\relax\mathcal}
+%% \DeclareRobustCommand*\mit{%
+%% \@xp\@obsolete@fontswitch\csname mit \endcsname\relax\mathnormal}
+%%\fi
+%\end{verbatim}
+% There's too great a chance that some people out there have
+% documents that begin with
+%\begin{verbatim}
+%\documentclass{amsart}
+%...
+%\newcommand{\cal}{\mathcal}
+%\end{verbatim}
+% and such documents would now get error messages.
+%
+% Since \cs{cal} is not documented as a valid command for \LaTeXe/, I
+% think it is OK to leave the status as is for AMS document classes.
+% If you use \cs{documentstyle}, \cs{cal} will work. If you use
+% \cs{documentclass}, well, it's a good idea to update to
+% \cs{mathcal} instead of leaving old instances of \cs{cal}.
+%
+% \subsection{Top matter}
+% For the \cn{title} command, we support an optional argument to give
+% a shortened version of the title for running heads.
+% \begin{macrocode}
+\renewcommand*{\title}[2][]{\gdef\shorttitle{#1}\gdef\@title{#2}}
+% \end{macrocode}
+% The default value for the optional argument is `same as the
+% mandatory arg' but there doesn't seem to be an easy way to get that
+% effect with \ncn{[re]newcommand}. Here is how to use \cs{@dblarg}
+% in conjunction with the preceding \cn{newcommand}:
+% \begin{macrocode}
+\edef\title{\@nx\@dblarg
+ \@xp\@nx\csname\string\title\endcsname}
+% \end{macrocode}
+% The \cn{author} command accepts an optional argument similar to
+% that of the \cn{title} command.
+% Moved update of \cn{addresses} within scope of \cs{else} to avoid
+% adding anything if no authors, and thus avoiding output of ``Author
+% address'' on monograph titlepage. [bnb, 1996/11/03]
+% \begin{macrocode}
+\renewcommand{\author}[2][]{%
+ \ifx\@empty\authors
+ \gdef\authors{#2}%
+ \else
+ \g@addto@macro\authors{\and#2}%
+ \g@addto@macro\addresses{\author{}}%
+ \fi
+ \@ifnotempty{#1}{%
+ \ifx\@empty\shortauthors
+ \gdef\shortauthors{#1}%
+ \else
+ \g@addto@macro\shortauthors{\and#1}%
+ \fi
+ }%
+}
+\edef\author{\@nx\@dblarg
+ \@xp\@nx\csname\string\author\endcsname}
+% \end{macrocode}
+% Initialize some variables.
+% \begin{macrocode}
+\let\shortauthors\@empty \let\authors\@empty
+% \end{macrocode}
+%
+% \begin{macro}{\contrib}
+%
+% Contributors are similar to authors except that they are responsible
+% for only part of a work, e.g., an appendix. The optional argument
+% for the first contributor of a group identifies what has been
+% contributed. There can be more than one group of contributors;
+% each group is treated separately, using the same ``and'' conventions
+% within the group as for authors. Contributor groups are strung
+% together separated by a comma; if the word ``and'' is desired before
+% the final group of contributors, it must be included in the optional
+% argument for that group.
+% \begin{macrocode}
+%<*amsart|amsproc>
+\newif\ifresetcontrib \resetcontribfalse
+\newcommand\contrib[2][]{%
+ \def\@tempa{#1}%
+ \ifx\@empty\@tempa
+ \else
+ \ifresetcontrib \@xcontribs
+ \else \global\resetcontribtrue
+ \fi
+ \fi
+ \ifx\@empty\contribs
+ \gdef\contribs{#1 #2}%
+ \else
+ \g@addto@macro\contribs{\and#1 #2}%
+ \fi
+% \end{macrocode}
+% Accumulate contribs separately for the table of contents. Here,
+% this is just a dummy; it is fully defined for in-house processing.
+% \begin{macrocode}
+ \@wraptoccontribs{#1}{#2}%
+}
+\def\wraptoccontribs#1#2{}
+\def\@xcontribs{%
+ \author@andify\contribs
+ \ifx\@empty\xcontribs
+ \xdef\xcontribs{\contribs}%
+ \else
+ \xdef\xcontribs{\xcontribs, \contribs}%
+ \fi
+ \let\contribs\@empty
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Initialize some more variables.
+% \begin{macrocode}
+\let\contribs\@empty \let\xcontribs\@empty \let\toccontribs\@empty
+%</amsart|amsproc>
+\let\addresses\@empty \let\thankses\@empty
+% \end{macrocode}
+%
+% The optional arguments of \cn{address}, \cn{curraddr}, \cn{email}
+% are to indicate which author the address applies to, if a document
+% has multiple authors and there is not a normal one-to-one
+% correspondence between authors and addresses.
+% \begin{macrocode}
+\newcommand{\address}[2][]{\g@addto@macro\addresses{\address{#1}{#2}}}
+\newcommand{\curraddr}[2][]{\g@addto@macro\addresses{\curraddr{#1}{#2}}}
+\newcommand{\email}[2][]{\g@addto@macro\addresses{\email{#1}{#2}}}
+\newcommand{\urladdr}[2][]{\g@addto@macro\addresses{\urladdr{#1}{#2}}}
+% \end{macrocode}
+%
+% Someone who does not look closely at the \cls{amsart} documentation
+% is likely to put the \cn{thanks} command inside that argument of
+% \cn{author}.
+% \begin{macrocode}
+\long\def\thanks@warning#1{%
+ \ClassError{\@classname}{%
+ \protect\thanks\space should be given separately, not inside author name.%
+ }\@ehb
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\renewcommand{\thanks}[1]{%
+ \@ifnotempty{#1}{\g@addto@macro\thankses{\thanks{#1}}}%
+}
+% \end{macrocode}
+%
+% The following example of addresses for three authors of a
+% tri-author paper illustrates the kind of complications that need to
+% be handled.
+%\begin{verbatim}
+% \author{Roland Campbell}
+% \address{Department of Mathematics\\
+% Pennsylvania State University\\
+% Pittsburgh, Pennsylvania 13593}
+% \email[R.~Campbell]{campr@@galois.psu.edu}
+%
+% \author{Mark M. Dane}
+% % Same address as R. Campbell
+% \curraddr[M.~Dane]{Atmospheric Research Station\\
+% Pala Lundi, Fiji}
+% \email[M.~Dane]{DaneMark@@ffr.choice}
+%
+% \author{Jeremiah Jones}
+% \address[J.~Jones]{Department of Philosophy\\
+% Freedman College\\
+% Periwinkle, Colorado 84320}
+% \email[J.~Jones]{id739e@@oseoi44 (Bitnet)}
+%\end{verbatim}
+% In an article, typesetting of the address information is done at
+% the end of the document, by calling \cs{@setaddresses}. This is done
+% through a parent function \cs{enddoc@text}, because some AMS journals
+% also print the abstract there instead of at the beginning, and it's
+% easier to redefine \cs{enddoc@text} than to try undoing material
+% already added to the \cs{AtEndDocument} hook.
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\enddoc@text{\ifx\@empty\@translators \else\@settranslators\fi
+ \ifx\@empty\addresses \else\@setaddresses\fi}
+\AtEndDocument{\enddoc@text}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\curraddrname{{\itshape Current address}}
+\def\emailaddrname{{\itshape E-mail address}}
+\def\urladdrname{{\itshape URL}}
+\def\@setaddresses{\par
+ \nobreak \begingroup
+%<amsart|amsproc>\footnotesize
+ \def\author##1{\nobreak\addvspace\bigskipamount}%
+% \end{macrocode}
+% Address is supposed to go all on one line, so we redefine |\\|
+% to just insert a comma instead of doing a line break.
+% \begin{macrocode}
+ \def\\{\unskip, \ignorespaces}%
+% \end{macrocode}
+% No page breaks in the address section is accomplished by
+% |\interlinepenalty\@M| and by the \cn{nobreak} before the \cn{bigskip}.
+% \begin{macrocode}
+ \interlinepenalty\@M
+ \def\address##1##2{\begingroup
+% \end{macrocode}
+% If there are two addresses for the same author, add a \cn{bigskip}
+% between them.
+% \begin{macrocode}
+ \par\addvspace\bigskipamount\indent
+% \end{macrocode}
+% If the name of the author to whom this address applies
+% was given, typeset it.
+% \begin{macrocode}
+ \@ifnotempty{##1}{(\ignorespaces##1\unskip) }%
+% \end{macrocode}
+% Now the main part of the address:
+% \begin{macrocode}
+ {\scshape\ignorespaces##2}\par\endgroup}%
+% \end{macrocode}
+% Current address:
+% \begin{macrocode}
+ \def\curraddr##1##2{\begingroup
+ \@ifnotempty{##2}{\nobreak\indent\curraddrname
+ \@ifnotempty{##1}{, \ignorespaces##1\unskip}\/:\space
+ ##2\par}\endgroup}%
+% \end{macrocode}
+% And then email. In versions 1.0 and 1.1 |@@| was required to print
+% a single \qc{\@} character; for bulletproofing we convert doubled
+% \qc{\@} characters if found.
+% \begin{macrocode}
+ \def\email##1##2{\begingroup
+ \@ifnotempty{##2}{\nobreak\indent\emailaddrname
+ \@ifnotempty{##1}{, \ignorespaces##1\unskip}\/:\space
+ \ttfamily##2\par}\endgroup}%
+% \end{macrocode}
+% URLaddr is simply a replica of the email address, with the
+% addition of a feature to enable |~| to print.
+% \begin{macrocode}
+ \def\urladdr##1##2{\begingroup
+ \def~{\char`\~}%
+ \@ifnotempty{##2}{\nobreak\indent\urladdrname
+ \@ifnotempty{##1}{, \ignorespaces##1\unskip}\/:\space
+ \ttfamily##2\par}\endgroup}%
+ \addresses
+ \endgroup
+}
+% \end{macrocode}
+%
+% Some other administrative info. For \cn{date} we can just use the
+% default definition provided by \latex/, except that we initialize
+% the date to empty instead of to \cn{today}.
+% \begin{macrocode}
+\let\@date\@empty
+\def\dedicatory#1{\def\@dedicatory{#1}}
+\let\@dedicatory=\@empty
+\def\keywords#1{\def\@keywords{#1}}
+\let\@keywords=\@empty
+% \end{macrocode}
+%
+% To allow various versions of the subject classification, accept an
+% optional value to identify the version, provide text for the two
+% currently in use, and give a warning if the version specified is
+% unknown. Default to 1991 version. [bnb, 1999/04/30]
+% \begin{macrocode}
+\newcommand*\subjclass[2][1991]{%
+ \def\@subjclass{#2}%
+ \@ifundefined{subjclassname@#1}{%
+ \ClassWarning{\@classname}{Unknown edition (#1) of Mathematics
+ Subject Classification; using '1991'.}%
+ }{%
+ \@xp\let\@xp\subjclassname\csname subjclassname@#1\endcsname
+ }%
+}
+\let\@subjclass=\@empty
+%<amsart>\def\commby#1{\def\@commby{(Communicated by #1)}}
+%<amsart>\let\@commby=\@empty
+% \end{macrocode}
+%
+% We handle translator names like author names, just in case there is
+% more than one translator. [mjd,1994/10/19]
+% \begin{macrocode}
+\def\translname{Translated by}
+\def\translator#1{%
+ \ifx\@empty\@translators \def\@translators{#1}%
+ \else\g@addto@macro\@translators{\and#1}\fi}
+\let\@translators=\@empty
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\@settranslators{\par\begingroup
+ \addvspace{6\p@\@plus9\p@}%
+ \hbox to\columnwidth{\hss\normalfont\normalsize
+ \translname{ }%
+ \andify\@translators \uppercasenonmath\@translators
+ \@translators}
+ \endgroup
+}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% The general function to convert a list of items in the form
+%\begin{verbatim}
+% A\and B\and C\and D
+%\end{verbatim}
+% to the form `A, B, C, and D' is \cs{xandlist}:
+%\begin{verbatim}
+% \xandlist{, }{ and }{, and }{A\and B\and C\and D}
+%\end{verbatim}
+% This is a completely expandable macro, with the return value being
+% the converted list. There is also a `no-execute' version whose
+% fourth argument should be a macro; the text to be converted will be
+% taken from that macro and after conversion will be put back as the
+% macro's new replacement text.
+%\begin{verbatim}
+% \nxandlist{, }{ and }{, and }\result
+%\end{verbatim}
+% I don't think I want to explain this except by recommending that
+% you watch it in operation with \cs{tracingmacros} if you're
+% interested. [mjd,1994/10/19]
+% \begin{macrocode}
+\newcommand{\xandlist}[4]{\@andlista{{#1}{#2}{#3}}#4\and\and}
+\def\@andlista#1#2\and#3\and{\@andlistc{#2}\@ifnotempty{#3}{%
+ \@andlistb#1{#3}}}
+\def\@andlistb#1#2#3#4#5\and{%
+ \@ifempty{#5}{%
+ \@andlistc{#2#4}%
+ }{%
+ \@andlistc{#1#4}\@andlistb{#1}{#3}{#3}{#5}%
+ }}
+\let\@andlistc\@iden
+\newcommand{\nxandlist}[4]{%
+ \def\@andlistc##1{\toks@\@xp{\the\toks@##1}}%
+ \toks@{\toks@\@emptytoks \@andlista{{#1}{#2}{#3}}}%
+ \the\@xp\toks@#4\and\and
+ \edef#4{\the\toks@}%
+ \let\@andlistc\@iden}
+% \end{macrocode}
+%
+% \begin{macro}{andify}
+%
+% The \cs{andify} function is provided as a convenient abbreviation
+% for the most common case. See also \cs{author@andify} (for
+% \cls{amsart} and \cls{amsproc} only), which gives better results
+% in cases with a large number of authors. Provide a substitutable
+% text string to simplify language-specific modifications.
+% \begin{macrocode}
+\def\@@and{and}
+\newcommand{\andify}{%
+ \nxandlist{\unskip, }{\unskip{} \@@and~}{\unskip, \@@and~}}
+% \end{macrocode}
+% Override the funny default definition of \cn{and} from \latex/.
+% This is not actually used by AMS classes, however.
+% \begin{macrocode}
+\def\and{\unskip{ }\@@and{ }\ignorespaces}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{maketitle}
+%
+% Set up the style of an article opening page. For books, see below.
+% For articles, we must add the copyright info footnote.
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\maketitle{\par
+ \@topnum\z@ % this prevents figures from falling at the top of page 1
+ \@setcopyright
+ \thispagestyle{firstpage}% this sets first page specifications
+% \end{macrocode}
+% Do some setup for the running heads here. If there are no author names,
+% we set the left-hand running head to the value of the right-hand running
+% head.
+% \begin{macrocode}
+ \uppercasenonmath\shorttitle
+ \ifx\@empty\shortauthors \let\shortauthors\shorttitle
+ \else \andify\shortauthors
+ \fi
+% \end{macrocode}
+% The following hook is used to activate the writing of author and
+% title information to an `issue table of contents' when multiple
+% articles are being processed for a journal issue or a proceedings
+% volume.
+% \begin{macrocode}
+ \@maketitle@hook
+ \begingroup
+ \@maketitle
+ \toks@\@xp{\shortauthors}\@temptokena\@xp{\shorttitle}%
+ \toks4{\def\\{ \ignorespaces}}% defend against questionable usage
+ \edef\@tempa{%
+ \@nx\markboth{\the\toks4
+ \@nx\MakeUppercase{\the\toks@}}{\the\@temptokena}}%
+ \@tempa
+ \endgroup
+ \c@footnote\z@
+ \@cleartopmattertags
+}
+\def\@cleartopmattertags{%
+ \def\do##1{\let##1\relax}%
+ \do\maketitle \do\@maketitle \do\title \do\@xtitle \do\@title
+ \do\author \do\@xauthor \do\address \do\@xaddress
+ \do\contrib \do\contribs \do\xcontribs \do\toccontribs
+ \do\email \do\@xemail \do\curraddr \do\@xcurraddr
+%<amsart> \do\commby \do\@commby
+ \do\dedicatory \do\@dedicatory \do\thanks \do\thankses
+ \do\keywords \do\@keywords \do\subjclass \do\@subjclass
+}
+%</amsart|amsproc>
+% \end{macrocode}
+% \end{macro}
+%
+% The hook \cs{@maketitle@hook} is placed into \cn{maketitle} rather
+% than \cs{@maketitle} because the latter tends to get redefined by
+% derived classes using this one as a base. The initial motivation
+% for this hook is to extract title and author information to an
+% external file, so we can't do it with \cs{AtBeginDocument}:
+% \cn{title} and \cn{author} commands might occur between
+% \verb'\begin{document}' and \cn{maketitle}.
+%
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\@maketitle@hook{\global\let\@maketitle@hook\@empty}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% Set up the style of an article opening page.
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\@maketitle{%
+% \end{macrocode}
+% Set font to normal, just in case.
+% \begin{macrocode}
+ \normalfont\normalsize
+% \end{macrocode}
+% Special footnotes are put here to ensure that they come first at
+% the bottom of the page.
+% \begin{macrocode}
+ \@adminfootnotes
+% \end{macrocode}
+% If |\pagestyle{myheadings}| was specified, \cs{@mkboth} will be a no-op.
+% \begin{macrocode}
+ \@mkboth{\@nx\shortauthors}{\@nx\shorttitle}%
+%<amsproc> \global\topskip8pc\relax % 10pc to base of first title line
+%<amsart> \global\topskip42\p@\relax % 5.5pc " " " " "
+ \@settitle
+ \ifx\@empty\authors \else \@setauthors \fi
+% \end{macrocode}
+% Likewise with \cs{@dedicatory} and \cs{@date}.
+% \begin{macrocode}
+ \ifx\@empty\@dedicatory
+ \else
+%<amsproc> \baselineskip26\p@
+%<amsart> \baselineskip18\p@
+ \vtop{\centering{\footnotesize\itshape\@dedicatory\@@par}%
+ \global\dimen@i\prevdepth}\prevdepth\dimen@i
+ \fi
+ \@setabstract
+% \end{macrocode}
+% Space before the main text should be 32 + 14 base-to-base; we
+% accomplish this by doing a vskip of that amount with \cs{baselineskip}
+% subtracted.
+% \begin{macrocode}
+ \normalsize
+ \if@titlepage
+ \newpage
+ \else
+ \dimen@34\p@ \advance\dimen@-\baselineskip
+ \vskip\dimen@\relax
+ \fi
+} % end \@maketitle
+% \end{macrocode}
+%
+% Segregate the definitions of administrative footnotes to permit
+% easier customization, especially for translation journals.
+% \begin{macrocode}
+\def\@adminfootnotes{%
+ \let\@makefnmark\relax \let\@thefnmark\relax
+%<amsart> \ifx\@empty\@date\else \@footnotetext{\@setdate}\fi
+ \ifx\@empty\@subjclass\else \@footnotetext{\@setsubjclass}\fi
+ \ifx\@empty\@keywords\else \@footnotetext{\@setkeywords}\fi
+% \end{macrocode}
+% In order to make multiple thanks footnotes work inside a single
+% \cs{@footnotetext} argument we need to make the first \cn{par} be
+% ignored. Cf.~\cs{@setthanks}.
+% \begin{macrocode}
+ \ifx\@empty\thankses\else \@footnotetext{%
+ \def\par{\let\par\@par}\@setthanks}%
+ \fi
+}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% \subsection{Journal/series logo for articles}
+%
+% \cs{publname} either will be defined by a parent class that is calling
+% \cls{amsart} or \cls{amsproc} as a base class, or will be absent, in
+% which case this can be used as a signal to omit the \cs{@serieslogo}.
+% A typical value for \cs{publname} would be
+%\begin{verbatim}
+% \def\publname{JOURNAL OF THE\newline
+% AMERICAN MATHEMATICAL SOCIETY}
+%\end{verbatim}
+%
+% Initialize \cs{publname} and \cs{@serieslogo} to no-op if
+% \cs{publname} is not already defined.
+% \begin{macrocode}
+%<*amsart|amsproc>
+\AtBeginDocument{%
+ \@ifundefined{publname}{%
+ \let\publname\@empty
+ \let\@serieslogo\@empty
+ }{%
+%<amsart> \def\@serieslogo{\article@logo}%
+%<amsproc> \def\@serieslogo{\procart@logo}%
+ }%
+}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% The \cs{number} prefix on current issue is to work around
+% inconsistencies in the form of issue numbers as passed in from
+% system level. Sometimes they will get passed in with a leading
+% zero, which we don't want to print if it happens to occur.
+% The |0| prevents an error if \cs{currentissue} happens to be empty.
+% \begin{macrocode}
+%<*amsart>
+\AtBeginDocument{%
+ \@ifundefined{volinfo}{%
+ \def\volinfo{%
+ Volume \currentvolume, Number \number0\currentissue
+% \end{macrocode}
+% Month/year is not included initially when a journal article is
+% posted on the WWW prior to print publication.
+% \begin{macrocode}
+ \if\@printyear , \currentmonth\ \currentyear\fi
+ }%
+ }{}%
+}
+\def\@printyear{TF}% boolean false
+%</amsart>
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*amsproc>
+\AtBeginDocument{%
+ \@ifundefined{volinfo}{\let\volinfo\@empty}{}
+}
+%</amsproc>
+% \end{macrocode}
+%
+% Default values for information such as volume, year, and so on are
+% provided as follows.
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\issueinfo#1#2#3#4{\def\currentvolume{#1}\def\currentissue{#2}%
+ \def\currentmonth{#3}\def\currentyear{#4}}
+\issueinfo{00}% volume number
+ {0}% % issue number
+ {Xxxx}% % month
+ {XXXX}% % year
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% Copyright year may be different from issue year. Allow it to be
+% specified separately. It is probably more natural anyway, from the
+% user's perspective, to give the copyright year in the same command
+% when giving the name of the copyright holder.
+% \begin{macrocode}
+\newcommand{\copyrightinfo}[2]{%
+ \def\copyrightyear{#1}%
+ \@ifnotempty{#2}{\def\copyrightholder{#2}}%
+}
+\copyrightinfo{0000}{(copyright holder)}
+% \end{macrocode}
+%
+% Provide page span information. If negative number is given, convert
+% to roman numeral form.
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\pagespan#1#2{\setcounter{page}{#1}%
+ \ifnum\c@page<\z@ \pagenumbering{roman}\setcounter{page}{-#1}\fi
+ \def\start@page{#1}\def\end@page{#2}}
+\pagespan{000}{000}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% Formatting for journal page numbers. [bnb, 1996/09/11]
+% \begin{macrocode}
+%<*amsart>
+\AtBeginDocument{%
+ \@ifundefined{pageinfo}{%
+ \def\pageinfo{%
+ \ifnum\start@page=\z@
+ Pages 000--000
+ \else
+ \ifx\start@page\end@page
+ Page \start@page
+ \else
+ Pages \start@page--\end@page
+ \fi
+ \fi}%
+ }{}%
+}
+%</amsart>
+% \end{macrocode}
+%
+% Publisher Item Identifier (we started using them in journal logos
+% as of January 1997).
+% \begin{macrocode}
+%<amsart>\@ifundefined{ISSN}{\def\ISSN{0000-0000}}{}
+%<amsart>\newcommand\PII[1]{\def\@PII{#1}}
+%<amsart>\PII{S \ISSN(XX)0000-0}
+% \end{macrocode}
+%
+% \subsection{Copyright block}
+%
+% Doing the copyright info on the first page is a little tricky. We
+% want it to come at the bottom, after any footnotes and floating
+% inserts, but before the page number. If we simply put it into
+% \cs{@oddfoot} (in \cs{ps@plain}) its height will not be subtracted
+% from the height of the text and then the page number will be lower
+% than we want. So we do it as an insert.
+%
+% Through version 1.2, this code was included only for \pkg{amsart}
+% and \pkg{amsproc}; the formatting of some book series requires an
+% insert at the bottom of the text block, so this code has been
+% extended to all AMS document classes. [bnb, 1999/07/14]
+% \begin{macrocode}
+\newinsert\copyins
+% \end{macrocode}
+% We set the skip register associated with this insert to the
+% \emph{base-to-base} distance from the bottom of the page contents
+% to the base of the first line in the copyright info. See the
+% definition of \cs{@setcopyright}.
+% \begin{macrocode}
+\skip\copyins=1.5pc
+\count\copyins=1000 % magnification factor, 1000 = 100%
+\dimen\copyins=.5\textheight % maximum allowed per page
+% \end{macrocode}
+% \cn{copyins} is ignored if a float is input on the first page;
+% adding it to \cs{@reinserts} will make the output routine behave.
+% [bnb; 2004/06/09; B-365]
+% \begin{macrocode}
+\g@addto@macro\@reinserts{%
+ \ifvoid\copyins\else\insert\copyins{\unvbox\copyins}\fi
+}
+% \end{macrocode}
+% Put the contents into a \tex/ insert. This information is omitted
+% unless \cs{@serieslogo} is non-null. In other words it will
+% normally not print except when an AMS publication-specific document
+% class such as \cls{tran-l} is used.
+% And even if the series logo is printed, omit the copyright line
+% if requested by |\coprightinfo{}{}|. [bnb, 1996/10/17]
+% \begin{macrocode}
+\def\@copyinsfontsize{\fontsize{6}{7\p@}\normalfont\upshape}
+\newif\if@extracrline \@extracrlinefalse
+\let\@extracrline\@empty
+\relax
+\def\@setcopyright{%
+ \ifx\@empty\@serieslogo
+ \else\ifx\@empty\copyrightyear
+ \else
+ \insert\copyins{\hsize\textwidth
+ \parfillskip\z@\relax
+ \leftskip\z@\@plus.9\textwidth\relax \rightskip\z@\relax
+ \@copyinsfontsize
+% \end{macrocode}
+% The spacing between the preceding text and the copyright info is
+% done with a strut of height |\skip\copyins|. (Note that
+% \cs{lineskip} and \cs{baselineskip} are 0 in the \latex/ output
+% routine.) The negative vskip gives an effective distance of 0 from
+% the top of the box to the base of the first line (assuming
+% |\skip\copyins| is greater than the height of that line). Then the
+% apparent total height of the box will work well with \tex/'s
+% calculations involving |\skip\copyins| for how much room to leave
+% for this object. An extra 6pt is allowed when an additional line
+% is present; this adjustment was found adequate in some borderline
+% cases where tight pages reset with the additional line had text
+% lines moved to the next page, causing the paper length to expand
+% by a page. [bnb, 2004/05/07-06/24]
+% \begin{macrocode}
+ \everypar{}%
+ \vskip-\skip\copyins
+ \if@extracrline
+ \vskip-6pt
+ \fi
+ \nointerlineskip
+ \leavevmode\hfill\vrule\@width\z@\@height\skip\copyins
+ \copyright\copyrightyear\ \copyrightholder\ignorespaces
+ \if@extracrline \@extracrline \fi
+ \par
+% \end{macrocode}
+% This kern of 0pt forces the depth of the last line (if any) to be
+% added to the height of the box.
+% \begin{macrocode}
+ \kern\z@}%
+ \fi\fi
+}
+% \end{macrocode}
+%
+% When \cs{@combinefloats} is called, the box \cs{@outputbox} already
+% contains the main text of the page and any footnotes. Then \latex/
+% adds top and bottom figures. We want to add our copyright info at
+% the very bottom, but still inside of the vbox.
+% \begin{macrocode}
+\def\@combinefloats{%
+ \ifx \@toplist\@empty \else \@cflt \fi
+ \ifx \@botlist\@empty \else \@cflb \fi
+ \ifvoid\copyins \else \@cflci \fi
+}
+% \end{macrocode}
+% \subsubsection{combine-floats-copyright-insert}
+%
+% In the twocolumn/firstcolumn case, postpone adding the drop folio.
+% Put an empty box of the same height at the bottom of the left-hand
+% column to make the columns balance. Allow a smidge of stretch in
+% case the first page of a chapter has no internal stretch, so that
+% the drop folio will be flush to the bottom of the text block;
+% don't do this for a twocolumn page, to avoid an uneven bottom.
+% \begin{macrocode}
+\def\@cflci{%
+ \setbox\@outputbox\vbox{%
+ \unvbox\@outputbox
+ \vskip\skip\copyins
+ \if@twocolumn \else \vskip\z@ plus\p@ \fi
+ \hbox to\columnwidth{%
+ \hss\vbox to\z@{\vss
+% \end{macrocode}
+% In two-column layout, put an empty box in the first column
+% instead of the drop folio.
+% \begin{macrocode}
+ \if@twocolumn
+ \if@firstcolumn \else \unvbox\copyins \fi
+ \else
+ \unvbox\copyins
+ \fi
+ }}}%
+% \end{macrocode}
+% Now redo the insert to make sure we get the right amount of space
+% reserved for it in the second column.
+% \begin{macrocode}
+ \if@twocolumn \if@firstcolumn
+ \insert\copyins{\unvbox\copyins}%
+ \fi\fi
+% \end{macrocode}
+% Reset the \cs{copyins} flag so that a subsequent insert
+% (e.g.\ \cs{@dropfolio} in some book series) will work.
+% \begin{macrocode}
+ \global\count\copyins=999 \relax
+}
+% \end{macrocode}
+% [End of code to support inserts at end of text block.]
+%
+% For journals only, provide a switch that indicates the author has
+% agreed to revert copyright to the public domain; this results in
+% an addition to the copyright block on the article.
+% \begin{macrocode}
+%<*amsart>
+\newif\if@revertcopyright \@revertcopyrightfalse
+\newcommand{\revertcopyright}{%
+ \global\@revertcopyrighttrue
+ \global\@extracrlinetrue}
+% \end{macrocode}
+% Add notation regarding reversion of copyright to public domain if
+% author has agreed to it. Permit this to be set in a different
+% size than the copyright line (required for some author packages).
+% \begin{macrocode}
+\def\@revertcrfontsize{\fontsize{6}{7\p@}\normalfont\upshape}
+\def\@extracrline{%
+ \if@revertcopyright
+ \unskip\\
+ \@revertcrfontsize
+ Reverts to public domain 28 years from publication
+ \fi
+}
+%</amsart>
+% \end{macrocode}
+%
+% \subsection{Other top matter info}
+%
+% Some name setup.
+% \begin{macrocode}
+\newcommand{\abstractname}{Abstract}
+\newcommand{\keywordsname}{Key words and phrases}
+% \end{macrocode}
+% For now, support just the two most recent versions; earlier versions
+% were:
+% \begin{itemize}
+% \item \textup{1980} Mathematics Subject Classification
+% \item \textup{1980} Mathematics Subject Classification
+% \textup{(1985} Revision\textup{)}
+% \end{itemize}
+% Default to the 1991 edition, as that's what is in production at the
+% time this change is made. [bnb, 1999/04/30]
+% \begin{macrocode}
+\newcommand{\subjclassname}{%
+ \textup{1991} Mathematics Subject Classification}
+\@xp\let\csname subjclassname@1991\endcsname \subjclassname
+\@namedef{subjclassname@2000}{%
+ \textup{2000} Mathematics Subject Classification}
+% \end{macrocode}
+% For the date we have a special little problem: We only want to add
+% the `Received by the editors' text for publication-specific
+% document classes such as \cls{tran-l}.
+% \begin{macrocode}
+%<amsbook>\def\@tempb{amsbook}
+%<amsproc>\def\@tempb{amsproc}
+%<amsart>\def\@tempb{amsart}
+\ifx\@classname\@tempb
+ \newcommand{\datename}{\textit{Date}:}
+\else
+ \newcommand{\datename}{Received by the editors}
+\fi
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\@settitle{\begin{center}%
+%<amsart> \baselineskip14\p@\relax
+%<amsproc> \Large
+ \bfseries
+%<amsart>\uppercasenonmath\@title
+ \@title
+ \end{center}%
+}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% For multiple authors we need to combine the author names into a
+% list of the form Author One, Author Two, \dots, and Author Last.
+% Change line breaking penalties to avoid a line break in the middle of
+% an author name if there are a lot of authors. This should probably
+% better be done by changing spaces within author names to
+% |\nolinebreak[3]\space|, but that would take more work.
+% [mjd,2000/12/27]
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\author@andify{%
+ \nxandlist {\unskip ,\penalty-1 \space\ignorespaces}%
+ {\unskip {} \@@and~}%
+ {\unskip ,\penalty-2 \space \@@and~}%
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\@setauthors{%
+ \begingroup
+ \def\thanks{\protect\thanks@warning}%
+ \trivlist
+%<amsart> \centering\footnotesize \@topsep30\p@\relax
+%<amsart> \advance\@topsep by -\baselineskip
+%<amsproc> \centering \fontsize{11}{13\p@}\selectfont\@topsep13\p@\relax
+ \item\relax
+ \author@andify\authors
+% \end{macrocode}
+% Make dbl-backslash robust to prevent problems if/when
+% \cs{MakeTextUppercase} expansion is applied.
+% \begin{macrocode}
+ \def\\{\protect\linebreak}%
+%<amsart> \MakeUppercase{\authors}%
+%<amsproc> \authors
+ \ifx\@empty\contribs
+ \else
+ ,\penalty-3 \space \@setcontribs
+ \@closetoccontribs
+ \fi
+ \endtrivlist
+ \endgroup
+}
+\def\@closetoccontribs{}
+\def\@setcontribs{%
+ \@xcontribs
+%<amsart> \MakeUppercase{\xcontribs}%
+%<amsproc> \xcontribs
+}
+\def\@setdate{\datename\ \@date\@addpunct.}
+\def\@setsubjclass{%
+ {\itshape\subjclassname.}\enspace\@subjclass\@addpunct.}
+\def\@setkeywords{%
+ {\itshape \keywordsname.}\enspace \@keywords\@addpunct.}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% The following definitions suffice for all the AMS document classes.
+% \begin{macrocode}
+\def\@setthanks{\def\thanks##1{\par##1\@addpunct.}\thankses}
+% \end{macrocode}
+%
+% `Abstract' can be changed to, say, `R\'esum\'e' (French) by
+% redefining \cn{abstractname}. This and other control sequence names
+% (\cn{refname}, \cn{contentsname}, \cn{appendixname}, and so on) are
+% compatible with the \pkg{babel} package (the AMS sometimes
+% publishes articles in languages other than English.)
+%
+% In AMS document classes, the abstract should be placed before
+% \cn{maketitle} (otherwise the desired ordering of frontmatter
+% elements cannot be ensured in all cases).
+% \begin{macrocode}
+\newbox\abstractbox
+% \end{macrocode}
+% We start by checking whether \cn{maketitle} has already been used
+% (in which case it was reset to \cs{relax}); if so, we give a
+% warning that the abstract should be placed before \cn{maketitle}.
+% \begin{macrocode}
+\newenvironment{abstract}{%
+ \ifx\maketitle\relax
+ \ClassWarning{\@classname}{Abstract should precede
+ \protect\maketitle\space in AMS document classes; reported}%
+ \fi
+ \global\setbox\abstractbox=\vtop \bgroup
+ \normalfont\Small
+ \list{}{\labelwidth\z@
+ \leftmargin3pc \rightmargin\leftmargin
+ \listparindent\normalparindent \itemindent\z@
+ \parsep\z@ \@plus\p@
+% \end{macrocode}
+% In order to get equation numbers indented with the rest of the
+% abstract, we have to do this:
+% \begin{macrocode}
+ \let\fullwidthdisplay\relax
+ }%
+ \item[\hskip\labelsep\scshape\abstractname.]%
+}{%
+ \endlist\egroup
+% \end{macrocode}
+% If the abstract was supposed to be typeset earlier, then
+% \cs{@setabstract} is now equal to \cs{relax}, and we had better
+% drop the contents of the abstract box onto the page immediately, to
+% salvage the situation as best we can.
+% \begin{macrocode}
+ \ifx\@setabstract\relax \@setabstracta \fi
+}
+% \end{macrocode}
+%
+% Because the abstract might be postponed until the end of an
+% article, we cannot simply use the fact of a preceding
+% \cn{maketitle} to tell whether \cs{endabstract} should immediately
+% put the abstract box contents on the page. So we use an auxiliary
+% function that will be reset to no-op once we have passed the point
+% where the abstract should normally be typeset.
+% \begin{macrocode}
+\def\@setabstract{\@setabstracta \global\let\@setabstract\relax}
+\def\@setabstracta{%
+ \ifvoid\abstractbox
+ \else
+ \skip@20\p@ \advance\skip@-\lastskip
+ \advance\skip@-\baselineskip \vskip\skip@
+ \box\abstractbox
+ \prevdepth\z@ % because \abstractbox is a vtop
+ \fi
+}
+% \end{macrocode}
+%
+% Title page environment does nothing much; information and
+% formatting to be provided by the user.
+% \begin{macrocode}
+\def\titlepage{%
+%<amsbook> \cleardoublepage
+%<amsart|amsproc> \clearpage
+ \thispagestyle{empty}\setcounter{page}{0}}
+\def\endtitlepage{\newpage}
+% \end{macrocode}
+%
+% \subsection{Macros for list labels}
+%
+% Through version 1.2, first-level enumerated item labels were formatted
+% with a following period, which is not AMS style. Effective with
+% version 2.0 these labels are formatted with parentheses. Anyone
+% requiring the period style will have to redefine \cs{labelenumi}.
+% \begin{macrocode}
+\def\labelenumi{(\theenumi)}
+\def\theenumi{\@arabic\c@enumi}
+\def\labelenumii{(\theenumii)}
+\def\theenumii{\@alph\c@enumii}
+\def\p@enumii{\theenumi}
+\def\labelenumiii{(\theenumiii)}
+\def\theenumiii{\@roman\c@enumiii}
+\def\p@enumiii{\theenumi(\theenumii)}
+\def\labelenumiv{(\theenumiv)}
+\def\theenumiv{\@Alph\c@enumiv}
+\def\p@enumiv{\p@enumiii\theenumiii}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\labelitemi{$\m@th\bullet$}
+\def\labelitemii{\bfseries --}% \upshape already done by \itemize
+\def\labelitemiii{$\m@th\ast$}
+\def\labelitemiv{$\m@th\cdot$}
+% \end{macrocode}
+%
+% \subsection{Verse and quotation environments}
+% \begin{macrocode}
+\newenvironment{verse}{\let\\\@centercr
+ \list{}{\itemsep\z@ \itemindent -1.5em\listparindent\itemindent
+ \rightmargin\leftmargin \advance\leftmargin 1.5em}\item[]%
+}{%
+ \endlist
+}
+\let\endverse=\endlist % for efficiency
+% \end{macrocode}
+% The left/right margins of the quotation environment are supposed to
+% be the same as for the abstract environment.
+% \begin{macrocode}
+\newenvironment{quotation}{\list{}{%
+ \leftmargin3pc \listparindent\normalparindent
+ \itemindent\z@
+ \rightmargin\leftmargin \parsep\z@ \@plus\p@}%
+ \item[]%
+}{%
+ \endlist
+}
+\let\endquotation=\endlist % for efficiency
+\newenvironment{quote}{%
+ \list{}{\rightmargin\leftmargin}\item[]%
+}{%
+ \endlist
+}
+\let\endquote=\endlist % for efficiency
+% \end{macrocode}
+%
+% \subsection{List environments}
+% Changed definition of \cs{trivlist}, \env{enumerate}, and
+% \env{itemize} in order to have \cn{makelabel} apply \cn{upshape}.
+% \begin{macrocode}
+\def\trivlist{\parsep\parskip\@nmbrlistfalse
+ \@trivlist \labelwidth\z@ \leftmargin\z@
+ \itemindent\z@
+ \let\@itemlabel\@empty
+ \def\makelabel##1{\upshape##1}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\renewenvironment{enumerate}{%
+ \ifnum \@enumdepth >3 \@toodeep\else
+ \advance\@enumdepth \@ne
+ \edef\@enumctr{enum\romannumeral\the\@enumdepth}\list
+ {\csname label\@enumctr\endcsname}{\usecounter
+ {\@enumctr}\def\makelabel##1{\hss\llap{\upshape##1}}}\fi
+}{%
+ \endlist
+}
+\let\endenumerate=\endlist % for efficiency
+% \end{macrocode}
+%
+% \begin{macrocode}
+\renewenvironment{itemize}{%
+ \ifnum\@itemdepth>3 \@toodeep
+ \else \advance\@itemdepth\@ne
+ \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
+ \list{\csname\@itemitem\endcsname}%
+ {\def\makelabel##1{\hss\llap{\upshape##1}}}%
+ \fi
+}{%
+ \endlist
+}
+\let\enditemize=\endlist % for efficiency
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newcommand{\descriptionlabel}[1]{\hspace\labelsep \upshape\bfseries #1:}
+\newenvironment{description}{\list{}{%
+% \end{macrocode}
+% Adjust the indent of the first line to the desired value:
+% \begin{macrocode}
+ \advance\leftmargini6\p@ \itemindent-12\p@
+ \labelwidth\z@ \let\makelabel\descriptionlabel}%
+}{
+ \endlist
+}
+\let\enddescription=\endlist % for efficiency
+% \end{macrocode}
+%
+% \begin{macro}{\upn}
+% The command \cn{upn} can be used to force upright font for
+% punctuation or digits in italic text. For example
+%\begin{verbatim}
+% ... as numbered by \upn{``A''} or \upn{``1''} hereafter\upn{)}
+%\end{verbatim}
+% \begin{macrocode}
+\let\upn=\textup
+% \end{macrocode}
+% \end{macro}
+%
+% Since these margin settings are dependent on the fonts used, we
+% postpone them until begin-document. (This means that we cannot use
+% the values directly for calculations before begin-document.) Allow
+% for a reasonable maximum value; 13 = xiii = m should be adequate.
+% \begin{macrocode}
+\AtBeginDocument{%
+ \labelsep=5pt\relax
+ \setcounter{enumi}{13}\setcounter{enumii}{13}%
+ \setcounter{enumiii}{13}\setcounter{enumiv}{13}%
+ \settowidth\leftmargini{\labelenumi\hskip\labelsep}%
+ \advance\leftmargini by \normalparindent
+ \settowidth\leftmarginii{\labelenumii\hskip\labelsep}%
+ \settowidth\leftmarginiii{\labelenumiii\hskip\labelsep}%
+ \settowidth\leftmarginiv{\labelenumiv\hskip\labelsep}%
+ \setcounter{enumi}{0}\setcounter{enumii}{0}%
+ \setcounter{enumiii}{0}\setcounter{enumiv}{0}%
+ \leftmarginv=10pt \leftmarginvi=\leftmarginv
+ \leftmargin=\leftmargini
+ \labelwidth=\leftmargini \advance\labelwidth-\labelsep
+ \@listi}
+% \end{macrocode}
+%
+% In some contexts the space above/below lists needs to be
+% suppressed. So we put it into a variable \cs{listisep}.
+% \begin{macrocode}
+\newskip\listisep
+\listisep\smallskipamount
+\def\@listI{\leftmargin\leftmargini \parsep\z@skip
+ \topsep\listisep \itemsep\z@skip
+ \listparindent\normalparindent}
+\let\@listi\@listI
+% \end{macrocode}
+%
+% Is it necessary to reset \cs{parsep}, \cs{partopsep}, \cs{itemsep}
+% to their default values (0) in each of the subordinate list
+% setup functions? I don't believe so, but I leave the settings in
+% the listii function just in case some unusual nesting of
+% environments might cause trouble. [mjd,1994/09/22]
+% \begin{macrocode}
+\def\@listii{\leftmargin\leftmarginii
+ \labelwidth\leftmarginii \advance\labelwidth-\labelsep
+ \topsep\z@skip \parsep\z@skip \partopsep\z@skip \itemsep\z@skip}
+\def\@listiii{\leftmargin\leftmarginiii
+ \labelwidth\leftmarginiii \advance\labelwidth-\labelsep}
+\def\@listiv{\leftmargin\leftmarginiv
+ \labelwidth\leftmarginiv \advance\labelwidth-\labelsep}
+\def\@listv{\leftmargin\leftmarginv
+ \labelwidth\leftmarginv \advance\labelwidth-\labelsep}
+\def\@listvi{\leftmargin\leftmarginvi
+ \labelwidth\leftmarginvi \advance\labelwidth-\labelsep}
+% \end{macrocode}
+%
+% \subsection{Fleqn option}
+%
+% \begin{macrocode}
+\@ifclasswith{\@classname}{fleqn}{%
+ \let\@tempa\@iden
+ \AtBeginDocument{\mathindent\leftmargini}%
+}{\let\@tempa\@gobble}%
+\@ifpackageloaded{amsmath}{\let\@tempa\@gobble}{%
+ \@ifpackageloaded{amstex}{\let\@tempa\@gobble}{}%
+}
+\@tempa{%
+ \def\[{\relax
+ \ifmmode\@badmath
+ \else
+ \begin{trivlist}%
+ \@beginparpenalty\predisplaypenalty
+ \@endparpenalty\postdisplaypenalty
+ \item[]\leavevmode
+ \hbox to\linewidth\bgroup$\displaystyle
+% \end{macrocode}
+% Note that the \cs{m@th} should go at the end in \cn{]} just in
+% case an embedded small math formula inside \cn{text} occurs in
+% the display.
+%
+% Why the extra bgroup here? I think it's not needed.
+% [mjd,3-Feb-1994]
+% \begin{macrocode}
+ \hskip\mathindent\bgroup
+ \fi}%
+ \def\]{\relax
+ \ifmmode
+ \egroup \m@th$\hfil \egroup
+ \end{trivlist}%
+ \else \@badmath
+ \fi}%
+ \renewenvironment{equation}{%
+ \@beginparpenalty\predisplaypenalty
+ \@endparpenalty\postdisplaypenalty
+ \refstepcounter{equation}%
+ \@topsep\abovedisplayskip \trivlist
+ \item[]\leavevmode
+ \hbox to\linewidth\bgroup\hskip\mathindent$\displaystyle
+ }{%
+ \m@th$\hfil \displaywidth\linewidth \hbox{\@eqnnum}\egroup
+ \endtrivlist
+ }%
+ \renewenvironment{eqnarray}{%
+ \stepcounter{equation}\let\@currentlabel\theequation
+ \global\@eqnswtrue \global\@eqcnt\z@ \tabskip\mathindent
+ \let\\=\@eqncr \abovedisplayskip\topsep
+ \ifvmode \advance\abovedisplayskip\partopsep \fi
+ \belowdisplayskip\abovedisplayskip
+ \belowdisplayshortskip\abovedisplayskip
+ \abovedisplayshortskip\abovedisplayskip
+ $$\everycr{}\halign to\linewidth\bgroup
+ \hskip\@centering
+ $\displaystyle\tabskip\z@skip####\m@th$&%
+ \@eqnsel \global\@eqcnt\@ne
+ \hfil${}####{}\m@th$\hfil&%
+ \global\@eqcnt\tw@
+ $\displaystyle ####\m@th$\hfil\tabskip\@centering&%
+ \global\@eqcnt\thr@@
+ \hbox to \z@\bgroup\hss####\egroup\tabskip\z@skip\cr
+ }{%
+ \@@eqncr \egroup \global\advance\c@equation\m@ne$$%
+ \global\@ignoretrue
+ }%
+ \newdimen\mathindent
+ \mathindent\leftmargini
+}
+% \end{macrocode}
+%
+% \subsection{Redefined internal sectioning commands}
+%
+% In amsart.sty \cs{@startsection}, \cs{@sect},
+% and a couple of other things are redefined to fix a few hard-coded
+% things that would interfere with the desired style. The most
+% noteworthy difference is that all section headings will go into the
+% table of contents (governed by secnumdepth as usual), EVEN WHEN THE
+% |*| FORM IS USED. The only section heading not listed in the table of
+% contents is the heading for the toc itself.
+%
+% A second major departure from standard \latex/ is that when a
+% short form of a section title is given, it is used only for the
+% running heads; the table of contents still gets the full version of
+% the title. This is correct for AMS editorial practice. However if
+% one wants to get a line break into the table of contents it means
+% that the standard \latex/ method cannot be used. See the
+% \cn{except} and \cn{for} commands.
+% \begin{macrocode}
+\def\@startsection#1#2#3#4#5#6{%
+% \end{macrocode}
+% Section titles, if they are run-in with the following text, are
+% stored in a box instead of being typeset right away. They will be
+% typeset by \cs{everypar}, but if one section heading follows
+% right after another, this won't happen. So by doing
+% \cs{leavevmode} we force this to happen. (\cs{if@noskipsec}
+% is true if the previous section title has not yet been typeset.)
+% \begin{macrocode}
+ \if@noskipsec \leavevmode \fi
+ \par \@tempskipa #4\relax
+ \@afterindenttrue
+ \ifdim \@tempskipa <\z@ \@tempskipa -\@tempskipa \@afterindentfalse\fi
+ \if@nobreak \everypar{}\else
+ \addpenalty\@secpenalty\addvspace\@tempskipa\fi
+% Don't call \@ssect in the ifstar case:
+ \@ifstar{\@dblarg{\@sect{#1}{\@m}{#3}{#4}{#5}{#6}}}%
+ {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}%
+}
+% \end{macrocode}
+%
+% We add \cn{textup} here in order to make section
+% numbers always roman, even if the rest of the section head is
+% italic.
+% \begin{macrocode}
+\def\@seccntformat#1{%
+ \protect\textup{\protect\@secnumfont
+ \csname the#1\endcsname
+ \protect\@secnumpunct
+ }%
+}
+% \end{macrocode}
+%
+% Some journals require a different font for section numbers. (As
+% coded here, this option permits only a change of weight, to
+% \cn{bfseries}.) The \cls{amsart} font is checked again later,
+% when processing \cn{section}, and if there is no section title,
+% it is made bold.
+% \begin{macrocode}
+%<amsbook|amsproc>\let\@secnumfont\@empty
+%<amsart>\def\@secnumfont{\mdseries}
+% \end{macrocode}
+%
+% For reference, here is the argument list for \cs{@sect}.
+%\begin{verbatim}
+% % #1 #2 #3 #4 #5 #6 #7 #8
+% {NAME}{LEVEL}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}[SHORTT]{TITLE}
+%\end{verbatim}
+% \begin{macrocode}
+\def\@sect#1#2#3#4#5#6[#7]#8{%
+% \end{macrocode}
+% Define \cs{@toclevel} for for \cs{@tocwrite} (to
+% \cs{@tochangmeasure}).
+% \begin{macrocode}
+ \edef\@toclevel{\ifnum#2=\@m 0\else\number#2\fi}%
+ \ifnum #2>\c@secnumdepth \let\@secnumber\@empty
+ \else \@xp\let\@xp\@secnumber\csname the#1\endcsname\fi
+% \end{macrocode}
+% If the value of afterskip $>0$, then this is not a run-in section
+% heading, and we want to suppress final punctuation.
+% \begin{macrocode}
+ \@tempskipa #5\relax
+% \end{macrocode}
+% \cs{@svsec} will be the section number plus some formatting if
+% the star form was not used and if the depth of numbering extends to
+% the current level. The user can change secnumdepth to control how
+% many levels of sectioning will be numbered.
+% \begin{macrocode}
+ \ifnum #2>\c@secnumdepth
+ \let\@svsec\@empty
+ \else
+ \refstepcounter{#1}%
+% \end{macrocode}
+% If the section heading is not run-in and there is no title, omit
+% final punctuation and space. If it is run-in, omit extra space.
+% \begin{macrocode}
+ \edef\@secnumpunct{%
+ \ifdim\@tempskipa>\z@ % not a run-in section heading
+ \@ifnotempty{#8}{.\@nx\enspace}%
+ \else
+ \@ifempty{#8}{.}{.\@nx\enspace}%
+ \fi
+ }%
+% \end{macrocode}
+% For \cls{amsart}, if a subsection has no title, make the section
+% number bold; otherwise leave it alone.
+% [bnb; 2004/06/08; per vwa, B-442]
+% \begin{macrocode}
+%<amsart> \@ifempty{#8}{%
+%<amsart> \ifnum #2=\tw@ \def\@secnumfont{\bfseries}\fi}{}%
+% \end{macrocode}
+% If the |*|-form was not used (\arg{2} less than 1000), we add
+% \cn{sectionname} or whatever as a prefix, separated by a space.
+% We need the ifundefined test in order to know whether the space
+% should be added or not. There must be a better way to do this
+% but I haven't thought of it yet.
+% \begin{macrocode}
+ \protected@edef\@svsec{%
+ \ifnum#2<\@m
+ \@ifundefined{#1name}{}{%
+ \ignorespaces\csname #1name\endcsname\space
+ }%
+ \fi
+ \@seccntformat{#1}%
+ }%
+ \fi
+ \ifdim \@tempskipa>\z@ % then this is not a run-in section heading
+ \begingroup #6\relax
+ \@hangfrom{\hskip #3\relax\@svsec}{\interlinepenalty\@M #8\par}%
+ \endgroup
+% \end{macrocode}
+%
+% Section headings don't set marks for the running heads in the article
+% style, only in the amsbook style. Assumption: \cs{sectionmark} is
+% defined to call \cs{@secnumber} as its penultimate argument.
+% \begin{macrocode}
+%<amsbook> \csname #1mark\endcsname{#7}%
+% \end{macrocode}
+% If \arg{2} (level) is greater than 1000 then we don't do a table
+% of contents entry. This happens only for the section heading above
+% the table of contents itself.
+% \begin{macrocode}
+ \ifnum#2>\@m \else \@tocwrite{#1}{#8}\fi
+ \else
+% \end{macrocode}
+% Otherwise we're doing a run-in heading; it is stored as \cs{@svsechd},
+% which will be typeset by \cs{everypar} as soon as some text is
+% encountered.
+% \begin{macrocode}
+ \def\@svsechd{#6\hskip #3\@svsec
+% \end{macrocode}
+% To allow for the possibility that the user wants an empty section
+% title, leaving just the section number, we check whether \arg{8}
+% is nonempty before adding the period.
+% \begin{macrocode}
+ \@ifnotempty{#8}{\ignorespaces#8\unskip
+% \end{macrocode}
+% The following test is to prevent a period being added if the
+% section title ended in a question mark or other punctuation.
+% \begin{macrocode}
+ \@addpunct.}%
+ \ifnum#2>\@m \else \@tocwrite{#1}{#8}\fi
+ }%
+ \fi
+% \end{macrocode}
+% In a previous version of \cls{amsart} \cs{@nobreaktrue} was added to
+% \cs{@xsect} for some reason. Let's keep that just in case it was done to
+% prevent a certain kind of bug. [mjd,17-Aug-1994]
+% \begin{macrocode}
+ \global\@nobreaktrue
+% \end{macrocode}
+% \cs{@xsect} does some more stuff based on whether this is a run-in
+% heading or not.
+% \begin{macrocode}
+ \@xsect{#5}}
+% \end{macrocode}
+%
+% Undefine \cs{@ssect} to save memory; it's not needed in \cls{amsart}.
+% \begin{macrocode}
+\let\@ssect\relax
+% \end{macrocode}
+%
+% \subsection{Chapters and sections}
+% Allocate counters for sectioning commands. Paragraph and subparagraph
+% counters are allocated but normally not used.
+% \begin{macrocode}
+\newcounter{part}
+%<amsbook>\newcounter{chapter}
+%<amsproc|amsart>\newcounter{section}
+%<amsbook>\newcounter{section}[chapter]
+%<amsbook>\def\thesection{\arabic{section}}
+\newcounter{subsection}[section]
+\newcounter{subsubsection}[subsection]
+\newcounter{paragraph}[subsubsection]
+\newcounter{subparagraph}[paragraph]
+% \end{macrocode}
+% Set numbering style for sectioning commands. In a couple of cases
+% resetting is unnecessary but we include the full list here for
+% completeness.
+% \begin{macrocode}
+\renewcommand\thepart {\arabic{part}}
+%<amsbook>\renewcommand\thechapter {\arabic{chapter}}
+\renewcommand\thesection {\arabic{section}}
+\renewcommand\thesubsection {\thesection.\arabic{subsection}}
+\renewcommand\thesubsubsection {\thesubsection .\arabic{subsubsection}}
+\renewcommand\theparagraph {\thesubsubsection.\arabic{paragraph}}
+\renewcommand\thesubparagraph {\theparagraph.\arabic{subparagraph}}
+% \end{macrocode}
+% Depth of section numbering; if \fn{secnumdepth} were 2 instead of
+% 3, \cn{subsubsection} would not be numbered.
+% \begin{macrocode}
+\setcounter{secnumdepth}{3}
+% \end{macrocode}
+%
+% The arguments of \cs{@startsection} are given for reference:
+%\begin{verbatim}
+% % #1 #2 #3 #4 #5 #6
+% {NAME}{LEVEL}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}
+%\end{verbatim}
+%
+% \begin{macrocode}
+\def\partname{Part}
+%<*amsart|amsproc>
+\def\part{\@startsection{part}{0}%
+ \z@{\linespacing\@plus\linespacing}{.5\linespacing}%
+ {\normalfont\bfseries\raggedright}}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% Specialsection correlates to our inhouse Z-head.
+% \begin{macrocode}
+\def\specialsection{\@startsection{section}{1}%
+%<amsart> \z@{\linespacing\@plus\linespacing}{.5\linespacing}%
+%<amsproc|amsbook> \z@{2\linespacing\@plus\linespacing}{.5\linespacing}%
+%<amsart> {\normalfont\centering}}
+%<amsproc|amsbook> {\large\scshape\centering}}
+% \end{macrocode}
+%
+% In the book class \cn{part} puts the part title on a separate
+% page.
+% \begin{macrocode}
+%<*amsbook>
+\def\part{\cleardoublepage \thispagestyle{empty}%
+ \null\vfil \markboth{}{}\secdef\@part\@spart}
+%
+\def\@part[#1]#2{%
+ \ifnum \c@secnumdepth >-2\relax \refstepcounter{part}%
+ \addcontentsline{toc}{part}{\partname\ \thepart.
+ \protect\enspace\protect\noindent#1}%
+ \else
+ \addcontentsline{toc}{part}{#1}\fi
+ \begingroup\centering
+ \ifnum \c@secnumdepth >-2\relax
+ {\fontsize{\@xviipt}{22}\bfseries
+ \partname\ \thepart} \vskip 20\p@ \fi
+ \fontsize{\@xxpt}{25}\bfseries
+ #1\vfil\vfil\endgroup \newpage\thispagestyle{empty}}
+
+\def\@spart#1{\addcontentsline{toc}{part}{\protect\noindent#1}%
+ \begingroup\centering
+ \fontsize{\@xxpt}{25}\bfseries
+ #1\vfil\vfil\endgroup \newpage\thispagestyle{empty}}
+%</amsbook>
+% \end{macrocode}
+%
+% The arguments of \cs{partrunhead} are \cs{partname},
+% \cs{thepart}, and the text of the part title. The first two were
+% fully expanded during the marking process. Use of a mere
+% interword space between the first two args makes it possible
+% to apply \cn{ignorespaces} and \cn{unskip} as shown here
+% to produce the desired results if one or the other is empty.
+% \begin{macrocode}
+%<*amsbook>
+\def\partrunhead#1#2#3{%
+ \@ifnotempty{#2}{\uppercase{\ignorespaces#1 #2\unskip}\@ifnotempty{#3}{. }}%
+ \def\@tempa{#3}%
+ \ifx\@empty\@tempa\else
+ \begingroup \def\\{ \ignorespaces}% defend against questionable usage
+ \uppercasenonmath\@tempa\@tempa
+ \endgroup
+ \fi
+}
+\let\chapterrunhead\partrunhead
+\let\sectionrunhead\partrunhead
+%</amsbook>
+% \end{macrocode}
+%
+% Section headings in the amsbook style differ from the amsart
+% style in a couple of ways: The ones that aren't centered are
+% indented on the left, instead of flush left; and the first
+% level, \cn{section}, is not small caps but bold.
+% Cf.~the definition of \cn{appendix}.
+% \begin{macrocode}
+\def\section{\@startsection{section}{1}%
+ \z@{.7\linespacing\@plus\linespacing}{.5\linespacing}%
+%<amsart> {\normalfont\scshape\centering}}
+%<amsbook|amsproc> {\normalfont\bfseries\centering}}
+% \end{macrocode}
+%
+% Negative value for \arg{5} is a signal to make a run-in heading instead
+% of doing a vskip after the heading.
+% \begin{macrocode}
+\def\subsection{\@startsection{subsection}{2}%
+%<amsart> \z@{.5\linespacing\@plus.7\linespacing}{-.5em}%
+%<amsbook|amsproc> \normalparindent{.5\linespacing\@plus.7\linespacing}{-.5em}%
+ {\normalfont\bfseries}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\subsubsection{\@startsection{subsubsection}{3}%
+%<amsart> \z@{.5\linespacing\@plus.7\linespacing}{-.5em}%
+%<amsbook|amsproc> \normalparindent\z@{-.5em}%
+ {\normalfont\itshape}}
+% \end{macrocode}
+%
+% Fontdimen 2 of the current font is the ideal interword space of the
+% font. Thus the following spec says that the space after the
+% paragraph heading should be a normal interword space (but
+% nonstretching and nonshrinking).
+% \begin{macrocode}
+\def\paragraph{\@startsection{paragraph}{4}%
+%<amsart> \z@\z@{-\fontdimen2\font}%
+%<amsbook|amsproc> \normalparindent\z@{-\fontdimen2\font}%
+ \normalfont}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\subparagraph{\@startsection{subparagraph}{5}%
+ \z@\z@{-\fontdimen2\font}%
+ \normalfont}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*amsart|amsproc>
+\def\appendix{\par\c@section\z@ \c@subsection\z@
+ \let\sectionname\appendixname
+ \def\thesection{\@Alph\c@section}}
+\def\appendixname{Appendix}
+%</amsart|amsproc>
+% \end{macrocode}
+%
+% A slower, but fully expandable definition of \cs{@Roman} to avoid
+% the nonexpandable \cn{uppercase} which is undesirable in certain
+% circumstances.
+% \begin{macrocode}
+\def\@Roman#1{\@xp\@slowromancap
+ \romannumeral#1@}%
+%
+\def\@slowromancap#1{\ifx @#1% then terminate
+ \else
+% \end{macrocode}
+% Note: \cs{if} is required here, not \cs{ifx}, because
+% \cs{romannumeral} returns category 12 letters!
+% \begin{macrocode}
+ \if i#1I\else\if v#1V\else\if x#1X\else\if l#1L\else\if
+ c#1C\else\if m#1M\else#1\fi\fi\fi\fi\fi\fi
+ \@xp\@slowromancap
+ \fi
+}
+% \end{macrocode}
+%
+% \subsection{Book features}
+% Books (monographs) comprise three distinct sections,
+% \cn{frontmatter}, \cn{mainmatter}, and \cn{backmatter}. The
+% \cn{frontmatter} would consist of the title page, copyright page,
+% table of contents, preface, etc. The \cn{mainmatter} would
+% be the body of the book. The \cn{backmatter} would include the
+% appendix, bibliography, glossary, and index.
+% \begin{macrocode}
+%<*amsbook>
+\def\frontmatter{\cleardoublepage\pagenumbering{roman}}
+\def\mainmatter{\cleardoublepage\pagenumbering{arabic}}
+\def\backmatter{%
+ \if@openright\cleardoublepage\else\clearpage\fi
+ \let\chaptername\relax}
+%</amsbook>
+% \end{macrocode}
+%
+% Book proceedings and monographs allow a signature to print at the
+% end of a preface.
+% \begin{macrocode}
+%<*!amsart>
+\def\aufm#1{\par\vspace*{12pt}{\flushright #1\par}}
+%</!amsart>
+% \end{macrocode}
+%
+% Monographs can have a special exercise environment.
+%
+% \begin{macrocode}
+%<*amsbook>
+\newenvironment{xcb}{%
+ \setcounter{enumi}{0}%
+ \settowidth{\leftmargini}{\labelenumi\hskip\labelsep}%
+ \setcounter{enumii}{4}% letter d
+ \settowidth{\leftmarginii}{\labelenumii\hskip\labelsep}%
+ \@startsection{section}% counter name; ignored because of the
+ % * below
+ {1}% sectioning level
+ {\z@}% indent to the left of the section title
+ {18\p@\@plus2\p@}% vertical space above
+ {1sp}% Space below of 13pt base-to-base, so none needs to be added
+ % here; but \z@ would cause the following text to be run-in, so we
+ % use 1sp instead.
+ {\bfseries}% The font of the subsection title
+ *% always unnumbered
+}{%
+ \par
+}
+%</amsbook>
+% \end{macrocode}
+%
+% \subsection{Book chapters}
+% The \cn{chapter} command is provided only in the \cls{amsbook} class,
+% not in \cls{amsart} or \cls{amsproc}.
+% \begin{macrocode}
+%<*amsbook>
+\def\chapter{%
+ \if@openright\cleardoublepage\else\clearpage\fi
+ \thispagestyle{plain}\global\@topnum\z@
+ \@afterindenttrue \secdef\@chapter\@schapter}
+% \end{macrocode}
+% \cs{@chapter} for numbered chapters.
+% \begin{macrocode}
+\def\@chapter[#1]#2{\refstepcounter{chapter}%
+ \ifnum\c@secnumdepth<\z@ \let\@secnumber\@empty
+ \else \let\@secnumber\thechapter \fi
+ \typeout{\chaptername\space\@secnumber}%
+ \def\@toclevel{0}%
+ \ifx\chaptername\appendixname \@tocwriteb\tocappendix{chapter}{#2}%
+ \else \@tocwriteb\tocchapter{chapter}{#2}\fi
+ \chaptermark{#1}%
+ \addtocontents{lof}{\protect\addvspace{10\p@}}%
+ \addtocontents{lot}{\protect\addvspace{10\p@}}%
+ \@makechapterhead{#2}\@afterheading}
+% \end{macrocode}
+% \cs{@schapter} for unnumbered chapters.
+% \begin{macrocode}
+\def\@schapter#1{\typeout{#1}%
+ \let\@secnumber\@empty
+ \def\@toclevel{0}%
+ \ifx\chaptername\appendixname \@tocwriteb\tocappendix{chapter}{#1}%
+ \else \@tocwriteb\tocchapter{chapter}{#1}\fi
+ \chaptermark{#1}%
+ \addtocontents{lof}{\protect\addvspace{10\p@}}%
+ \addtocontents{lot}{\protect\addvspace{10\p@}}%
+ \@makeschapterhead{#1}\@afterheading}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newcommand\chaptername{Chapter}
+\newcommand\appendixname{Appendix}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\@makechapterhead#1{\global\topskip 7.5pc\relax
+ \begingroup
+ \fontsize{\@xivpt}{18}\bfseries\centering
+% \end{macrocode}
+% In order to keep the chapter number ``CHAPTER III'' from
+% getting in the way of the \cs{topskip} we put it inside
+% the paragraph containing the main title. Then we have to
+% do some laborious \cs{rlap}ing and \cs{hskip}ing to
+% position it correctly.
+% \begin{macrocode}
+ \ifnum\c@secnumdepth>\m@ne
+ \leavevmode \hskip-\leftskip
+ \rlap{\vbox to\z@{\vss
+ \centerline{\normalsize\mdseries
+ \uppercase\@xp{\chaptername}\enspace\thechapter}
+ \vskip 3pc}}\hskip\leftskip\fi
+ #1\par \endgroup
+ \skip@34\p@ \advance\skip@-\normalbaselineskip
+ \vskip\skip@ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\@makeschapterhead#1{\global\topskip 7.5pc\relax
+ \begingroup
+ \fontsize{\@xivpt}{18}\bfseries\centering
+ #1\par \endgroup
+ \skip@34\p@ \advance\skip@-\normalbaselineskip
+ \vskip\skip@ }
+%</amsbook>
+% \end{macrocode}
+% The \cn{appendix} command, following the \latex/ book, marks the
+% start of a division after \cn{mainmatter} and before
+% \cn{backmatter} that consists of appendixes.
+% \begin{macrocode}
+%<*amsbook>
+\def\appendix{\par
+ \c@chapter\z@ \c@section\z@
+ \let\chaptername\appendixname
+ \def\thechapter{\@Alph\c@chapter}}
+%</amsbook>
+% \end{macrocode}
+%
+% \subsection{Table of contents macros}
+%
+% \cn{tableofcontents} is like \cn{chapter} or \cn{section} except
+% for no number and no table of contents entry.
+%
+% \cs{@pnumwidth} is the maximum width for page numbers in a table of
+% contents. |1.6em| allows enough room for three digits.
+% \begin{macrocode}
+\newcommand{\@pnumwidth}{1.6em}
+% \end{macrocode}
+% \cs{@tocrmarg} is \cs{@pnumwidth} plus the desired minimum
+% space (|1em|) between page numbers and the preceding text.
+% \begin{macrocode}
+\newcommand{\@tocrmarg}{2.6em}
+%<amsart>\setcounter{tocdepth}{2}
+%<amsbook|amsproc>\setcounter{tocdepth}{1}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newswitch{toc}
+\newswitch{lof}
+\newswitch{lot}
+% \end{macrocode}
+%
+% Since table of contents, list of figures and list of figures
+% are identical in design as far as the chapter heading and other
+% preliminaries go, we redefine \cs{@starttoc} to do the necessary
+% work, rather than defining a new macro (which would use up another
+% control sequence name).
+%
+% We define first the article form of \cs{@starttoc}, then the book
+% form.
+%
+% Owing to confusion about what font to use for \cn{contentsname}, a
+% symbolic name has been assigned to provide flexibility.
+% \begin{macrocode}
+%<*amsart|amsproc>
+\newcommand\contentsnamefont{\scshape}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\@starttoc#1#2{\begingroup
+ \setTrue{#1}%
+% \end{macrocode}
+% Remove the skip after the abstract so that we can substitute another.
+% \begin{macrocode}
+ \par\removelastskip\vskip\z@skip
+% \end{macrocode}
+% The first two arguments of \cs{@startsection} here are special values
+% that cause different internal branches to be taken.
+%\begin{verbatim}
+% Arguments: {} = name = empty
+% \@M = no number should be used and no table of contents entry
+% \z@ = indent amount
+% 12pt + 12pt = vskip before
+% 6pt = vskip after
+% \centering\contentsnamefont = format
+%\end{verbatim}
+% \begin{macrocode}
+ \@startsection{}\@M\z@{\linespacing\@plus\linespacing}%
+ {.5\linespacing}{\centering\contentsnamefont}{#2}%
+% \end{macrocode}
+% If we have a list of figures or list of tables we want to put
+% them in the main table of contents, but we don't want to put an
+% entry there for the main table of contents itself. So we check
+% to see if argument 2 is \cn{contentsname} and if it is then
+% we refrain from doing \cn{addcontentsline}.
+% \begin{macrocode}
+ \ifx\contentsname#2%
+ \else \addcontentsline{toc}{section}{#2}\fi
+ \makeatletter
+ \@input{\jobname.#1}%
+ \if@filesw
+ \@xp\newwrite\csname tf@#1\endcsname
+ \immediate\@xp\openout\csname tf@#1\endcsname \jobname.#1\relax
+ \fi
+ \global\@nobreakfalse \endgroup
+ \addvspace{32\p@\@plus14\p@}%
+ \let\tableofcontents\relax
+}
+%</amsart|amsproc>
+% \end{macrocode}
+% And here is the book form of \cs{@starttoc}.
+% \begin{macrocode}
+%<*amsbook>
+\def\@starttoc#1#2{%
+ \begingroup
+ \setTrue{#1}%
+% \end{macrocode}
+% Inside this group we change \cs{secdef} so that we can call
+% \cn{chapter} and only get the preliminary part of its definition
+% that we need.
+% \begin{macrocode}
+ \let\secdef\@gobbletwo \chapter
+% \end{macrocode}
+% If we have a list of figures or list of tables we want to put
+% them in the main table of contents, but we don't want to put an
+% entry there for the main table of contents itself. So we check
+% to see if argument 2 is \cn{contentsname} and if it is then
+% we refrain from doing \cn{addcontentsline}.
+% \begin{macrocode}
+ \let\@secnumber\@empty % for \@tocwrite and \chaptermark
+ \ifx\contentsname#2%
+ \else \@tocwrite{chapter}{#2}\fi
+% \end{macrocode}
+% Now we do the equivalent of \cs{@schapter}. Expand \arg{2} so that
+% it will be easy to apply uppercasing to it. (For \cs{@starttoc} we
+% assume that \arg{2} is always a control such as \cn{contentsname}.)
+% \begin{macrocode}
+ \typeout{#2}\@xp\chaptermark\@xp{#2}%
+ \@makeschapterhead{#2}\@afterheading
+% \end{macrocode}
+% Protect against document classes that have nonzero \cs{parskip}.
+% \begin{macrocode}
+ \parskip\z@skip
+% \end{macrocode}
+% And finally we read in the \fn{.toc} (or whatever) file.
+% \begin{macrocode}
+ \makeatletter
+ \@input{\jobname.#1}%
+ \if@filesw
+ \@xp\newwrite\csname tf@#1\endcsname
+ \immediate\@xp\openout\csname tf@#1\endcsname \jobname.#1\relax
+ \fi
+ \global\@nobreakfalse \endgroup
+ \newpage
+}
+%</amsbook>
+% \end{macrocode}
+%
+% Now it is easy to define \cn{tableofcontents} and its relatives.
+% \begin{macrocode}
+\def\contentsname{Contents}
+\def\listfigurename{List of Figures}
+\def\listtablename{List of Tables}
+\def\tableofcontents{%
+ \@starttoc{toc}\contentsname
+}
+\def\listoffigures{\@starttoc{lof}\listfigurename}
+\def\listoftables{\@starttoc{lot}\listtablename}
+% \end{macrocode}
+%
+% In order to automatically leave enough space for the `number' part
+% of toc entries, we compute the maximum width of the `number' part
+% for each sectioning level and pass that information to
+% \cs{@tocline} through the \fn{.aux} file.
+%
+% Init the tocindents if they are not yet set (first run).
+% \begin{macrocode}
+\AtBeginDocument{%
+ \@for\@tempa:=-1,0,1,2,3\do{%
+ \@ifundefined{r@tocindent\@tempa}{%
+ \@xp\gdef\csname r@tocindent\@tempa\endcsname{0pt}}{}%
+ }%
+}
+% \end{macrocode}
+%
+% \begin{macro}{\@writetocindents}
+% This function writes out the max toc indents to the aux file.
+% \begin{macrocode}
+\def\@writetocindents{%
+ \begingroup
+ \@for\@tempa:=-1,0,1,2,3\do{%
+ \immediate\write\@auxout{%
+ \string\newlabel{tocindent\@tempa}{%
+ \csname r@tocindent\@tempa\endcsname}}%
+ }%
+ \endgroup}
+%
+\AtEndDocument{\@writetocindents}
+% \end{macrocode}
+% \end{macro}
+%
+
+% \begin{macro}{\indentlabel}
+% This function is a no-op except in \cs{@tocwrite} where it is a
+% pointer to \cs{@tochangmeasure}.
+% \begin{macrocode}
+\let\indentlabel\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@tochangmeasure}
+% This function measures the hangindent part of a toc entry and
+% updates the current max for the given sectioning level, if
+% necessary. The max's at the end of the document will be written
+% in the form of a pseudo-label to the \fn{.aux} file by
+% \cs{@writetocindents}.
+%
+% We can assume that \cs{@tochangmeasure} is already inside a group
+% when called.
+% \begin{macrocode}
+\def\@tochangmeasure#1{\sbox\z@{#1}%
+ \ifdim\wd\z@>\csname r@tocindent\@toclevel\endcsname\relax
+ \@xp\xdef\csname r@tocindent\@toclevel\endcsname{\the\wd\z@}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@toclevel}
+% Initialize, for the record.
+% \begin{macrocode}
+\def\@toclevel{0}
+% \end{macrocode}
+% \end{macro}
+%
+% Since we don't have leader dots, we have \cs{@tocline} instead of
+% \cs{@dottedtocline}.
+% \begin{macrocode}
+\def\@tocline#1#2#3#4#5#6#7{\relax
+ \ifnum #1>\c@tocdepth % then omit
+ \else
+ \par \addpenalty\@secpenalty\addvspace{#2}%
+ \begingroup \hyphenpenalty\@M
+ \@ifempty{#4}{%
+ \@tempdima\csname r@tocindent\number#1\endcsname\relax
+ }{%
+ \@tempdima#4\relax
+ }%
+ \parindent\z@ \leftskip#3\relax \advance\leftskip\@tempdima\relax
+ \rightskip\@pnumwidth plus4em \parfillskip-\@pnumwidth
+ #5\leavevmode\hskip-\@tempdima #6\nobreak\relax
+ \hfil\hbox to\@pnumwidth{\@tocpagenum{#7}}\par
+ \nobreak
+ \endgroup
+ \fi}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\@tocpagenum#1{\hss{\mdseries #1}}
+% \end{macrocode}
+%
+% The function \cs{@tocwrite} writes the information of a section
+% heading to the \fn{.toc} file in a standard form. It allows
+% different functions to be substituted for \cs{numberline}, to get
+% greater control of toc formatting.
+% \begin{macrocode}
+\def\@tocwrite#1{\@xp\@tocwriteb\csname toc#1\endcsname{#1}}
+% \end{macrocode}
+% The \cn{chapter} command uses \cs{@tocwriteb} directly because of
+% the need to write slightly different things to the toc file
+% depending on the current value of \cn{chaptername}.
+% \begin{macrocode}
+\def\@tocwriteb#1#2#3{%
+ \begingroup
+ \def\@tocline##1##2##3##4##5##6{%
+ \ifnum##1>\c@tocdepth
+ \else \sbox\z@{##5\let\indentlabel\@tochangmeasure##6}\fi}%
+ \csname l@#2\endcsname{#1{\csname#2name\endcsname}{\@secnumber}{}}%
+ \endgroup
+ \addcontentsline{toc}{#2}%
+ {\protect#1{\csname#2name\endcsname}{\@secnumber}{#3}}}
+% \end{macrocode}
+%
+% Specs for monograph toc are as follows (tocdepth is 1, i.e.,
+% subsections and lower are not listed in toc).
+%\begin{verbatim}
+% Part: Space above 12pt plus2pt, indent 0pt, "Part" + wordspace +
+% number + "." + 1em + title (raggedright, no hangindent) + 1em +
+% page number in column 1.6em wide.
+%
+% Chapter: Space above 8pt, hangindent on ("Chapter 0" + "." + 1em),
+% + title (raggedright) + 1em + page number in column 1.6em wide.
+%
+% Appendix: Same as Chapter except for epithet "Appendix M"
+%
+% Section: Space above 0pt, hangindent on (1pc + "0.0" + "." + 1em),
+% + title (raggedright) + 1em + page number in column 1.6em wide.
+%\end{verbatim}
+%
+% Specs for article toc are as follows (tocdepth 2):
+%\begin{verbatim}
+% Section: Same as for monograph.
+%
+% Subsection: Space above 0pt, hangindent 6pc (number + "." + 1em),
+% + title (raggedright) + 1em + page number in column 1.6em wide.
+%
+% Subsubsection: Same as subsection but hangindent 8pc
+%\end{verbatim}
+%
+% Typical invocation of \cs{l@chapter}:
+%\begin{verbatim}
+% \contentsline{chapter}{%
+% \tocchapter{Chapter}{3}{Some title stuff}}{103}
+% -->\l@chapter-->
+% #1 #2 #3 #4 #5
+% \@tocline{0}{8pt}{0pt}{}{\bfseries}
+% #6 6a 6b 6c #7
+% {\tocchapter{Chapter}{3}{Some title stuff}}{103}
+%\end{verbatim}%
+% The \cs{tocchapter} is a slightly more useful form than
+% \cs{numberline} that allows control for optionally omitting strings
+% like `Chapter' or changing fonts for subcomponents of the toc
+% entry. Note that it is allowed to have appendix and chapter at the
+% same toc level, with \cs{tocappendix} instead of \cs{tocchapter}
+% written in the \fn{.toc} file.
+%
+% The arguments of \cs{@tocline} are as follows:
+%\begin{verbatim}
+% \@tocline{LEVEL}{VSPACE}{INDENT}{NUMBERWIDTH}{EXTRA}%
+% {TEXT}{PAGENUM}
+%\end{verbatim}%
+% where `numberwidth' is the width of the box allotted to contain the
+% section number, including any preceding word like `Chapter' or
+% `Part'. If this width arg is empty then an automatically computed
+% width (max over TOC of the numberwidths for this level) is used.
+% The `extra' argument is formatting such as font changes.
+% The `text' argument contains a section-command specific function
+% like \cs{tocsection} or \cs{tocchapter} which takes in turn three
+% arguments: epithet, number, topic.
+% \begin{macrocode}
+\def\l@section{\@tocline{1}{0pt}{1pc}{}{}}
+% \end{macrocode}
+% *** The indents do not agree between in-house and distributed ***\\
+% *** versions; no changes; get specs before revising. ***\\
+% The use of \cn{ignorespaces} in \cs{tocsection} and its relatives
+% means that if \arg{1} is empty, the following space will be also
+% removed.
+% \begin{macrocode}
+\newcommand{\tocsection}[3]{%
+ \indentlabel{\@ifnotempty{#2}{\ignorespaces#1 #2.\quad}}#3}
+\def\l@subsection{\@tocline{2}{0pt}{1pc}{5pc}{}}
+\let\tocsubsection\tocsection
+\def\l@subsubsection{\@tocline{3}{0pt}{1pc}{7pc}{}}
+\let\tocsubsubsection\tocsection
+\let\l@paragraph\l@subsubsection
+\let\tocparagraph\tocsection
+\let\l@subparagraph\l@subsubsection
+\let\tocsubparagraph\tocsection
+%
+\def\l@part{\@tocline{-1}{12pt plus2pt}{0pt}{}{\bfseries}}
+\let\tocpart\tocsection
+\def\l@chapter{\@tocline{0}{8pt plus1pt}{0pt}{}{}}
+\let\tocchapter\tocsection
+% \end{macrocode}
+% In this case we are pretty sure the word "Appendix" or similar is
+% present, so only check if arg 2 is empty:
+% \begin{macrocode}
+\newcommand{\tocappendix}[3]{%
+ \indentlabel{#1\@ifnotempty{#2}{ #2}.\quad}#3}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\l@figure{\@tocline{0}{3pt plus2pt}{0pt}{1.5pc}{}}
+\let\l@table=\l@figure
+% \end{macrocode}
+%
+% \subsection{Bibliography section or chapter}
+%
+% Following the \pkg{babel} package, we use \cn{refname} in articles
+% and \cn{bibname} in books.
+% \begin{macrocode}
+\def\refname{References}
+\def\bibname{Bibliography}
+% \end{macrocode}
+%
+% Restudy the following code; \cs{bibsetup} isn't used anywhere
+% although it's defined for the three different bibstyles.
+% Because some publications have different default label styles,
+% separate that out for easy tailoring of packages.
+% \begin{macrocode}
+\def\@defaultbiblabelstyle#1{#1.}
+\def\bibliographystyle#1{%
+ \if@filesw\immediate\write\@auxout{\string\bibstyle{#1}}\fi
+ \def\@tempa{#1}%
+ \def\@tempb{amsplain}%
+ \def\@tempc{}%
+ \ifx\@tempa\@tempb
+ \def\@biblabel##1{\@defaultbiblabelstyle{##1}}%
+ \def\bibsetup{}%
+ \else
+ \def\bibsetup{\labelsep6\p@}%
+ \ifx\@tempa\@tempc
+ \def\@biblabel##1{}%
+ \def\bibsetup{\labelwidth\z@ \leftmargin24\p@
+ \itemindent-\leftmargin
+ \labelsep\z@ }%
+ \fi
+ \fi}
+% \end{macrocode}
+%
+% Permit easy change of font size for unusual purpose, e.g., for
+% an author's ``life list'' in collected works. [bnb, 2004/04/01]
+% \begin{macrocode}
+\newcommand{\bibliofont}{\footnotesize}
+% \end{macrocode}
+%
+% \env{thebibliography} differs in some author packages only in the
+% shape of the title; make this easy to change. [bnb, 2004/05/22]
+% \begin{macrocode}
+\newcommand{\@bibtitlestyle}{%
+%<amsart|amsproc> \@xp\section\@xp*\@xp{\refname}%
+%<amsbook> \@xp\chapter\@xp*\@xp{\bibname}%
+}
+\newenvironment{thebibliography}[1]{%
+ \@bibtitlestyle
+ \normalfont\bibliofont\labelsep .5em\relax
+ \renewcommand\theenumiv{\arabic{enumiv}}\let\p@enumiv\@empty
+ \list{\@biblabel{\theenumiv}}{\settowidth\labelwidth{\@biblabel{#1}}%
+ \leftmargin\labelwidth \advance\leftmargin\labelsep
+ \usecounter{enumiv}}%
+ \sloppy \clubpenalty\@M \widowpenalty\clubpenalty
+ \sfcode`\.=\@m
+}{%
+% \end{macrocode}
+% Change error for empty list (no items) to warning, to allow authors
+% to leave their bibliography temporarily empty during writing:
+% \begin{macrocode}
+ \def\@noitemerr{\@latex@warning{Empty `thebibliography' environment}}%
+ \endlist
+}
+% \end{macrocode}
+%
+% The \cn{bysame} command prints a horizontal dash indicating
+% repetition of the author's name in consecutive bibliography
+% entries.
+% \begin{macrocode}
+\def\bysame{\leavevmode\hbox to3em{\hrulefill}\thinspace}
+% \end{macrocode}
+% We define \cn{newblock} even though it's not needed for AMS
+% publication style, just to avoid error messages when a non-AMS
+% \fn{.bst} file is used. This is a convenience for users; use of
+% \cn{newblock} is not recommended for submissions to the AMS.
+% \begin{macrocode}
+\def\newblock{}
+% \end{macrocode}
+%
+% \begin{macro}{\MR}
+% \begin{macro}{\MRhref}
+% Provide an MR number for a bibliography item. At the moment
+% [mjd,1995/08/07] this only prints the MR number, but later
+% we expect to extend it to write an HTML \cs{special} to the
+% \fn{.dvi} file.
+%
+% The presentation of the MR number has been simplified (from using
+% a bold volume number) coincident with the change in the MathSciNet
+% database to a 7-digit reference number from the volume:number form.
+%
+% Ensure that an old-style MR number does not break across lines if
+% it contains a space; editorial request. [bnb; 2004/04/01]
+% Countermanded, to permit break between reference number and an
+% old-style number following in parentheses. [bnb; 2004/06/11]
+% \begin{macrocode}
+\newcommand\MR[1]{\relax\ifhmode\unskip\spacefactor3000 \space\fi
+ MR~\MRhref{#1}{#1}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\MRhref\@gobble
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\URL}
+% \begin{macro}{\URLhref}
+% \begin{macro}{\@URL}
+% Allows sticking in an arbitrary URL in a bibliography. Leading
+% ``http'' is not assumed. Call \cn{verb} to ensure that special
+% characters in the URL don't cause trouble.
+% \begin{macrocode}
+\newcommand\URL{\begingroup
+ \def\@sverb##1{%
+ \def\@tempa####1##1{\@URL{####1}\egroup\endgroup}%
+ \@tempa}%
+ \verb}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\URLhref\@gobble
+\def\@URL#1{\URLhref{#1}#1}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Index section or chapter}
+%
+% Chapter or section heading for an index. Index is set up to be two
+% columns.
+% \begin{macrocode}
+\newif\if@restonecol
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*amsbook>
+\def\indexchap#1{\global\topskip 7.5pc\relax
+ \twocolumn[{\fontsize{\@xivpt}{18}\bfseries\centering
+ \vskip\topskip\hbox{}\vskip-\baselineskip% adjust top space
+ #1\par
+% \end{macrocode}
+% After \cs{twocolumn} finishes operating, the top material is left in an
+% insert register, and topskip will now be applied above the
+% following material. So we should set it to the normal
+% after-chapter-title space (34pt)---cf.~\cs{@makeschapterhead}.
+% \begin{macrocode}
+ \global\topskip 34\p@\relax
+ \ifx\@empty\indexintro
+ \else
+ \begingroup \normalsize
+ \skip@\topskip \advance\skip@ -\baselineskip
+ \vskip\skip@
+ \parbox[t]{24pc}{\normalfont\indexintro\par}%
+ \endgroup
+ \global\topskip 24\p@\relax
+ \fi
+ }]%
+}
+\newcommand{\indexintro}{}
+%</amsbook>
+% \end{macrocode}
+%
+% \env{theindex} differs in some author packages only in the
+% shape of the title; make this easy to change. [bnb, 2004/05/22]
+% \begin{macrocode}
+\newcommand{\@indextitlestyle}{%
+%<*amsbook>
+ \let\@makeschapterhead\indexchap
+ \@xp\chapter\@xp*\@xp{\indexname}%
+%</amsbook>
+%<amsart|amsproc> \twocolumn[\@xp\section\@xp*\@xp{\indexname}]%
+}
+\def\theindex{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
+ \columnseprule\z@ \columnsep 35\p@
+ \@indextitlestyle
+ \thispagestyle{plain}%
+ \let\item\@idxitem
+ \parindent\z@ \parskip\z@\@plus.3\p@\relax
+ \raggedright
+ \hyphenpenalty\@M
+ \footnotesize}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\indexname{Index}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\@idxitem{\par\hangindent 2em}
+\def\subitem{\par\hangindent 2em\hspace*{1em}}
+\def\subsubitem{\par\hangindent 3em\hspace*{2em}}
+\def\endtheindex{\if@restonecol\onecolumn\else\clearpage\fi}
+\def\indexspace{\par\bigskip}
+% \end{macrocode}
+%
+% \subsection{Footnotes}
+% In books the footnote counter should reset to 0 at the beginning of
+% each chapter:
+% \begin{macrocode}
+%<amsbook>\@addtoreset{footnote}{chapter}
+% \end{macrocode}
+%
+% Rule above footnotes is 5 picas wide.
+% \begin{macrocode}
+\def\footnoterule{\kern-.4\p@
+ \hrule\@width 5pc\kern11\p@\kern-\footnotesep}
+% \end{macrocode}
+%
+% A simple superscript doesn't work here; it fails on a minipage,
+% where \cs{itshape} (which is invalid in math mode) is used for the
+% footnote numbers. Cf.~ the definition of \cn{textprime}.
+% \begin{macrocode}
+\def\@makefnmark{%
+ \leavevmode
+ \raise.9ex\hbox{\fontsize\sf@size\z@\normalfont\@thefnmark}%
+}
+%
+\def\@makefntext{\indent\@makefnmark}
+% \end{macrocode}
+% Add \cn{normalfont} before \cn{footnotesize} so that
+% fonts will come out properly using the new font selection scheme.
+% \begin{macrocode}
+\long\def\@footnotetext#1{%
+ \insert\footins{%
+ \normalfont\footnotesize
+ \interlinepenalty\interfootnotelinepenalty
+ \splittopskip\footnotesep \splitmaxdepth \dp\strutbox
+ \floatingpenalty\@MM \hsize\columnwidth
+% \end{macrocode}
+% Mostly \cs{@parboxrestore} does what we want; but not with
+% respect to \cs{parindent} and \cs{tolerance}.
+% \begin{macrocode}
+ \@parboxrestore \parindent\normalparindent \sloppy
+ \protected@edef\@currentlabel{%
+ \csname p@footnote\endcsname\@thefnmark}%
+ \@makefntext{%
+ \rule\z@\footnotesep\ignorespaces#1\unskip\strut\par}}}
+% \end{macrocode}
+% We change \cn{sloppy} to keep it from overriding our normal value of
+% 1pt for \cs{hfuzz} and \cs{vfuzz} with a LESS sloppy value (.5pt).
+% \begin{macrocode}
+\hfuzz=1pt \vfuzz=\hfuzz
+\def\sloppy{\tolerance9999 \emergencystretch 3em\relax}
+% \end{macrocode}
+%
+% \subsection{Float placement parameters}
+% These control the placing of floating objects like tables and
+% figures. We use much more tolerant values than the \latex/ defaults;
+% the \latex/ defaults are geared to fussier page breaks, at a price of
+% requiring more manual intervention to deal with difficult page
+% breaking problems.
+%
+% When using \latex/'s twocolumn option, `page' really means `column',
+% for the parameters that don't have a dbl prefix: that is, topnumber
+% is then the maximum number of top figures allowed in each column,
+% and so forth.
+% \begin{description}
+% \item[topnumber] maximum number of top figures allowed per page
+% \item[bottomnumber] maximum number of bottom figures allowed per page
+% \item[totalnumber] maximum number of figures (top and bottom) allowed
+% per page
+% \item[dbltopnumber] same as topnumber, but for two-column wide
+% figures, when double-column format is used
+% \end{description}
+% \begin{macrocode}
+\setcounter{topnumber}{4}
+\setcounter{bottomnumber}{4}
+\setcounter{totalnumber}{4}
+\setcounter{dbltopnumber}{4}
+% \end{macrocode}
+% Float fraction parameters.
+% \begin{description}
+% \item[\cs{topfraction}] maximum part of the page allowed for top
+% figures, expressed as a decimal fraction. The value of .97 means
+% roughly `accept pages that have only two lines of text, and the
+% rest figures'.
+% \item[\cs{bottomfraction}] same as \cs{topfraction}, but for bottom
+% figures
+% \item[\cs{textfraction}] \emph{minimum} part of the page that must be
+% occupied by text, if the page is to have any text at all. If this
+% value cannot be achieved, \latex/ will turn the current figure or
+% figures into a ``float page'', i.e., a page of figures without any
+% text.
+% \item[\cs{floatpagefraction}] minimum amount (that is, total combined
+% height) of figures needed before \latex/ will make a float page. This
+% is expressed as a fraction of the normal page height.
+% \item[\cs{dbltopfraction}] like \cs{topfraction}, but applies only to
+% figures that are two columns wide, when double-column format is
+% used.
+% \item[\cs{dblfloatpagefraction}] minimum amount of double-column
+% figure material needed before \latex/ will make a two-column wide
+% ``float page''
+% \end{description}
+% \begin{macrocode}
+\renewcommand{\topfraction}{.97}
+\renewcommand{\bottomfraction}{.97}
+\renewcommand{\textfraction}{.03}
+\renewcommand{\floatpagefraction}{.9}
+\renewcommand{\dbltopfraction}{.97}
+\renewcommand{\dblfloatpagefraction}{.9}
+% \end{macrocode}
+%
+% We also modify the default values for spacing around floating
+% figures: (A) so that figures on a float page will not be
+% vertically centered on the total page height but will
+% be flush at the top of the page, and (B) so that there will
+% be slightly more stretchability around figures, to help find better
+% page breaks in difficult situations.
+%
+% \begin{description}
+% \item[\cs{floatsep}] Space between consecutive figures
+% \item[\cs{textfloatsep}] Space between text and top or bottom figures
+% \item[\cs{intextsep}] Space above and below a figure in the middle of
+% the text (i.e., placed with the |[h]| option)
+% \item[\cs{dblfloatsep}] Space between consecutive figures that are
+% two columns wide (when two-column format is used)
+% \item[\cs{dbltextfloatsep}] Space between double-column figures and text
+% \item[\cs{@fptop}] Space above the first figure on a float page
+% \item[\cs{@fpsep}] Space between figures on a float page
+% \item[\cs{@fpbot}] Space below the last figure on a float page
+% \item[\cs{@dblfptop}] Space above the first double-column figure on a
+% two-column wide float page
+% \item[\cs{@dblfptop}] Space between double-column figures on a two-column
+% wide float page
+% \item[\cs{@dblfptop}] Space below the last double-column figure on a
+% two-column wide float page
+% \end{description}
+% \begin{macrocode}
+\setlength{\floatsep}{12pt plus 6pt minus 4pt}
+\setlength{\textfloatsep}{15pt plus 8pt minus 5pt}
+\setlength{\intextsep}{12pt plus 6pt minus 4pt}
+\setlength{\dblfloatsep}{12pt plus 6pt minus 4pt}
+\setlength{\dbltextfloatsep}{15pt plus 8pt minus 5pt}
+\setlength{\@fptop}{0pt}% removed "plus 1fil"
+\setlength{\@fpsep}{8pt}% removed "plus 2fil"
+\setlength{\@fpbot}{0pt plus 1fil}
+\setlength{\@dblfptop}{0pt}% removed "plus 1fil"
+\setlength{\@dblfpsep}{8pt}% removed "plus 2fil"
+\setlength{\@dblfpbot}{0pt plus 1fil}
+% \end{macrocode}
+%
+% \cs{fps@figure}, \cs{fps@table}: placement specifications for
+% \env{figure} and \env{table} environments. `|tbp|' means that a
+% figure will be placed at the top or bottom of a page, or on a
+% separate page with no text. This might be changed to `|tp|', for
+% example, if you never want figures to appear at the bottom of a
+% page.
+% \begin{macrocode}
+\newcommand{\fps@figure}{tbp}
+\newcommand{\fps@table}{tbp}
+% \end{macrocode}
+%
+% Some more setup for figures.
+% \begin{macrocode}
+%<amsart|amsproc>\newcounter{figure}
+%<amsbook>\newcounter{figure}[chapter]
+\def\@captionheadfont{\scshape}
+\def\@captionfont{\normalfont}
+\def\ftype@figure{1}
+\def\ext@figure{lof}
+\def\fnum@figure{\figurename\ \thefigure}
+\def\figurename{Figure}
+\newenvironment{figure}{%
+ \@float{figure}%
+}{%
+ \end@float
+}
+\newenvironment{figure*}{%
+ \@dblfloat{figure}%
+}{%
+ \end@dblfloat
+}
+% \end{macrocode}
+% And similar for tables.
+% \begin{macrocode}
+%<amsart|amsproc>\newcounter{table}
+%<amsbook>\newcounter{table}[chapter]
+\def\ftype@table{2}
+\def\ext@table{lot}
+\def\fnum@table{\tablename\ \thetable}
+\def\tablename{Table}
+\newenvironment{table}{%
+ \@float{table}%
+}{%
+ \end@float
+}
+\newenvironment{table*}{%
+ \@dblfloat{table}%
+}{%
+ \end@dblfloat
+}
+% \end{macrocode}
+%
+% Change \cs{@floatboxreset} to add \cn{centering}. Centering is
+% always applied to tables and figures in AMS publications. It should
+% not be necessary to throw in |\begin{center}| \ldots |\end{center}|
+% in every instance to achieve this.
+% \begin{macrocode}
+\def\@floatboxreset{\global\@minipagefalse \centering}
+% \end{macrocode}
+%
+% This is what we want \cs{@makecaption} to do: If the total width is
+% greater than normal columnwidth we want to break the caption into
+% lines using a line width of $W$ = (columnwidth $-$ 6pc), and center
+% the resulting block between the margins. Otherwise we want to set
+% the caption as a single line, centered between the margins.
+%
+% To do this we set the caption as a vbox with line width $W$,
+% except that we allow the last line (which may be the only line) to
+% have width up to full columnwidth by adding a kern of -6pc. If the
+% result is a single hbox (i.e., a single line) we need to unpack the
+% hbox, remove rightskip, parfillskip, and the -6pc kern, and center
+% the remaining material. If the caption is more than one line, then
+% box 1 contains the last line, which we need to unpack in the same
+% way, and run through the paragraphing process again (because this
+% last line may be up to 6 picas wider than the desired width).
+%
+% In practice this procedure tends to fail if there are any potential
+% breakpoints near the end of the first line (in the window between
+% short-width and full-width). Then \TeX{} tends to choose a break
+% (depending on spaceskip, tolerance, etc) at the last acceptable
+% breakpoint before short-width is exceeded, \emph{without
+% considering any later material}---in particular, the negative kern.
+% [This was pointed out by Donald Arseneau, May 2000.] Unfortunately,
+% setting parfillskip to a negative value does not work either. I
+% guess this is a special case of the existing limitation on
+% parshape: you cannot specify a parshape in terms of number of lines
+% from the bottom of the paragraph. (We would like to specify a
+% parshape where the last line is 6 picas longer than the others.)
+%
+% Finally, if the caption is for a figure, it will be set below the
+% figure, so the separating space goes above the caption; otherwise
+% the separating space goes below the caption.
+% \begin{macrocode}
+\long\def\@makecaption#1#2{%
+% \end{macrocode}
+% Measure the contents of the caption. If \arg{2} is not
+% empty, then we must add a period and an en-space before
+% typesetting it. The \cs{@caption} macro adds an extra
+% \cn{ignorespaces} at the beginning of \arg{2}, so in order
+% to find out if the user-typed portion is empty we use
+% \cs{@cdr} to pull off the \cn{ignorespaces}.
+% \begin{macrocode}
+% Use color-safe commands
+ \setbox\@tempboxa\vbox{\color@setgroup
+ \advance\hsize-2\captionindent\noindent
+ \@captionfont\@captionheadfont#1\@xp\@ifnotempty\@xp
+ {\@cdr#2\@nil}{.\@captionfont\upshape\enspace#2}%
+ \unskip\kern-2\captionindent\par
+ \global\setbox\@ne\lastbox\color@endgroup}%
+ \ifhbox\@ne % the normal case
+ \setbox\@ne\hbox{\unhbox\@ne\unskip\unskip\unpenalty\unkern}%
+ \fi
+% \end{macrocode}
+% If \cs{@tempboxa} is not empty at this point then the caption was
+% more than one line long or there was extra vertical mode material,
+% maybe a \cs{write} (from \cn{index} or something).
+% Interestingly, we can't use \cs{ifvoid} to see if
+% \cs{@tempboxa} is empty, because empty is not the same thing
+% as void (as far as the \cs{ifvoid} test is concerned). So
+% instead we measure the width of \cs{@tempboxa}
+% to see if it's zero; this should suffice for non-bizarre cases.
+% \begin{macrocode}
+ \ifdim\wd\@tempboxa=\z@ % this means caption will fit on one line
+ \setbox\@ne\hbox to\columnwidth{\hss\kern-2\captionindent\box\@ne\hss}%
+ \else % tempboxa contained more than one line
+ \setbox\@ne\vbox{\unvbox\@tempboxa\parskip\z@skip
+ \noindent\unhbox\@ne\advance\hsize-2\captionindent\par}%
+ \fi
+ \ifnum\@tempcnta<64 % if the float IS a figure...
+ \addvspace\abovecaptionskip
+ \hbox to\hsize{\kern\captionindent\box\@ne\hss}%
+ \else % if the float IS NOT a figure...
+ \hbox to\hsize{\kern\captionindent\box\@ne\hss}%
+ \nobreak
+ \vskip\belowcaptionskip
+ \fi
+\relax
+}
+% \end{macrocode}
+% Allocate the skip registers for above and below caption space.
+% \begin{macrocode}
+\newskip\abovecaptionskip \abovecaptionskip=12pt \relax
+\newskip\belowcaptionskip \belowcaptionskip=12pt \relax
+\newdimen\captionindent \captionindent=3pc
+% \end{macrocode}
+%
+% \subsection{Miscellaneous}
+%
+% \begin{macro}{\nonbreakingspace}
+% Change \qc{\~} to be more forgiving of accidental adjacent spaces.
+% Note that this means multiple |~~~...| cannot be used to get
+% multiple spaces in the output.
+% \begin{macrocode}
+\def\nonbreakingspace{\unskip\nobreak\ \ignorespaces}
+\def~{\protect\nonbreakingspace}
+% \end{macrocode}
+% \end{macro}
+%
+% Redefine \cs{@biblabel} to do nothing if the argument is empty. We
+% don't really care what the previous definition was so we don't
+% check it.
+% \begin{macrocode}
+\def\@biblabel#1{\@ifnotempty{#1}{[#1]}}
+% \end{macrocode}
+% Changed \cs{@cite} to always use roman/upright, nonbold font, even
+% in italic or bold text (following AMS style).
+% Turn off \cs{mathsurround} just in case there are subscripts in the
+% cite numbers.
+% \begin{macrocode}
+\def\@citestyle{\m@th\upshape\mdseries}
+%<amsart>\let\citeform\@firstofone
+%<amsbook|amsproc>\def\citeform#1{{\bfseries#1}}
+\def\@cite#1#2{{%
+ \@citestyle[\citeform{#1}\if@tempswa, #2\fi]}}
+% \end{macrocode}
+%
+% Make \cn{cite} robust if it isn't already. Too many unsuspecting
+% users get problems from this in a figure or table caption.
+% \begin{macrocode}
+\@ifundefined{cite }{%
+ \expandafter\let\csname cite \endcsname\cite
+ \edef\cite{\@nx\protect\@xp\@nx\csname cite \endcsname}%
+}{}
+% \end{macrocode}
+%
+% \begin{macro}{\fullwidthdisplay}
+% The function \cs{fullwidthdisplay} makes a displayed equation take
+% up the full column width even if the current context is an indented
+% list.
+% \begin{macrocode}
+\def\fullwidthdisplay{\displayindent\z@ \displaywidth\columnwidth}
+% \end{macrocode}
+% And we insert the \cs{fullwidthdisplay} function at the beginning of
+% \cs{everydisplay} just in case any later code in \cs{everydisplay}
+% needs to use the values of \cs{displayindent} or \cs{displaywidth}.
+% \begin{macrocode}
+\edef\@tempa{\noexpand\fullwidthdisplay\the\everydisplay}
+\everydisplay\expandafter{\@tempa}
+% \end{macrocode}
+% \end{macro}
+%
+% A few odds and ends for indexes, based on \pkg{makeindex}. The
+% definition of \cn{see} as ``see also'' is unfortunate, but of
+% long standing, and cannot be changed without destroying backward
+% compatibility, so an alternate command, \cn{seeonly}, is provided
+% to cover the basic situation.
+% \begin{macrocode}
+\newcommand*\seeonlyname{see}
+\newcommand*\seename{see also}
+\newcommand*\alsoname{see also}
+\newcommand*\seeonly[2]{\emph{\seeonlyname} #1}
+\newcommand*\see[2]{\emph{\seename} #1}
+\newcommand*\seealso[2]{\emph{\alsoname} #1}
+\newcommand\printindex{\@input{\jobname.ind}}
+% \end{macrocode}
+%
+% \begin{macro}{\textprime}
+% A text prime symbol, for applying primes to numbers such as list
+% numbers or equation numbers that are not really math. Furthermore
+% Cyrillic myagkii znak, or soft sign, is represented by a prime
+% symbol in Russian names when they are transliterated into English.
+%
+% \cn{textprime} uses the prime symbol from math, but because it's
+% intended specifically for nonmath use, we avoid going through math
+% mode with \verb'$...$'. We must therefore call \cs{check@mathfonts}
+% to ensure that \verb'scriptfont2' is actually defined. Otherwise,
+% if \cn{textprime} were used in a document before the first math
+% formula, there would be no adequate assignment yet for
+% \verb'\scriptfont2'.
+%
+% The raise value of \verb'.8ex' is just a reasonable guess at making
+% the bottom of the prime symbol fall near the top of a preceding
+% lowercase letter but still not fall too low on an uppercase letter.
+% We could look up the \cs{fontdimen} values used in math mode for
+% superscripts but I don't think it's worth the bother.
+%
+% Cf.~also the definition of \cs{@makefnmark}. The prime symbol here
+% is not raised quite so high because I think that is desirable for
+% the soft-sign usage.
+% \begin{macrocode}
+\DeclareRobustCommand\textprime{\leavevmode
+ \raise.8ex\hbox{\check@mathfonts\the\scriptfont2 \char48 }}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Book style variations}
+% Here is the layout for a \cn{maketitle} in the \cls{amsbook} class.
+% \begin{macrocode}
+%<*amsbook>
+\def\maketitle{\par
+ \@topnum\z@ % this prevents figures from falling at the top of page 1
+ \begingroup
+ \@maketitle
+ \endgroup
+ \c@footnote\z@
+ \def\do##1{\let##1\relax}%
+ \do\maketitle \do\@maketitle \do\title \do\@xtitle \do\@title
+ \do\author \do\@xauthor \do\address \do\@xaddress
+ \do\email \do\@xemail \do\curraddr \do\@xcurraddr
+ \do\dedicatory \do\@dedicatory \do\thanks \do\thankses
+ \do\keywords \do\@keywords \do\subjclass \do\@subjclass
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\@maketitle{%
+ \cleardoublepage \thispagestyle{empty}%
+ \begingroup \topskip\z@skip
+ \null\vfil
+ \begingroup
+ \LARGE\bfseries \centering
+ \openup\medskipamount
+ \@title\par\vspace{24pt}%
+ \def\and{\par\medskip}\centering
+ \mdseries\authors\par\bigskip
+ \endgroup
+ \vfil
+ \ifx\@empty\addresses \else \@setaddresses \fi
+ \vfil
+ \ifx\@empty\@dedicatory
+ \else \begingroup
+ \centering{\footnotesize\itshape\@dedicatory\@@par}%
+ \endgroup
+ \fi
+ \vfill
+ \newpage\thispagestyle{empty}
+ \begin{center}
+ \ifx\@empty\@subjclass\else\@setsubjclass\fi
+ \ifx\@empty\@keywords\else\@setkeywords\fi
+ \ifx\@empty\@translators\else\vfil\@settranslators\fi
+ \ifx\@empty\thankses\else\vfil\@setthanks\fi
+ \end{center}
+ \vfil
+ \@setabstract
+ \endgroup}
+% \end{macrocode}
+%
+% Define the desired form for translator names.
+% \begin{macrocode}
+\def\@settranslators{\par
+ \begingroup
+ \translname: \andify\@translators \uppercasenonmath\@translators
+ \@translators \@@par
+ \endgroup}
+\def\@setdate{\par\smallskip\@date\par\smallskip}
+\def\@setsubjclass{\par\smallskip
+ {\itshape\subjclassname.}\enspace\@subjclass\par\smallskip}
+\def\@setkeywords{\par\smallskip
+ {\itshape \keywordsname.}\enspace \@keywords\par\smallskip}
+%</amsbook>
+%</classes>
+% \end{macrocode}
+%
+% \subsection{Setup for theorems, definitions, remarks, proofs}
+% \subsubsection{Intended usage}
+%
+% Here are some examples showing the kinds of theorem environment
+% declarations that are possible.
+%\begin{verbatim}
+% \newtheorem{prop}{Proposition}
+% \newtheorem{thm}{Theorem}[section]
+% \newtheorem{lem}[thm]{Lemma}
+% \newtheorem*{Zorn}{Zorn's Lemma}
+%
+% \theoremstyle{definition}
+% \newtheorem{dfn}{Definition}
+%
+% \theoremstyle{remark}
+% \newtheorem*{rmk}{Remark}
+%\end{verbatim}
+%
+% The first four statements all define environments using the default
+% theorem style (`plain'), since there is no prefatory
+% \cn{theoremstyle} declaration. The first statement defines an
+% automatically numbered \env{prop} environment whose headings will
+% look like this: Proposition 1, Proposition 2, and so forth. The
+% second statement defines an environment \env{thm} with numbers
+% subordinate to section numbers, so the headings will look like
+% this: Theorem 1.1, Theorem 1.2, Theorem 1.3, \dots, (in section 2:)
+% Theorem 2.1, Theorem 2.2, and so forth. The third statement defines
+% a \env{lem} environment whose numbers will interleave in sequence
+% with the theorem numbers: Theorem 1.3, Lemma 1.4, Lemma 1.5,
+% Theorem 1.6, and so forth. The fourth statement defines a special
+% unnumbered lemma named `Zorn's Lemma'. The remaining two
+% \cn{newtheorem} statements have no special features except for the
+% \cn{theoremstyle} declarations that cause the \env{dfn} and
+% \env{rmk} environments to have some differences in appearance.
+%
+% There are three basic styles provided: The `plain' style produces
+% bold headings and italic body text; the `definition' style produces
+% bold headings and normal body text; the `remark' style produces
+% italic headings and normal body text.
+%
+% A \cn{swapnumbers} command allows theorem numbers to be swapped to
+% the front of the theorem headings. Putting \cn{swapnumbers} in your
+% document preamble will cause \emph{all following} \cn{newtheorem}
+% statements to produce number-first headings. (To provide maximum
+% control, \cn{swapnumbers} is designed so that it can be used more
+% than once; each time it is used, theorem numbers will be swapped to
+% the opposite side for all following \cn{newtheorem} statements. But
+% rarely will it need to be invoked more than once per document.)
+%
+% \subsubsection{Custom theorem styles}
+% There is a \cn{newtheoremstyle} command provided to make the
+% creation of custom theoremstyles fairly easy.
+%
+% Usage:
+%\begin{verbatim}
+% #1
+% \newtheoremstyle{NAME}%
+% #2 #3 #4
+% {ABOVESPACE}{BELOWSPACE}{BODYFONT}%
+% #5 #6 #7 #8
+% {INDENT}{HEADFONT}{HEADPUNCT}{HEADSPACE}%
+% #9
+% {CUSTOM-HEAD-SPEC}
+%\end{verbatim}
+% Leaving the `indent' argument empty is equivalent to entering
+% |0pt|. The `headpunct' and `headspace' arguments are for the
+% punctuation and horizontal space between the theorem head and the
+% following text. There are two special values that may be used for
+% `headspace': a single space means that a normal interword space
+% should be used; ``\cn{newline}'' means that there should be a line
+% break after the head instead of horizontal space. The
+% `custom-head-spec' argument follows a special convention: it is
+% interpreted as the replacement text for an internal three-argument
+% function \cn{thmhead}, i.e., as if you were defining
+%\begin{verbatim}
+% \renewcommand{\thmhead}[3]{...#1...#2...#3...}
+%\end{verbatim}
+% but omitting the initial |\renewcommand{\thmhead}[3]|. The three
+% arguments that will be supplied to \cn{thmhead} are the name,
+% number, and optional note components. Within the replacement text
+% you can (and normally will want to) use other special functions
+% \cn{thmname}, \cn{thmnumber}, and \cn{thmnote}. These will print
+% their argument if and only if the corresponding argument of
+% \cn{thmhead} is nonempty. For example
+%\begin{verbatim}
+% {\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}}
+%\end{verbatim}
+% This would cause the theorem note \arg{3} to be printed with a
+% preceding space and enclosing parentheses, if it is present, and if
+% it is absent, the space and parentheses will be omitted because
+% they are inside the argument of \cn{thmnote}.
+%
+% Finally, if you have an extra bit of arbitrary code that you want
+% to slip in somewhere, the best place to do it is in the `body font'
+% argument.
+%
+% The \cn{newtheoremstyle} command is designed to provide, through a
+% relatively simple interface, control over the style aspects that
+% are most commonly changed. More complex requirements must be
+% addressed through a separate \latex/ package.
+%
+% When you set up custom theorem styles with \cn{newtheoremstyle} you
+% should not use \cn{swapnumbers}. You have full control of the
+% ordering of elements in the theorem head, just place them where you
+% want. Or, if you do use \cn{swapnumbers}, you must look at the
+% definition of \cs{swappedhead} and change it appropriately.
+
+% \subsubsection{Implementation}
+% The \cn{theoremstyle} command is very simple except for the need to
+% warn about an unknown theoremstyle.
+% \begin{macrocode}
+%<*amsthm|classes>
+\newcommand{\theoremstyle}[1]{%
+ \@ifundefined{th@#1}{%
+ \PackageWarning{amsthm}{Unknown theoremstyle `#1'}%
+ \thm@style{plain}%
+ }{%
+ \thm@style{#1}%
+ }%
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newtoks\thm@style
+\thm@style{plain}
+% \end{macrocode}
+%
+% What's really needed is a full-fledged systematic approach for
+% specifying the desired order and formatting of the three identified
+% parts of a theorem head (name, number, note).
+% \begin{macrocode}
+\newtoks\thm@bodyfont \thm@bodyfont{\itshape}
+\newtoks\thm@headfont \thm@headfont{\bfseries}
+\newtoks\thm@notefont \thm@notefont{}
+\newtoks\thm@headpunct \thm@headpunct{.}
+% \end{macrocode}
+% Vertical spacing: initialize to current value of \cs{topsep}.
+% If a document class loads the \pkg{amsthm} package it
+% should take care to set these variables explicitly, if current
+% \cs{topsep} is not the desired value.
+% \begin{macrocode}
+\newskip\thm@preskip \newskip\thm@postskip
+%<*classes>
+\def\thm@space@setup{%
+ \thm@preskip=.5\baselineskip\@plus.2\baselineskip
+ \@minus.2\baselineskip
+ \thm@postskip=\thm@preskip
+}
+%</classes>
+%<*amsthm>
+\def\thm@space@setup{%
+ \thm@preskip=\topsep \thm@postskip=\thm@preskip
+}
+%</amsthm>
+% \end{macrocode}
+% Modify \cn{newtheorem} to add |*| option. If a |*| is found, pass
+% it on to \cs{@xnthm} as the first argument. (This information
+% enables us to handle two different possibilities in a single
+% function \cs{@xnthm} instead of needing two separate functions.)
+% \begin{macrocode}
+\renewcommand{\newtheorem}{\@ifstar{\@xnthm *}{\@xnthm \relax}}
+% \end{macrocode}
+%
+% Check to see if an optional arg is present after the first
+% mandatory arg (which is \arg{2} at the moment since the |*| or
+% non-|*| is \arg{1}).
+% \begin{macrocode}
+\def\@xnthm#1#2{%
+ \let\@tempa\relax
+ \@xp\@ifdefinable\csname #2\endcsname{%
+ \global\@xp\let\csname end#2\endcsname\@endtheorem
+ \ifx *#1% unnumbered, need to get one more mandatory arg
+ \edef\@tempa##1{%
+ \gdef\@xp\@nx\csname#2\endcsname{%
+ \@nx\@thm{\@xp\@nx\csname th@\the\thm@style\endcsname}%
+ {}{##1}}}%
+ \else % numbered theorem, need to check for optional arg
+ \def\@tempa{\@oparg{\@ynthm{#2}}[]}%
+ \fi
+ }%
+ \@tempa
+}
+% \end{macrocode}
+%
+% Environment numbered together with a previously defined
+% environment.
+%
+% Arg1: env name, e.g. `thm'\par
+% Arg2: optional sibling counter\par
+% Arg3: heading text e.g. `Theorem'
+% \begin{macrocode}
+\def\@ynthm#1[#2]#3{%
+% \end{macrocode}
+% If optional arg \arg{2} is empty, call \cs{@xthm} to look for a
+% possible optional arg in terminal position. Note that
+% the two optional args are mutually exclusive. As \arg{2} is a
+% counter name and must be processed by \cs{csname} anyway,
+% we can use a simpler test instead of \cs{@ifempty}.
+% \begin{macrocode}
+ \ifx\relax#2\relax
+ \def\@tempa{\@oparg{\@xthm{#1}{#3}}[]}%
+ \else
+ \@ifundefined{c@#2}{%
+ \def\@tempa{\@nocounterr{#2}}%
+ }{%
+ \@xp\xdef\csname the#1\endcsname{\@xp\@nx\csname the#2\endcsname}%
+ \toks@{#3}%
+ \@xp\xdef\csname#1\endcsname{%
+ \@nx\@thm{%
+ \let\@nx\thm@swap
+ \if S\thm@swap\@nx\@firstoftwo\else\@nx\@gobble\fi
+ \@xp\@nx\csname th@\the\thm@style\endcsname}%
+ {#2}{\the\toks@}}%
+ \let\@tempa\relax
+ }%
+ \fi
+ \@tempa
+}
+% \end{macrocode}
+%
+% Environment numbered relative to the counter given as \arg{3}. This
+% function should really be named \cs{@znthm} but we're trying to
+% save a bit of hash table and string pool by reusing one of the
+% command names rendered obsolete by the \pkg{amsthm} package.
+%
+% Arg1: env name e.g. `thm';
+% Arg2: heading text e.g. `Theorem';
+% Arg3: parent counter e.g. section.
+% \begin{macrocode}
+\def\@xthm#1#2[#3]{%
+% \end{macrocode}
+% Set up the counter \verb'c@#1' and optionally add it to the reset
+% list of counter \arg{3}. As \arg{3} is a
+% counter name and must be processed by \cs{csname} anyway,
+% we can use a simpler test instead of \cs{@ifempty}.
+% \begin{macrocode}
+ \ifx\relax#3\relax
+ \newcounter{#1}%
+ \else
+ \newcounter{#1}[#3]%
+% \end{macrocode}
+% Define \cn{thexxx} to be \verb'\theyyy.\arabic{xxx}' (assuming
+% default values of punctuation and numbering style). The use of
+% \cs{xdef} here is inherited from the old \latex/ code, I'm not
+% sure it's a good idea in general, but there should not be any
+% problems unless someone changes the value of \cs{@thmcountersep} or
+% \cs{@thmcounter}.
+% \begin{macrocode}
+ \@xp\xdef\csname the#1\endcsname{\@xp\@nx\csname the#3\endcsname
+ \@thmcountersep\@thmcounter{#1}}%
+ \fi
+ \toks@{#2}%
+ \@xp\xdef\csname#1\endcsname{%
+ \@nx\@thm{%
+ \let\@nx\thm@swap
+ \if S\thm@swap\@nx\@firstoftwo\else\@nx\@gobble\fi
+ \@xp\@nx\csname th@\the\thm@style\endcsname}%
+ {#1}{\the\toks@}}%
+}
+% \end{macrocode}
+%
+% [mjd,1999/10/13] The following code doesn't handle the case where
+% an equation is immediately followed by a theorem with no
+% intervening \cs{par}---then the spacefactor is 1000.
+% \begin{macrocode}
+% % \def\thm@check@break{%
+% % \ifhmode \unskip \unskip
+% % \edef\pre@thm@spacefactor{\the\spacefactor}\par
+% % \edef\thm@topbreak{%
+% % \ifnum\pre@thm@spacefactor<\sfcode`\!\relax
+% % % preceding text line did not end with end-of-sentence punctuation
+% % \ifnum\prevgraf=\@ne \penalty\widowpenalty
+% % \else \penalty9999\relax
+% % \fi
+% % \else
+% % \@nx\addpenalty{\@beginparpenalty}%
+% % \fi
+% % }%
+% % \else
+% % \def\thm@topbreak{\addpenalty\@beginparpenalty}%
+% % \fi
+% % }
+% \end{macrocode}
+%
+% If arg \arg{2} is empty, this is an unnumbered environment;
+% otherwise \arg{2} is the name of a counter. \arg{3} is descriptive
+% name such as ``Theorem'' or ``Lemma''. Arg \arg{1} is the style
+% function, for example \cs{th@plain}.
+% \begin{macrocode}
+\def\@thm#1#2#3{%
+ \ifhmode\unskip\unskip\par\fi
+ \normalfont
+ \trivlist
+% \end{macrocode}
+% Explicitly set plain style here, then override parts as necessary
+% in the function provided as \arg{1}.
+% \begin{macrocode}
+ \let\thmheadnl\relax
+ \let\thm@swap\@gobble
+%<amsart> \let\thm@indent\noindent % no indent
+%<amsart> \thm@headfont{\bfseries}% heading font bold
+%<amsbook|amsproc> \let\thm@indent\indent % indent
+%<amsbook|amsproc> \thm@headfont{\scshape}% heading font small caps
+ \thm@notefont{\fontseries\mddefault\upshape}%
+ \thm@headpunct{.}% add period after heading
+ \thm@headsep 5\p@ plus\p@ minus\p@\relax
+ \thm@space@setup
+ #1% style overrides
+ \@topsep \thm@preskip % used by thm head
+ \@topsepadd \thm@postskip % used by \@endparenv
+ \def\@tempa{#2}\ifx\@empty\@tempa
+ \def\@tempa{\@oparg{\@begintheorem{#3}{}}[]}%
+ \else
+ \refstepcounter{#2}%
+ \def\@tempa{\@oparg{\@begintheorem{#3}{\csname the#2\endcsname}}[]}%
+ \fi
+ \@tempa
+}
+% \end{macrocode}
+%
+% The internal function \cs{@restorelabelsep} starts out as a no-op.
+% I don't think this is needed any more [mjd,2000/10/26].
+% \begin{macrocode}
+\def\@restorelabelsep{\relax}
+% \end{macrocode}
+%
+% This variation of the \cs{@thm} command is no longer needed. The
+% variation \cs{@xthm} was commandeered for \cn{newtheorem} use.
+% \begin{macrocode}
+\let\@ythm\relax
+% \end{macrocode}
+%
+% Init \cn{thmname} etc.
+% \begin{macrocode}
+\let\thmname\@iden \let\thmnote\@iden \let\thmnumber\@iden
+% \end{macrocode}
+%
+% \begin{macro}{\@upn}
+% The function \cs{\@upn} is used to force theorem numbers and
+% similar elements to be upright even when the current font is
+% italic. If a suitable italic font with upright numbers and
+% punctuation is available, this function should be redefined to be a
+% no-op.
+% \begin{macrocode}
+\providecommand\@upn{\textup}
+% \end{macrocode}
+% \end{macro}
+%
+% Definitions for theorem heads.
+% \begin{macrocode}
+\def\thmhead@plain#1#2#3{%
+% \end{macrocode}
+% To allow for the case where the thmname part is empty and the
+% heading consists only of a number (don't laugh, we have
+% examples from real mathematical manuscripts), we don't add the
+% space at the beginning of thmnumber unless \arg{1} is nonempty.
+% \begin{macrocode}
+ \thmname{#1}\thmnumber{\@ifnotempty{#1}{ }\@upn{#2}}%
+% \end{macrocode}
+% In thmnote we always add a leading space, i.e., assuming that
+% at least one of the preceding parts will always be present.
+% \begin{macrocode}
+ \thmnote{ {\the\thm@notefont(#3)}}}
+\let\thmhead\thmhead@plain
+% \end{macrocode}
+% Swappedhead is for the case where the number precedes the
+% word "Theorem". When the numbers fall on the left, like section
+% numbers, AMS journal style calls for them to be lightface. We get
+% this by invoking \cs{@secnumfont}.
+%
+% In handling the punctuation after the number we have to step
+% delicately if we want to successfully handle cases where the
+% theorem name is empty (this is very rare, yet it sometimes arises
+% in practice).
+% \begin{macrocode}
+\def\swappedhead#1#2#3{%
+%<amsthm> \thmnumber{#2}%
+%<amsthm> \thmname{\@ifnotempty{#2}{~}#1}%
+%<classes> \thmnumber{\@upn{\@secnumfont#2\@ifnotempty{#1}{.~}}}%
+%<classes> \thmname{#1}%
+ \thmnote{ {\the\thm@notefont(#3)}}}
+% \end{macrocode}
+%
+% A customized definition of \cs{th@plain} written for version 1.x of
+% the \pkg{amsthm} package might refer to \cs{swappedhead@plain}; this
+% gives it a definition for backward compatibility.
+% \begin{macrocode}
+\let\swappedhead@plain=\swappedhead
+% \end{macrocode}
+%
+% In \cs{@begintheorem} \cn{thmheadnl} is called after the theorem
+% head: maybe a newline, otherwise a no-op.
+% \begin{macrocode}
+\let\thmheadnl\relax
+\let\thm@indent\noindent
+\let\thm@swap\@gobble
+% \end{macrocode}
+%
+% If argument \arg{2} is empty, then this is an unnumbered
+% environment. Otherwise \arg{2} is a numbering command such as
+% \cn{thexyz}. We use \cs{deferred@thm@head} instead of \cs{item} in
+% order to allow line breaking in the optional note argument.
+% \begin{macrocode}
+\def\@begintheorem#1#2[#3]{%
+ \deferred@thm@head{\the\thm@headfont \thm@indent
+% \end{macrocode}
+% Changes to \cs{thmnumber} and \cs{thmnote} are local to the
+% containing box.
+% \begin{macrocode}
+ \@ifempty{#1}{\let\thmname\@gobble}{\let\thmname\@iden}%
+ \@ifempty{#2}{\let\thmnumber\@gobble}{\let\thmnumber\@iden}%
+ \@ifempty{#3}{\let\thmnote\@gobble}{\let\thmnote\@iden}%
+% \end{macrocode}
+% The \cs{thm@swap} function selects either \cs{swappedhead} or
+% \cs{thmhead}.
+% \begin{macrocode}
+ \thm@swap\swappedhead\thmhead{#1}{#2}{#3}%
+% \end{macrocode}
+% I can't think of any example where the after-head punctuation
+% should be omitted so it seems correct not to use \cs{@addpunct}
+% here.
+% \begin{macrocode}
+ \the\thm@headpunct
+% \end{macrocode}
+% If this \emph{is} a newline (from a \cn{newtheoremstyle}), it
+% gets lost if there isn't any text following the heading, since
+% \cs{deferred@thm@head} packs the heading into an hbox with
+% \cs{sbox}\cs{@labels}. Attempting to move the \cs{thmheadnl}
+% outside the scope of \cs{deferred@thm@head} (just outside the
+% ending brace below) results in no improvement if no text follows
+% the heading, and where there is text, runs it in. Inserting a
+% space following such a heading results in an extra blank line.
+% [bnb, 2004/06/30]
+% \begin{macrocode}
+ \thmheadnl % possibly a newline.
+ \hskip\thm@headsep
+ }%
+ \ignorespaces}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newskip\thm@headsep
+\thm@headsep=5pt plus1pt minus1pt\relax
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\adjust@parskip@nobreak=\@nbitem
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newtoks\dth@everypar
+\dth@everypar={%
+ \@minipagefalse \global\@newlistfalse
+ \@noparitemfalse
+ \if@inlabel
+ \global\@inlabelfalse
+ \begingroup \setbox\z@\lastbox
+ \ifvoid\z@ \kern-\itemindent \fi
+ \endgroup
+ \unhbox\@labels
+ \fi
+ \if@nobreak \@nobreakfalse \clubpenalty\@M
+ \else \clubpenalty\@clubpenalty \everypar{}%
+ \fi
+}%
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\deferred@thm@head#1{%
+ \if@inlabel \indent \par \fi % eject a section head if one is pending
+ \if@nobreak
+% \end{macrocode}
+% This case normally arises when a theorem follows immediately after
+% a section head. Then we leave the below-section-head space instead
+% of adding above-theorem space; but some adjustment of parskip is
+% needed.
+% \begin{macrocode}
+ \adjust@parskip@nobreak
+ \else
+ \addpenalty\@beginparpenalty
+ \addvspace\@topsep
+ \addvspace{-\parskip}%
+ \fi
+ \global\@inlabeltrue
+ \everypar\dth@everypar
+ \sbox\@labels{\normalfont#1}%
+ \ignorespaces
+}
+% \end{macrocode}
+%
+% \begin{macro}{\nonslanted}
+% The \cn{nonslanted} command changes the current font to
+% \cn{upshape} if it is \cn{itshape} or \cn{slshape}. This is used
+% for document structure numbers that should be consistently upright
+% in all contexts.
+% \begin{macrocode}
+\def\nonslanted{\relax
+% \end{macrocode}
+% Can't do a direct \cs{ifx} between \cs{f@shape} and \cs{itdefault}
+% because the latter is \cs{long} (grumble grumble).
+% \begin{macrocode}
+ \@xp\let\@xp\@tempa\csname\f@shape shape\endcsname
+ \ifx\@tempa\itshape\upshape
+ \else\ifx\@tempa\slshape\upshape\fi\fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\swapnumbers}
+% The \cn{swapnumbers} command sets a switch \cs{thm@swap} that is
+% used by \cn{newtheorem}. To conserve hash table we load
+% \cs{thm@swap} with two uses; the first one is needed only in
+% \cn{newtheorem} declarations and the second one is needed only in
+% typesetting theorem environments.
+% \begin{macrocode}
+\def\swapnumbers{\edef\thm@swap{\if S\thm@swap N\else S\fi}}
+\def\thm@swap{N}%
+% \end{macrocode}
+% \end{macro}
+%
+% \cs{@opargbegintheorem} not needed, \cs{@oparg} utility serves
+% instead.
+% \begin{macrocode}
+\let\@opargbegintheorem\relax
+% \end{macrocode}
+%
+% Except for the body font, default values are built into \cs{@thm}.
+% \begin{macrocode}
+\def\th@plain{%
+%% \let\thm@indent\noindent % no indent
+%% \thm@headfont{\bfseries}% heading font is bold
+%% \thm@notefont{}% same as heading font
+%% \thm@headpunct{.}% add period after heading
+%% \let\thm@swap\@gobble
+%% \thm@preskip\topsep
+%% \thm@postskip\theorempreskipamount
+ \itshape % body font
+}
+% \end{macrocode}
+%
+% Theorem style `definition' is the same as `plain' except for the
+% body font.
+% \begin{macrocode}
+\def\th@definition{%
+ \normalfont % body font
+}
+% \end{macrocode}
+%
+% Theorem style `remark' differs from `plain' in head font and body
+% font. Also smaller spacing above and below for AMS classes only.
+% \begin{macrocode}
+\def\th@remark{%
+%<amsart|amsthm> \thm@headfont{\itshape}%
+ \normalfont % body font
+%<*amsthm>
+ \thm@preskip\topsep \divide\thm@preskip\tw@
+ \thm@postskip\thm@preskip
+%</amsthm>
+}
+% \end{macrocode}
+%
+% The standard definition of \cs{@endtheorem} is just
+% \cs{endtrivlist}, but that doesn't automatically start a new
+% paragraph, so we add \cs{@endpefalse} in order to ensure a new
+% paragraph. This differs from the basic \latex/ behavior.
+% \begin{macrocode}
+\def\@endtheorem{\endtrivlist\@endpefalse }
+% \end{macrocode}
+%
+% \begin{macro}{\newtheoremstyle}
+% An easy way to make a not too complicated variant theorem style.
+% Usage:
+%\begin{verbatim}
+% #1
+% \newtheoremstyle{NAME}%
+% #2 #3 #4
+% {ABOVESPACE}{BELOWSPACE}{BODYFONT}%
+% #5 #6 #7 #8
+% {INDENT}{HEADFONT}{HEADPUNCT}{HEADSPACE}%
+% #9
+% {CUSTOM-HEAD-SPEC}
+%\end{verbatim}
+% \begin{macrocode}
+\newcommand{\newtheoremstyle}[9]{%
+% \end{macrocode}
+% Empty or 0pt for \arg{5} is translated to \cs{noindent}.
+% \begin{macrocode}
+ \@ifempty{#5}{\dimen@\z@skip}{\dimen@#5\relax}%
+ \ifdim\dimen@=\z@
+% \end{macrocode}
+% \arg{4} is body font. Extra code could be included there if
+% necessary.
+% \begin{macrocode}
+ \toks@{#4\let\thm@indent\noindent}%
+ \else
+ \toks@{#4\def\thm@indent{\noindent\hbox to#5{}}}%
+ \fi
+% \end{macrocode}
+% Arg \arg{8} is a glue spec for the space after the head. As
+% a proper glue spec for `normal interword space' is rather hard to
+% write, we recognize an argument of |{ }| as a special case and
+% translate internally to the necessary fontdimen equivalent.
+% Furthermore, if \arg{8} consists entirely of \cn{newline}, then we
+% will perform a line break after the theorem head instead of adding
+% horizontal space. At the moment [1995/01/23] this is not perfectly
+% well implemented because of complications with the way \latex/'s
+% \cn{item} adds a heading to the vertical list; for best results
+% there should not be anything (not even a blank line) after the
+% |\begin{xxx}| command.
+% \begin{macrocode}
+ \def\@tempa{#8}\ifx\space\@tempa
+% \end{macrocode}
+% Notice that we disregard stretch and shrink for labelsep =
+% interwordspace.
+% \begin{macrocode}
+ \toks@\@xp{\the\toks@ \thm@headsep\fontdimen\tw@\font\relax}%
+ \else
+ \def\@tempb{\newline}%
+ \ifx\@tempb\@tempa
+ \toks@\@xp{\the\toks@ \thm@headsep\z@skip
+ \def\thmheadnl{\newline}}%
+ \else
+ \toks@\@xp{\the\toks@ \thm@headsep#8\relax}%
+ \fi
+ \fi
+ \begingroup
+ \thm@space@setup
+ \@defaultunits\@tempskipa#2\thm@preskip\relax\@nnil
+ \@defaultunits\@tempskipb#3\thm@postskip\relax\@nnil
+ \xdef\@gtempa{\thm@preskip\the\@tempskipa
+ \thm@postskip\the\@tempskipb\relax}%
+ \endgroup
+ \@temptokena\@xp{\@gtempa
+ \thm@headfont{#6}\thm@headpunct{#7}%
+ }%
+ \@ifempty{#9}{%
+ \let\thmhead\thmhead@plain
+ }{%
+ \@namedef{thmhead@#1}##1##2##3{#9}%
+ \@temptokena\@xp{\the\@temptokena
+ \@xp\let\@xp\thmhead\csname thmhead@#1\endcsname}%
+ }%
+ \@xp\xdef\csname th@#1\endcsname{\the\toks@ \the\@temptokena}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\qed}
+% Define \cn{qed} for end of proof. This command might
+% occur in math mode, in a displayed equation, but it should never
+% occur in inner math mode in ordinary paragraph text.
+% \begin{macrocode}
+\DeclareRobustCommand{\qed}{%
+ \ifmmode \mathqed
+ \else
+ \leavevmode\unskip\penalty9999 \hbox{}\nobreak\hfill
+% \end{macrocode}
+% The hbox is to prevent a line break within the \cn{qedsymbol} if it
+% is defined to be something composite--- e.g., things like
+% \verb"(Corollary 1.2) \openbox" as are occasionally done.
+% \begin{macrocode}
+ \quad\hbox{\qedsymbol}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Setup for QED stack. We use a dedicated iterator macro \cs{qed@elt}
+% instead of the generic \cs{@elt} because the \latex/ output routine
+% is not safe against changes in \cs{@elt}. Therefore it is not safe
+% to use \cs{@elt} for any processing that might trigger the output
+% routine. Although this does not seem very likely when adding a QED
+% symbol to a horizontal list, we did in fact get a bug report for
+% this kind of failure.
+% \begin{macrocode}
+\let\QED@stack\@empty
+\let\qed@elt\relax
+% \end{macrocode}
+%
+% Puts a QED symbol on the stack:
+% \begin{macrocode}
+\newcommand{\pushQED}[1]{%
+ \toks@{\qed@elt{#1}}\@temptokena\expandafter{\QED@stack}%
+ \xdef\QED@stack{\the\toks@\the\@temptokena}%
+}
+% \end{macrocode}
+%
+% Pops the QED stack and prints the result.
+% \begin{macrocode}
+\newcommand{\popQED}{%
+ \begingroup\let\qed@elt\popQED@elt \QED@stack\relax\relax\endgroup
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\popQED@elt#1#2\relax{#1\gdef\QED@stack{#2}}
+% \end{macrocode}
+%
+% Prints the current QED symbol and replaces the top entry on the
+% stack with a null entry.
+% \begin{macrocode}
+\newcommand{\qedhere}{%
+ \begingroup \let\mathqed\math@qedhere
+ \let\qed@elt\setQED@elt \QED@stack\relax\relax \endgroup
+}
+% \end{macrocode}
+%
+% In case the \pkg{amsmath} or \pkg{amstext} packages are loaded, we
+% need the following two tests. (Redundantly declaring them is
+% harmless.)
+% \begin{macrocode}
+\newif\ifmeasuring@
+\newif\iffirstchoice@ \firstchoice@true
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\setQED@elt#1#2\relax{%
+ \ifmeasuring@
+ \else \iffirstchoice@ \gdef\QED@stack{\qed@elt{}#2}\fi
+ \fi
+ #1%
+}
+% \end{macrocode}
+%
+% \begin{macro}{\mathqed}
+% When a QED occurs inside a math formula, well, it is presumably a
+% displayed equation. In order to find out where to place the QED
+% symbol, we need to check what kind of equation structure we are in.
+%
+% \begin{macrocode}
+\def\qed@warning{%
+ \PackageWarning{amsthm}{The \@nx\qedhere command may not work
+ correctly here}%
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newcommand{\mathqed}{\quad\hbox{\qedsymbol}}
+% \end{macrocode}
+%
+% The \cs{linebox@qed} function comes into play with the \opt{fleqn}
+% option.
+% \begin{macrocode}
+\def\linebox@qed{\hfil\hbox{\qedsymbol}\hfilneg}
+% \end{macrocode}
+% \end{macro}
+%
+% Two large sections of code follow. One for \fn{amsmath} 2.0 and one
+% for plain \latex/.
+% \begin{macrocode}
+\@ifpackageloaded{amsmath}{%
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \def\math@qedhere{%
+ \@ifundefined{\@currenvir @qed}{%
+ \qed@warning\quad\hbox{\qedsymbol}%
+ }{%
+ \@xp\aftergroup\csname\@currenvir @qed\endcsname
+ }%
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \def\displaymath@qed{%
+ \relax
+ \ifmmode
+ \ifinner \aftergroup\linebox@qed
+ \else
+ \eqno
+ \let\eqno\relax \let\leqno\relax \let\veqno\relax
+ \hbox{\qedsymbol}%
+ \fi
+ \else
+ \aftergroup\linebox@qed
+ \fi
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \@xp\let\csname equation*@qed\endcsname\displaymath@qed
+% \end{macrocode}
+%
+% If the equation has both an equation number and a qed, we've got
+% trouble, but we can provide half-way decent for the simple cases.
+% \begin{macrocode}
+ \def\equation@qed{%
+ \iftagsleft@
+ \hbox{\phantom{\quad\qedsymbol}}%
+ \gdef\alt@tag{%
+ \rlap{\hbox to\displaywidth{\hfil\qedsymbol}}%
+ \global\let\alt@tag\@empty
+ }%
+ \else
+ \gdef\alt@tag{%
+ \global\let\alt@tag\@empty
+ \vtop{\ialign{\hfil####\cr
+ \tagform@\theequation\cr
+ \qedsymbol\cr}}%
+ \setbox\z@
+ }%
+ \fi
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \def\qed@tag{%
+ \global\tag@true \nonumber
+ &\omit\setboxz@h {\strut@ \qedsymbol}\tagsleft@false
+ \place@tag@gather
+ \kern-\tabskip
+ \ifst@rred \else \global\@eqnswtrue \fi \global\advance\row@\@ne \cr
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \def\split@qed{%
+ \def\endsplit{\crcr\egroup \egroup \ctagsplit@false \rendsplit@
+ \aftergroup\align@qed
+ }%
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \def\align@qed{%
+ \ifmeasuring@ \tag*{\qedsymbol}%
+ \else \let\math@cr@@@\qed@tag
+ \fi
+ }
+ \@xp\let\csname align*@qed\endcsname\align@qed
+ \@xp\let\csname gather*@qed\endcsname\align@qed
+% \end{macrocode}
+%
+% \begin{macrocode}
+%% Needs some patching up for amsmath 1.2
+% \end{macrocode}
+%
+% \begin{macrocode}
+}{% end of amsmath branch, start plain LaTeX branch
+% \end{macrocode}
+%
+% The \cn{qedhere} handling for generic \latex/ classes (\cls{article},
+% \cls{book}) with the \pkg{amsthm} package (without \pkg{amsmath}) is
+% fairly sketchy. When a qed symbol and an equation number are both
+% applied to a single display, the results may not be entirely
+% satisfactory, particularly when the \opt{fleqn} and/or \opt{leqno}
+% options are used. [mjd,2000/01/17]
+%
+% As for \cs{math@qedhere}, it is expected to occur only via
+% \cn{qedhere}, where the \cs{aftergroup} makes sense.
+% \begin{macrocode}
+ \def\math@qedhere{%
+ \@ifundefined{\@currenvir @qed}{%
+ \qed@warning \aftergroup\displaymath@qed
+ }{%
+ \@xp\aftergroup\csname\@currenvir @qed\endcsname
+ }%
+ }
+% \end{macrocode}
+%
+% The \cs{ifmmode} \cs{ifinner} case is expected to happen with the
+% \opt{fleqn} option, where we have something like:
+%\begin{verbatim}
+%\hbox to\linewidth{\hbox{$...$}\hfil}
+%\end{verbatim}
+% In order to counteract the \cs{hfil} we must jump out two grouping
+% levels.
+% \begin{macrocode}
+ \def\displaymath@qed{%
+ \relax
+ \ifmmode
+ \ifinner \aftergroup\aftergroup\aftergroup\linebox@qed
+ \else
+ \eqno \def\@badmath{$$}%
+ \let\eqno\relax \let\leqno\relax \let\veqno\relax
+ \hbox{\qedsymbol}%
+ \fi
+ \else
+ \aftergroup\linebox@qed
+ \fi
+ }
+% \end{macrocode}
+%
+% This definition is a fallback definition that places the qed and
+% then the equation number, on the right-hand side. For \opt{leqno},
+% not so good; but then
+% \begin{macrocode}
+ \@ifundefined{ver@leqno.clo}{%
+ \def\equation@qed{\displaymath@qed \quad}%
+ }{%
+ \def\equation@qed{\displaymath@qed}%
+ }
+% \end{macrocode}
+%
+% If \pkg{amsmath} is not loaded, then we need to do some surgery
+% on the \cn{[} macro. Normally it looks like this:
+%\begin{verbatim}
+% \[=macro:
+% ->\relax \ifmmode \@badmath \else
+% \ifvmode \nointerlineskip \makebox [.6\linewidth ]\fi $$\fi
+%\end{verbatim}
+%
+% If arg 2 is \cs{m@th} when we make this test it indicates that the
+% fleqn option is in effect. Perhaps try to do something there.
+% \begin{macrocode}
+ \def\@tempa#1$#2#3\@nil{%
+ \def\[{#1$#2\def\@currenvir{displaymath}#3}%
+ }%
+ \expandafter\@tempa\[\@nil
+}
+% \end{macrocode}
+%
+% If an older version of \pkg{amsmath} is in use, we need to fall
+% back to a simpler definition of \cs{math@qedhere}.
+% \begin{macrocode}
+\@ifpackageloaded{amstex}{%
+ \def\@tempa{TT}%
+}{%
+ \@ifpackageloaded{amsmath}{%
+ \def\@tempb#1 v#2.#3\@nil{#2}%
+ \ifnum\@xp\@xp\@xp\@tempb\csname ver@amsmath.sty\endcsname v0.0\@nil
+ <\tw@
+ \def\@tempa{TT}%
+ \else
+ \def\@tempa{TF}%
+ \fi
+ }{%
+ \def\@tempa{TF}
+ }%
+}
+\if\@tempa
+ \renewcommand{\math@qedhere}{\quad\hbox{\qedsymbol}}%
+\fi
+% \end{macrocode}
+%
+% The reason that we do not simply use the \cn{square} symbol from
+% \fn{msam} for the open-box qed symbol is that we want to avoid
+% requiring users to have the AMSFonts font package. And the \fn{lasy}
+% \cn{Box} is too large.
+% \begin{macrocode}
+\newcommand{\openbox}{\leavevmode
+% \end{macrocode}
+% I think I got these numbers from measuring \fn{msam}'s \cn{square}
+% but I forgot to make notes at the time. [mjd,1995/01/25]
+% \begin{macrocode}
+ \hbox to.77778em{%
+ \hfil\vrule
+ \vbox to.675em{\hrule width.6em\vfil\hrule}%
+ \vrule\hfil}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareRobustCommand{\textsquare}{%
+ \begingroup \usefont{U}{msa}{m}{n}\thr@@\endgroup
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<*classes>
+\@ifclasswith{\@classname}{noamsfonts}{%
+ \providecommand{\qedsymbol}{\openbox}%
+}{}
+\providecommand{\qedsymbol}{\textsquare}
+%</classes>
+%<amsthm>\providecommand{\qedsymbol}{\openbox}
+% \end{macrocode}
+%
+% The proof environment is never numbered, and has a \cn{qed} at the
+% end, which makes it inconvenient to use \cn{newtheorem} for
+% defining it. Also authors frequently need to substitute an
+% alternative heading text (e.g.\ `Proof of Lemma 4.3')
+% instead of the default `Proof'. For all these reasons we define the
+% proof environment here instead of leaving it for authors to define.
+% Text after the end of a proof, like that after the end of a theorem,
+% begins a new paragraph. This differs from basic \latex/ behavior.
+% [bnb, 1999/09/27]
+% \begin{macrocode}
+\newenvironment{proof}[1][\proofname]{\par
+ \pushQED{\qed}%
+ \normalfont \topsep6\p@\@plus6\p@\relax
+ \trivlist
+%<amsbook|amsproc> \itemindent\normalparindent
+ \item[\hskip\labelsep
+%<amsbook|amsproc> \scshape
+%<amsart|amsthm> \itshape
+ #1\@addpunct{.}]\ignorespaces
+}{%
+ \popQED\endtrivlist\@endpefalse
+}
+% \end{macrocode}
+% Default for \cn{proofname}:
+% \begin{macrocode}
+\providecommand{\proofname}{Proof}
+% \end{macrocode}
+%
+% For reference:
+%\begin{verbatim}
+% From: tycchow@math.mit.edu (Timothy Y. Chow)
+% Subject: Suppressing theorem numbering in LaTeX
+% Message-ID: <1994Aug11.234754.22523@galois.mit.edu>
+% Date: Thu, 11 Aug 94 23:47:54 GMT
+% To: tex-news@SHSU.EDU
+%
+% A friend of mine wants numbering of theorems, conjectures, and so on
+% suppressed if there is only one of them in his article. In other words
+% he wants "Conjecture 1" to appear as simply "Conjecture" if there is no
+% Conjecture 2. What is the best way to go about doing this?
+% ...
+%\end{verbatim}
+% Maybe something clever can be done to make the desired behavior
+% happen automatically. Note that this would seem to be a general
+% numbering problem rather than a theorem-specific one, because
+% similar behavior would be desirable for appendixes: according to
+% standard publishing practice, if there's only one it is titled just
+% `Appendix', and if there are more than one they are titled
+% `Appendix A', `Appendix B', and so on.
+%
+% \begin{macrocode}
+%</amsthm|classes>
+%<*classes>
+% \end{macrocode}
+%
+% \subsection{Utility commands used with AMS author packages}
+%
+% \begin{macro}{\bb@skip}
+% Skip to result in base-to-base distance from previous to next box.
+% \begin{macrocode}
+\def\bb@skip#1{%
+ \skip@#1\relax \advance\skip@-\prevdepth \advance\skip@-\baselineskip
+ \vskip\skip@}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\markleft}
+% Basic \latex/ has \cn{markright} and \cn{markboth}, but sometimes
+% it's necessary to change just the left running head. This macro
+% completes the set. From the \pkg{altxext.sty} module of Klaus
+% Lagally's \pkg{arabtex}. [bnb, 2004/03/25]
+% \begin{macrocode}
+\def\markleft#1{{\let\protect\noexpand
+ \let\label\relax \let\index\relax \let\glossary\relax
+ \expandafter\@markleft\@themark{#1}%
+ \mark{\@themark}}%
+ \if@nobreak\ifvmode\nobreak\fi\fi}
+\def\@markleft#1#2#3{\gdef\@themark{{#3}{#2}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DH}
+% \begin{macro}{\dh}
+% \begin{macro}{\DJ}
+% \begin{macro}{\dj}
+% The Icelandic thorn and eth and the Croatian barred D are part of
+% the T1 font encoding, but aren't available in OT1. However, they
+% are needed (rarely) in the author names or bibliographies. Provide
+% emulations, using the thorn in \fn{msbm} or D's barred with a macron.
+% The lowercase eth requires an \cs{edef} to access \fn{msbm} properly.
+% Define it separately to permit checking for small caps. [bnb, 2004/04/05]
+% \begin{macrocode}
+\def\@tempa{}
+\edef\@dh{%
+ \noexpand\mathhexbox{\hexnumber@\symAMSb}67}
+\DeclareTextCommand{\dh}{OT1}{%
+ \edef\@tempb{\scdefault}%
+ \ifx\f@shape\@tempb
+ \leavevmode
+ \raisebox{-.8ex}{\makebox[\z@][l]{\hskip-.08em\accent"16\hss}}d%
+ \else
+ \@dh
+ \fi
+}
+\DeclareTextCommand{\DH}{OT1}{%
+ \leavevmode\raisebox{-.5ex}{\makebox[\z@][l]{\hskip-.07em\accent"16\hss}}D}
+\DeclareTextCommand{\DJ}{OT1}{%
+ \leavevmode\raisebox{-.5ex}{\makebox[\z@][l]{\hskip-.07em\accent"16\hss}}D}
+\DeclareTextCommand{\dj}{OT1}{%
+ \edef\@tempa{\f@shape}\edef\@tempb{\scdefault}%
+ \ifx\@tempa\@tempb
+ \leavevmode
+ \raisebox{-.75ex}{\makebox[\z@][l]{\hskip-.08em\accent"16\hss}}d%
+ \else
+ \leavevmode\raisebox{.02ex}{\makebox[\z@][l]{\hskip.1em\accent"16\hss}}d%
+ \fi}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Hyphenation exceptions}
+% Some common hyphenation exceptions, based on the listing in
+% TUGboat vol 10, no 3, November 1989, pp.~336--341. Many words from
+% the TUGboat list that seemed less likely to occur in mathematical
+% text have been omitted because hyphenation exceptions use up memory
+% (most versions of \tex/ currently have a limit of 307 on hyphenation
+% exceptions; each added hyphenation exception uses up something like
+% 2 extra words of main memory as well). The list of hyphenations for
+% proper names could be expanded forever if room permitted; we
+% restrict ourselves to a rather short, extremely arbitrary list.
+% Note that the hyphenation rules of British English differ in some
+% particulars from the US rules, so some of the hyphenations
+% given below may need to be overridden for proper UK hyphenation.
+%
+% \begin{macrocode}
+\hyphenation{acad-e-my acad-e-mies af-ter-thought anom-aly anom-alies
+an-ti-deriv-a-tive an-tin-o-my an-tin-o-mies apoth-e-o-ses
+apoth-e-o-sis ap-pen-dix ar-che-typ-al as-sign-a-ble as-sist-ant-ship
+as-ymp-tot-ic asyn-chro-nous at-trib-uted at-trib-ut-able bank-rupt
+bank-rupt-cy bi-dif-fer-en-tial blue-print busier busiest
+cat-a-stroph-ic cat-a-stroph-i-cally con-gress cross-hatched data-base
+de-fin-i-tive de-riv-a-tive dis-trib-ute dri-ver dri-vers eco-nom-ics
+econ-o-mist elit-ist equi-vari-ant ex-quis-ite ex-tra-or-di-nary
+flow-chart for-mi-da-ble forth-right friv-o-lous ge-o-des-ic
+ge-o-det-ic geo-met-ric griev-ance griev-ous griev-ous-ly
+hexa-dec-i-mal ho-lo-no-my ho-mo-thetic ideals idio-syn-crasy
+in-fin-ite-ly in-fin-i-tes-i-mal ir-rev-o-ca-ble key-stroke
+lam-en-ta-ble light-weight mal-a-prop-ism man-u-script mar-gin-al
+meta-bol-ic me-tab-o-lism meta-lan-guage me-trop-o-lis
+met-ro-pol-i-tan mi-nut-est mol-e-cule mono-chrome mono-pole
+mo-nop-oly mono-spline mo-not-o-nous mul-ti-fac-eted mul-ti-plic-able
+non-euclid-ean non-iso-mor-phic non-smooth par-a-digm par-a-bol-ic
+pa-rab-o-loid pa-ram-e-trize para-mount pen-ta-gon phe-nom-e-non
+post-script pre-am-ble pro-ce-dur-al pro-hib-i-tive pro-hib-i-tive-ly
+pseu-do-dif-fer-en-tial pseu-do-fi-nite pseu-do-nym qua-drat-ic
+quad-ra-ture qua-si-smooth qua-si-sta-tion-ary qua-si-tri-an-gu-lar
+quin-tes-sence quin-tes-sen-tial re-arrange-ment rec-tan-gle
+ret-ri-bu-tion retro-fit retro-fit-ted right-eous right-eous-ness
+ro-bot ro-bot-ics sched-ul-ing se-mes-ter semi-def-i-nite
+semi-ho-mo-thet-ic set-up se-vere-ly side-step sov-er-eign spe-cious
+spher-oid spher-oid-al star-tling star-tling-ly sta-tis-tics
+sto-chas-tic straight-est strange-ness strat-a-gem strong-hold
+sum-ma-ble symp-to-matic syn-chro-nous topo-graph-i-cal tra-vers-a-ble
+tra-ver-sal tra-ver-sals treach-ery turn-around un-at-tached
+un-err-ing-ly white-space wide-spread wing-spread wretch-ed
+wretch-ed-ly Eng-lish Euler-ian Feb-ru-ary Gauss-ian
+Hamil-ton-ian Her-mit-ian Jan-u-ary Japan-ese Kor-te-weg
+Le-gendre Mar-kov-ian Noe-ther-ian No-vem-ber Rie-mann-ian Sep-tem-ber}
+% \end{macrocode}
+%
+% \subsection{Initialization}
+% We define a function to do the normal calculations that we want for
+% \cn{textheight} and \cn{textwidth}
+%
+% \begin{macro}{\calclayout}
+% Subtract the height of the running heads:
+% \begin{macrocode}
+\def\calclayout{\advance\textheight -\headheight
+ \advance\textheight -\headsep
+% \end{macrocode}
+% We set \cn{oddsidemargin} and \cn{evensidemargin} to
+% center the text on the page.
+% \begin{macrocode}
+ \oddsidemargin\paperwidth
+ \advance\oddsidemargin -\textwidth
+ \divide\oddsidemargin\tw@
+% \end{macrocode}
+% Now we subtract the default margin provided by standard DVI
+% drivers. But first we make sure that the final margin will
+% be at least .5 inch.
+% \begin{macrocode}
+ \ifdim\oddsidemargin<.5truein \oddsidemargin.5truein \fi
+ \advance\oddsidemargin -1truein
+ \evensidemargin\oddsidemargin
+% \end{macrocode}
+% And we set \cn{topmargin} to get vertical centering as well.
+% \begin{macrocode}
+ \topmargin\paperheight \advance\topmargin -\textheight
+ \advance\topmargin -\headheight \advance\topmargin -\headsep
+% \end{macrocode}
+% Height of running foot ignored: not present.
+% \begin{macrocode}
+ \divide\topmargin\tw@
+% \end{macrocode}
+% We provide a minimum of .5in (after compensating for the default
+% margin---see next step).
+% \begin{macrocode}
+ \ifdim\topmargin<.5truein \topmargin.5truein \fi
+% \end{macrocode}
+% Now subtract the default margin provided by standard DVI
+% drivers.
+% \begin{macrocode}
+ \advance\topmargin -1truein\relax
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Initialize the dimensions, page numbering, etc. For inhouse use,
+% administrative stuff is isolated in separate files.
+% \begin{macrocode}
+%<amsart>\InputIfFileExists{amsart.cfg}{}{%
+%<amsproc>\InputIfFileExists{amsproc.cfg}{}{%
+%<amsbook>\InputIfFileExists{amsbook.cfg}{}{%
+ \calclayout % initialize
+ \pagenumbering{arabic}%
+ \pagestyle{headings}%
+ \thispagestyle{plain}%
+}
+% \end{macrocode}
+%
+% If we are in compatibility mode, add some backward compatibility
+% stuff below. Otherwise quit here.
+% \begin{macrocode}
+\if@compatibility \else\endinput\fi
+% \end{macrocode}
+%
+% Compensate for changed meaning of \cn{tiny}:
+% \begin{macrocode}
+\def\tiny{\Tiny}
+% \end{macrocode}
+%
+% The macro \cn{defaultfont} was provided in version 1.1 of amsart;
+% retained for compatibility as a synonym of \cn{normalfont}. Resets
+% everything except for size.
+% \begin{macrocode}
+\def\defaultfont{\normalfont}
+% \end{macrocode}
+%
+% Macro for making non-slanted numbers and punctuation in italic
+% or slanted text. This is to avoid visual inconsistencies
+% between numbers or parentheses in math and adjacent numbers or
+% parentheses in text.
+% \begin{macrocode}
+\def\rom{\textup}
+% \end{macrocode}
+%
+% For backward compatibility with version 1.1 of \cls{amsart}, we
+% define \env{pf}, \env{pf*} environments. And undefine \cn{proof}
+% just in case an existing document contains a \cn{newenvironment} or
+% \cn{newcommand} for it, as that would now cause an error.
+% \begin{macrocode}
+\let\@newpf\proof \let\proof\relax \let\endproof\relax
+\newenvironment{pf}{\@newpf[\proofname]}{\popQED\endtrivlist}
+\newenvironment{pf*}[1]{\@newpf[#1]}{\popQED\endtrivlist}
+% \end{macrocode}
+%
+% The usual \cn{endinput} to ensure that random garbage at the end of
+% the file doesn't get copied by \fn{docstrip}.
+% \begin{macrocode}
+\endinput
+%</classes>
+% \end{macrocode}
+%
+% \changes{v1.2a}{1995/02/01}{Added global init for @secnumber}
+% \changes{v1.2a}{1995/02/01}{Made psamsfonts option pass cmex10 to
+% amsmath}
+% \changes{v1.2a}{1995/02/01}{Added missing endpar after authors in
+% amsbook @maketitle}
+%
+% \changes{v1.2b}{1995/02/20}{Improve handling of abstract}
+% \changes{v1.2b}{1995/02/20}{Allow titlepage option for articles}
+% \changes{v1.2b}{1995/02/20}{Suppress logo and copyright info for
+% generic AMS classes}
+% \changes{v1.2b}{1995/02/20}{Use `Date' instead of `Received by...' in
+% the generic AMS classes}
+%
+% \changes{v2.13}{2002/12/06}{Added a warning for thanks inside author}
+%
+% \CheckSum{5682}
+% \Finale
diff --git a/Master/texmf-dist/source/latex/amslatex/amsdtx.dtx b/Master/texmf-dist/source/latex/amslatex/amsdtx.dtx
new file mode 100644
index 00000000000..cd9bb13b2c2
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/amsdtx.dtx
@@ -0,0 +1,1192 @@
+%%% ====================================================================
+%%% @LaTeX-file{
+%%% filename = "amsdtx.dtx",
+%%% version = "2.06",
+%%% date = "2004/08/06",
+%%% time = "12:18:49 EDT",
+%%% checksum = "19929 1192 3506 39423",
+%%% author = "Michael J. Downes, updated by David M. Jones",
+%%% copyright = "Copyright 1996, 1999, 2004
+%%% 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.",
+%%% address = "American Mathematical Society,
+%%% Technical Support,
+%%% Publications Technical Group,
+%%% 201 Charles Street,
+%%% Providence, RI 02904,
+%%% USA",
+%%% telephone = "401-455-4080 or (in the USA and Canada)
+%%% 800-321-4AMS (321-4267)",
+%%% FAX = "401-331-3842",
+%%% email = "tech-support@ams.org (Internet)",
+%%% codetable = "ISO/ASCII",
+%%% keywords = "latex, amslatex, ams-latex, user documentation",
+%%% supported = "yes",
+%%% abstract = "This is the source for two document classes, amsdtx
+%%% and amsldoc, 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}
+
+\makeindex
+
+\CodelineIndex
+
+\begin{document}
+\title{The \cls{amsldoc} and \cls{amsdtx} document classes}
+\author{American Mathematical Society\\Michael Downes\\
+ updated by David M. Jones}
+\date{Version \fileversion, \filedate}
+\hDocInput{amsdtx.dtx}
+\PrintIndex
+\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
+%
+% \tableofcontents
+%
+% \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{bst}& \rp To print the name of a \bibtex/ style
+% \verb"\bst{amsalpha}"\\
+% \cn{fn}& \rp To print a file name or font name: \verb"\fn{T1enc.def}",
+% \verb"\fn{cmsy10}"\\
+% \cn{fnt}& \rp To print a font name: \verb"\fn{cmsy10}" \\
+% \cn{cnt}& \rp To print a counter name: \verb"\fn{topnumber}" \\
+% \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)
+[1995/06/01]% LaTeX date must be June 1995 or later
+%<*amsldoc>
+\ProvidesClass{amsldoc}[2004/08/06 v2.06]
+%</amsldoc>
+%<*amsdtx>
+\ProvidesClass{amsdtx}[2004/08/06 v2.06]
+%</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\penalty\exhyphenpenalty}
+\providecommand{\ndash}{\textendash\penalty\exhyphenpenalty}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\@xp\expandafter
+% \end{macrocode}
+% \section{Indexing primitives}
+%
+% Unlike \pkg{amsdtx}, \pkg{amsldoc} doesn't load the \pkg{doc}
+% package, so we need to provide the following logical names. The
+% values are consistent with \fn{makeindex}'s default conventions.
+% \begin{macrocode}
+%<*amsldoc>
+\def\actualchar{@}
+\def\quotechar{"}
+\def\levelchar{!}
+\def\encapchar{|}
+\def\verbatimchar{+}
+% \end{macrocode}
+% We also need the \cs{ifcodeline@index} switch.
+% \begin{macrocode}
+\newif\ifcodeline@index
+%</amsldoc>
+% \end{macrocode}
+%
+% \begin{macro}{\autoindex}
+% When generating a codeline index, this encapsulates the page
+% number in italics.
+% \begin{macrocode}
+\newcommand*{\autoindex}[1]{%
+ \index{#1\ifcodeline@index\encapchar usage\fi}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ntt}
+% 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}
+% \end{macro}
+%
+% \begin{macro}{\indexcs}
+% Index a control sequence without printing it. Note
+% non-long. The \cs{@nobslash} strips off an optional leading
+% backslash before passing the control sequence name to
+% \cs{@indexcs}. This means that |\indexcs{\cs}| and
+% |\indexcs{cs}| produce the same index entry.
+% \begin{macrocode}
+\newcommand*{\indexcs}[1]{%
+ \@xp\@xp\@xp\@indexcs\@xp\@nobslash\string#1\@nil
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@indexcs}
+% Given |cs| as an argument, this writes something like
+% |cs@\verb"*+\cs+| to the \fn{.idx} file (or |cs=\verb!*+\cs+| if
+% using \fn{doc.sty}).
+% \begin{macrocode}
+\def\@indexcs#1\@nil{%
+ \autoindex{#1\actualchar
+ \string\verb\quotechar*\verbatimchar
+ \@xp\@bothoftwo\string\ #1\@empty
+ \verbatimchar
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@bothoftwo}
+% This has the effect of removing spaces before each of the
+% arguments. In particular, it removes the space generated by
+% \verb*+\string\ + above.
+% \begin{macrocode}
+\def\@bothoftwo#1#2{#1#2}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\category@index}
+% \begin{macrocode}
+\def\category@index#1#2{%
+ {\ntt#2}%
+ \@category@index{#1}{#2}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@category@index}
+% \begin{macrocode}
+\def\@category@index#1#2{%
+ \autoindex{%
+ #2\actualchar\string\texttt{#2}%
+ \ifx\@nil#1\@nil\else\space#1\fi
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% 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 \LaTeXe\ 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}
+%
+% \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
+ \@xp\@xp\@xp\@indexcs\@xp\@nobslash\string#1\@nil
+ }%
+}
+% \end{macrocode}
+%
+% Allow distinguishing non-private `command names' that will be
+% visible to the user from internal (mostly private) `control
+% sequences'.
+% \begin{macrocode}
+\let\cn\cs
+% \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}{\category@index{class}}
+% \end{macrocode}
+%
+% \latex/ package name.
+% \begin{macrocode}
+\DeclareRobustCommand{\pkg}{\category@index{package}}
+% \end{macrocode}
+%
+% \latex/ option name.
+% \begin{macrocode}
+\DeclareRobustCommand{\opt}{\category@index{option}}
+% \end{macrocode}
+%
+% Environment name.
+% \begin{macrocode}
+%<amsdtx>\DeclareRobustCommand{\env}[1]{{\ntt#1}\SpecialEnvIndex{#1}}
+%<amsldoc>\DeclareRobustCommand{\env}{\category@index{environment}}
+% \end{macrocode}
+%
+% File name.
+% \begin{macrocode}
+\DeclareRobustCommand{\fn}{\category@index{}}
+% \end{macrocode}
+%
+% \bibtex/ style.
+% \begin{macrocode}
+\DeclareRobustCommand{\bst}{\category@index{\string\BibTeX{} style}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareRobustCommand{\cnt}{\category@index{counter}}
+\DeclareRobustCommand{\fnt}{\category@index{font}}
+% \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]{}
+%</amsldoc>
+\newcommand*{\secref}[1]{\S\ref{#1}}
+% \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, \qc{\ }.
+% \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}
+\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}}}}
+% \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 table of contents.
+% \begin{macrocode}
+%<*amsdtx>
+\renewcommand\tableofcontents{%
+ \if@twocolumn
+ \@restonecoltrue\onecolumn
+ \else
+ \@restonecolfalse
+ \fi
+ \subsection*{\contentsname}%
+ \@starttoc{toc}%
+ \if@restonecol\twocolumn\fi
+ }
+%</amsdtx>
+% \end{macrocode}
+%
+% Edit the sectioning commands.
+% \begin{macrocode}
+\renewcommand\section{\@startsection {section}{1}{\z@}%
+ {-.6\baselineskip \@plus -3\p@}%
+ {.4\baselineskip}
+%<amsdtx> {\reset@font\Large\bfseries}}
+%<amsldoc> {\reset@font\normalsize\bfseries}}
+\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
+ {-.3\baselineskip\@plus -2\p@}%
+ {.2\baselineskip}%
+%<amsdtx> {\reset@font\large\bfseries}}
+%<amsldoc> {\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}
+%
+% \begin{macro}{\SpecialMainEnvIndex}
+% Override \fn{doc.sty}'s main environment indexing to get rid of
+% the parens around ``environment'', for compatibility with our
+% \cs{env} command.
+% \begin{macrocode}
+\def\SpecialMainEnvIndex#1{%
+ \@bsphack
+ \special@index{%
+ #1\actualchar\string\texttt{#1} environment\encapchar main%
+ }%
+ \special@index{%
+ environments:\levelchar#1%
+ \actualchar\string\texttt{#1}%
+ \encapchar main}%
+ \@esphack
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\SpecialEnvIndex}
+% \begin{macrocode}
+\def\SpecialEnvIndex#1{%
+ \@bsphack
+ \index{#1\actualchar\string\texttt{#1} environment\encapchar usage}%
+ \index{%
+ environments:\levelchar#1%
+ \actualchar\string\texttt{#1}%
+ \encapchar usage}%
+ \@esphack
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DescribeOption}
+% \begin{macrocode}
+\def\DescribeOption{%
+ \leavevmode
+ \@bsphack
+ \begingroup
+ \MakePrivateLetters
+ \Describe@Option
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Describe@Option}
+% \begin{macrocode}
+\def\Describe@Option#1{%
+ \endgroup
+ \marginpar{\raggedleft\PrintDescribeOption{#1}}%
+ \SpecialOptionIndex{#1}%
+ \@esphack
+ \ignorespaces
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintDescribeOption}
+% \begin{macrocode}
+\def\PrintDescribeOption#1{\strut \MacroFont #1\ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\option}
+% \begin{macrocode}
+\def\option{%
+ \let\SpecialMainEnvIndex\SpecialMainOptionIndex
+\begingroup
+ \catcode`\\12
+ \MakePrivateLetters \m@cro@ \iffalse}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\SpecialMainOptionIndex}
+% \begin{macrocode}
+\def\SpecialMainOptionIndex#1{%
+ \@bsphack
+ \special@index{#1\actualchar\string\texttt{#1} option\encapchar main}%
+ \@esphack
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\SpecialOptionIndex}
+% \begin{macrocode}
+\def\SpecialOptionIndex{\@category@index{option}}
+% \end{macrocode}
+% \end{macro}
+%
+% 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}
+%
+% A bunch of stuff we don't want in code indexes:
+% \begin{macrocode}
+%<*amsdtx>
+\DoNotIndex{\@xp,\@nx,\@empty,\newcommand,\renewcommand}
+\DoNotIndex{\newenvironment,\renewenvironment,\providecommand}
+\DoNotIndex{\if,\fi,\ifnum,\fi,\@let@token,\futurelet,\fsa@n}
+\DoNotIndex{\ignorespaces,\@tempcnta,\@tempcntb,\count@}
+\DoNotIndex{\toks@,\@ne,\advance}
+\DoNotIndex{\!,\/,\?,\@,\^,\_}
+\DoNotIndex{\@@par,\@M,\@auxout,\@bsphack,\@esphack,\@depth,\@ehc}
+\DoNotIndex{\@for,\@flushglue,\@gobble,\@gobbletwo,\@height,\@idxitem}
+\DoNotIndex{\@ifnextchar,\@ifstar,\@ifundefined,\@input,\@latexerr}
+\DoNotIndex{\@makeschapterhead,\@namedef,\@nameuse,\@nil}
+\DoNotIndex{\@nobreakfalse,\@restonecolfalse,\@restonecoltrue}
+\DoNotIndex{\@tempa,\@tempb,\@tempc,\@tempf,\@temptokena,\@themark,\@width}
+\DoNotIndex{\active,\aindex,\baselineskip,\begin,\begingroup,\box}
+\DoNotIndex{\c@page,\catcode,\chapter,\char,\chardef,\closeout}
+\DoNotIndex{\CodelineIndex,\sp,\sb,\label,\leavevmode,\mark}
+\DoNotIndex{\mark,\newinsert,\newwrite,\newtoks,\xdef}
+\DoNotIndex{\columnsep,\columnseprule,\columnwidth,\csname,\def}
+\DoNotIndex{\dimen,\do,\DocInput,\documentstyle,\edef,\em}
+\DoNotIndex{\EnableCrossrefs,\end,\endcsname,\endgroup,\endinput}
+\DoNotIndex{\everypar,\expandafter,\filedate,\fileversion}
+\DoNotIndex{\footnotesize,\gdef,\global,\glossary,\hangindent}
+\DoNotIndex{\if@filesw,\else,\fi}
+\DoNotIndex{\if@nobreak,\if@twocolumn,\if@twoside,\fi,\fi,\fi}
+\DoNotIndex{\hsize,\hskip}
+\DoNotIndex{\ifhmode,\ifmmode,\ifodd,\ifvmode,\ifx,\fi,\fi,\fi,\fi,\fi}
+\DoNotIndex{\ifcase,\ifdim,\ifeof,\iffalse,\iftrue,\fi,\fi,\fi,\fi,\fi}
+\DoNotIndex{\ifcat,\fi}
+\DoNotIndex{\immediate,\insert,\item,\jobname,\long}
+\DoNotIndex{\let,\lineskip,\marginparsep,\marginparwidth,\maxdimen}
+\DoNotIndex{\makeatletter,\noexpand,\openout,\protect,\rlap}
+\DoNotIndex{\min,\newpage,\nobreak,\normalbaselineskip}
+\DoNotIndex{\normallineskip,\p@,\par,\parfillskip,\parindent,\parskip}
+\DoNotIndex{\penalty,\relax,\section,\sin,\sloppy,\space,\string}
+\DoNotIndex{\tableofcontents,\the,\thepage,\thispagestyle,\toks,\tt}
+\DoNotIndex{\twocolumn,\uppercase,\vbox,\vrule,\vskip,\vss}
+\DoNotIndex{\write,\z@,\z@skip}
+%</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}
+%
+% \changes{v2.03}{2004/04/06}{Reworked indexing commands for
+% compatibility with doc.sty}
+%
+% \changes{v2.04}{2004/04/07}{Further work on indexing commands for
+% compatibility with macro and environment environments in \fn{doc.sty}.
+% Also added \env{option} environment, \cs{DescribeOption},
+% \cs{PrintDescribeOption}, \cs{SpecialOptionIndex}, and
+% \cs{SpecialMainOptionIndex}.}
+%
+% \changes{v2.05}{2004/04/27}{Fixed the amsdtx \cs{env} so that it
+% prints its argument in addition to putting it in the index. Added
+% |\penalty\exhyphenpenalty| to \cs{mdash} and \cs{ndash} as per
+% \pkg{textcmds}.}
+%
+% \CheckSum{1516}
+% \Finale
diff --git a/Master/texmf-dist/source/latex/amslatex/amsgen.dtx b/Master/texmf-dist/source/latex/amslatex/amsgen.dtx
new file mode 100644
index 00000000000..dddaadd9af8
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/amsgen.dtx
@@ -0,0 +1,396 @@
+%%% ====================================================================
+%%% @LaTeX-file{
+%%% filename = "amsgen.dtx",
+%%% version = "2.0",
+%%% date = "1999/11/30",
+%%% time = "12:33:33 EST",
+%%% author = "American Mathematical Society",
+%%% copyright = "Copyright 1995, 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.",
+%%% 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 = "07569 396 1613 14368",
+%%% email = "tech-support@ams.org (Internet)",
+%%% codetable = "ISO/ASCII",
+%%% keywords = "latex, amslatex, ams-latex",
+%%% supported = "yes",
+%%% abstract = "This is part of the AMS-\LaTeX{} distribution.
+%%% It contains some general internal macros shared
+%%% by several different files in AMS-\LaTeX{}.",
+%%% 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
+%<*driver>
+\documentclass{amsdtx}
+\begin{document}
+\title{The \pkg{amsgen} package}
+\author{American Mathematical Society\\Michael Downes}
+\date{Version \fileversion, \filedate}
+\hDocInput{amsgen.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \maketitle
+%
+% \MakeShortVerb\|
+%
+% \section{Introduction}
+% This is an internal package for storing common functions
+% that are shared by more than one package in the \amslatex/
+% distribution. Some of these might eventually make it into the \latex/
+% kernel.
+%
+% \StopEventually{}
+%
+% Standard package info.
+% Using \cs{ProvidesFile} rather than \cs{ProvidesPackage} because
+% the latter, when input by, e.g, \cls{amsbook}, results in
+% \texttt{LaTeX warning: You have requested document class `amsbook',
+% but the document class provides `amsgen'.}
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
+[1994/12/01]% LaTeX date must December 1994 or later
+\ProvidesFile{amsgen.sty}[1999/11/30 v2.0]
+% \end{macrocode}
+%
+% \section{Implementation}
+% Some general macros shared by \fn{amsart.dtx}, \fn{amsmath.dtx},
+% \fn{amsfonts.dtx}, \dots
+%
+% \begin{macro}{\@saveprimitive}
+% The \pkg{amsmath} package redefines a number of \tex/ primitives.
+% In case some preceding package also decided to redefine one of
+% those same primitives, we had better do some checking to make
+% sure that we are able to save the primitive meaning for internal
+% use. This is handled by the \cs{@saveprimitive} function. We
+% follow the example of \cs{@@input} where the primitive meaning is
+% stored in an internal control sequence with a |@@| prefix.
+% Primitive control sequences can be distinguished by the fact that
+% \cs{string} and \cs{meaning} return the same information.
+% \begin{macrocode}
+\providecommand{\@saveprimitive}[2]{\begingroup\escapechar`\\\relax
+ \edef\@tempa{\string#1}\edef\@tempb{\meaning#1}%
+ \ifx\@tempa\@tempb \global\let#2#1%
+ \else
+% \end{macrocode}
+% Check to see if \arg{2} was already given the desired primitive
+% meaning somewhere else.
+% \begin{macrocode}
+ \edef\@tempb{\meaning#2}%
+ \ifx\@tempa\@tempb
+ \else
+ \@latex@error{Unable to properly define \string#2; primitive
+ \noexpand#1no longer primitive}\@eha
+ \fi
+ \fi
+ \endgroup}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@xp}
+% \begin{macro}{\@nx}
+% Shorthands for long command names.
+% \begin{macrocode}
+\let\@xp=\expandafter
+\let\@nx=\noexpand
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\@emptytoks}
+% A token register companion for \cs{@empty}. Saves a little main mem and
+% probably makes initializations such as |\toks@{}| run faster too.
+% \begin{macrocode}
+\newtoks\@emptytoks
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@oparg}
+% Use of \cs{@oparg} simplifies some constructions where a macro
+% takes an optional argument in square brackets. We can't use
+% \cn{newcommand} here because this function might be previously
+% defined by the \pkg{amsmath} package in a loading sequence such as
+% \begin{verbatim}
+% \usepackage{amsmath,amsthm}
+% \end{verbatim}
+% \begin{macrocode}
+\def\@oparg#1[#2]{\@ifnextchar[{#1}{#1[#2]}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@ifempty}
+% \begin{macro}{\@ifnotempty}
+% |\@ifnotempty| and |\@ifempty| use category 11 |@| characters to
+% test whether the argument is empty or not, since these are highly
+% unlikely to occur in the argument. As with \cn{@oparg}, there is a
+% possibility that these commands were defined previously in
+% \fn{amsmath.sty}.
+% \begin{macrocode}
+\long\def\@ifempty#1{\@xifempty#1@@..\@nil}
+\long\def\@xifempty#1#2@#3#4#5\@nil{%
+ \ifx#3#4\@xp\@firstoftwo\else\@xp\@secondoftwo\fi}
+% \end{macrocode}
+% \cs{@ifnotempty} is a shorthand that makes code read better when
+% no action is needed in the empty case. At a cost of double
+% argument-reading---so for often-executed code, avoiding
+% \cs{@ifnotempty} might be wise.
+% \begin{macrocode}
+\long\def\@ifnotempty#1{\@ifempty{#1}{}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% Some abbreviations to conserve token mem.
+% \begin{macrocode}
+\def\FN@{\futurelet\@let@token}
+\def\DN@{\def\next@}
+\def\RIfM@{\relax\ifmmode}
+\def\setboxz@h{\setbox\z@\hbox}
+\def\wdz@{\wd\z@}
+\def\boxz@{\box\z@}
+\def\relaxnext@{\let\@let@token\relax}
+% \end{macrocode}
+%
+% \begin{macro}{\new@ifnextchar}
+% This macro is a new version of \latex/'s \verb+\@ifnextchar+,
+% macro that does not skip over spaces.
+% \begin{macrocode}
+\long\def\new@ifnextchar#1#2#3{%
+% \end{macrocode}
+% By including the space after the equals sign, we make it possible
+% for \cs{new@ifnextchar} to do look-ahead for any token, including a
+% space!
+% \begin{macrocode}
+ \let\reserved@d= #1%
+ \def\reserved@a{#2}\def\reserved@b{#3}%
+ \futurelet\@let@token\new@ifnch
+}
+%
+\def\new@ifnch{%
+ \ifx\@let@token\reserved@d \let\reserved@b\reserved@a \fi
+ \reserved@b
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@ifstar}
+% There will essentially never be a space before the \qc{\*}, so
+% using \cs{@ifnextchar} is unnecessarily slow.
+% \begin{macrocode}
+\def\@ifstar#1#2{\new@ifnextchar *{\def\reserved@a*{#1}\reserved@a}{#2}}
+% \end{macrocode}
+% \end{macro}
+%
+% The hook \cs{every@size} was changed to \cs{every@math@size} in the
+% December 1994 release of \latex/ and its calling procedures changed.
+% If \cs{every@math@size} is undefined it means the user has an older
+% version of \latex/ so we had better define it and patch a couple of
+% functions (\cs{glb@settings} and \cs{set@fontsize}).
+% \begin{macrocode}
+\@ifundefined{every@math@size}{%
+% \end{macrocode}
+% Reuse the same token register; since it was never used except for
+% the purposes that are affected below, this is OK.
+% \begin{macrocode}
+\let\every@math@size=\every@size
+\def\glb@settings{%
+ \expandafter\ifx\csname S@\f@size\endcsname\relax
+ \calculate@math@sizes
+ \fi
+ \csname S@\f@size\endcsname
+ \ifmath@fonts
+% \ifnum \tracingfonts>\tw@
+% \@font@info{Setting up math fonts for
+% \f@size/\f@baselineskip}\fi
+ \begingroup
+ \escapechar\m@ne
+ \csname mv@\math@version \endcsname
+ \globaldefs\@ne
+ \let \glb@currsize \f@size
+ \math@fonts
+ \endgroup
+ \the\every@math@size
+ \else
+% \ifnum \tracingfonts>\tw@
+% \@font@info{No math setup for \f@size/\f@baselineskip}%
+% \fi
+ \fi
+}
+% \end{macrocode}
+% Remove |\the\every@size| from \cs{size@update}.
+% \begin{macrocode}
+\def\set@fontsize#1#2#3{%
+ \@defaultunits\@tempdimb#2pt\relax\@nnil
+ \edef\f@size{\strip@pt\@tempdimb}%
+ \@defaultunits\@tempskipa#3pt\relax\@nnil
+ \edef\f@baselineskip{\the\@tempskipa}%
+ \edef\f@linespread{#1}%
+ \let\baselinestretch\f@linespread
+ \def\size@update{%
+ \baselineskip\f@baselineskip\relax
+ \baselineskip\f@linespread\baselineskip
+ \normalbaselineskip\baselineskip
+ \setbox\strutbox\hbox{%
+ \vrule\@height.7\baselineskip
+ \@depth.3\baselineskip
+ \@width\z@}%
+%%% \the\every@size
+ \let\size@update\relax}%
+ }
+}{}% end \@ifundefined test
+% \end{macrocode}
+%
+% \begin{macro}{\ex@}
+% The \cs{ex@} variable provides a small unit of space for use in
+% math-mode constructions, that varies according to the current type
+% size. For example, the \cn{pmb} command uses \cs{ex@} units.
+% Since a macro or mu unit solution for the \meta{dimen} \cs{ex@} won't
+% work without changing a lot of current code in the \pkg{amsmath}
+% package, we set \cs{ex@} through the \cs{every@math@size} hook.
+% The value of \cs{ex@} is scaled nonlinearly in a range of roughly
+% 0.5pt to 1.5pt, by the function \cs{compute@ex@}.
+% \begin{macrocode}
+\newdimen\ex@
+\addto@hook\every@math@size{\compute@ex@}
+% \end{macrocode}
+% \end{macro}
+%
+% \cs{compute@ex@} computes \cs{ex@} as a nonlinear scaling from 10pt
+% to current font size (\cs{f@size}). Using .97 as the multiplier makes 1
+% |ex@| $\approx$ .9pt when the current type size is 8pt and 1 |ex@|
+% $\approx$ 1.1pt when the current type size is 12pt.
+%
+% The formula is essentially
+% \begin{displaymath}
+% \newcommand{\points}{\mbox{pt}}
+% \newcommand{\floor}[1]{\lfloor#1\rfloor}
+% 1\points \pm (1\points - (.97)^{\floor{\vert 10 - n\vert}})
+% \end{displaymath}
+% where $n$ = current type size, but adjusted to differentiate
+% half-point sizes as well as whole point sizes, and there is a
+% cutoff for extraordinarily large values of \cs{f@size} ($>$ 20pt)
+% so that the value of \cs{ex@} never exceeds 1.5pt.
+%
+% \begin{macrocode}
+\def\compute@ex@{%
+ \begingroup
+ \dimen@-\f@size\p@
+ \ifdim\dimen@<-20\p@
+% \end{macrocode}
+% Never make \cs{ex@} larger than 1.5pt.
+% \begin{macrocode}
+ \global\ex@ 1.5\p@
+ \else
+% \end{macrocode}
+% Adjust by the reference size and multiply by 2 to allow for
+% half-point sizes.
+% \begin{macrocode}
+ \advance\dimen@10\p@ \multiply\dimen@\tw@
+% \end{macrocode}
+% Save information about the current sign of \cs{dimen@}.
+% \begin{macrocode}
+ \edef\@tempa{\ifdim\dimen@>\z@ -\fi}%
+% \end{macrocode}
+% Get the absolute value of \cs{dimen@}.
+% \begin{macrocode}
+ \dimen@ \ifdim\dimen@<\z@ -\fi \dimen@
+ \advance\dimen@-\@m sp % fudge factor
+% \end{macrocode}
+% Here we use \cs{vfuzz} merely as a convenient scratch register
+% \begin{macrocode}
+ \vfuzz\p@
+% \end{macrocode}
+% Multiply in a loop.
+% \begin{macrocode}
+ \def\do{\ifdim\dimen@>\z@
+ \vfuzz=.97\vfuzz
+ \advance\dimen@ -\p@
+%\message{\vfuzz: \the\vfuzz, \dimen@: \the\dimen@}%
+ \@xp\do \fi}%
+ \do
+ \dimen@\p@ \advance\dimen@-\vfuzz
+ \global\ex@\p@
+ \global\advance\ex@ \@tempa\dimen@
+ \fi
+ \endgroup
+%\typeout{\string\f@size: \f@size}\showthe\ex@
+}
+% \end{macrocode}
+% Tests of the \cs{compute@ex@} function yield the following results:
+%
+% \begin{center}\begin{tabular}{rlrl}
+% \cs{f@size}& \cs{ex@}& \cs{f@size}& \cs{ex@}\\
+% 10& 1.0pt& 9& 0.94089pt\\
+% 11& 1.05911pt& 8.7& 0.91266pt\\
+% 12& 1.11473pt& 8.5& 0.91266pt\\
+% 14.4& 1.23982pt& 8.4& 0.88527pt\\
+% 17.28& 1.36684pt& 8& 0.88527pt\\
+% 20.74& 1.5pt& 7& 0.83293pt\\
+% 19.5& 1.4395pt& 6& 0.78369pt\\
+% && 5& 0.73737pt\\
+% && 1& 0.57785pt
+% \end{tabular}\end{center}
+%
+% \begin{macro}{\@addpunct}
+% Use of the \cs{@addpunct} function allows ending punctuation in
+% section headings and elsewhere to be intelligently omitted
+% when punctuation is already present.
+% \begin{macrocode}
+\def\@addpunct#1{\ifnum\spacefactor>\@m \else#1\fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\frenchspacing}
+% Change \cn{frenchspacing} to ensure that \cs{@addpunct} will
+% continue to work properly even when `french' spacing is in effect.
+% \begin{macrocode}
+\def\frenchspacing{\sfcode`\.1006\sfcode`\?1005\sfcode`\!1004%
+ \sfcode`\:1003\sfcode`\;1002\sfcode`\,1001 }
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Miscellaneous}
+% \begin{macrocode}
+\def\nomath@env{\@amsmath@err{%
+ \string\begin{\@currenvir} allowed only in paragraph mode%
+}\@ehb% "You've lost some text"
+}
+% \end{macrocode}
+% A trade-off between main memory space and hash size; using
+% \verb+\Invalid@@+ saves 14 bytes of main memory for each use of
+% \verb+\Invalid@+, at the cost of one control sequence name.
+% \verb+\Invalid@+ is currently used about five times and
+% \verb+\Invalid@@+ is used by itself in some other instances,
+% which means that it saves us more memory than \verb+\FN@+,
+% \verb+\RIfM@+, and some of the other abbreviations above.
+% \begin{macrocode}
+\def\Invalid@@{Invalid use of \string}
+% \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}
+%
+% \CheckSum{337}
+% \Finale
diff --git a/Master/texmf-dist/source/latex/amslatex/amsmath.dtx b/Master/texmf-dist/source/latex/amslatex/amsmath.dtx
new file mode 100644
index 00000000000..9810bc283f0
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/amsmath.dtx
@@ -0,0 +1,5829 @@
+%%% ====================================================================
+%%% @LaTeX-file{
+%%% filename = "amsmath.dtx",
+%%% version = "2.13",
+%%% date = "2000/07/18",
+%%% time = "08:16:41 EDT",
+%%% author = "American Mathematical Society",
+%%% copyright = "Copyright 1995, 2000 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.",
+%%% address = "American Mathematical Society,
+%%% Technical Support,
+%%% Publications Technical Group,
+%%% 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 = "38084 5829 21569 202795",
+%%% email = "tech-support@ams.org (Internet)",
+%%% codetable = "ISO/ASCII",
+%%% keywords = "latex, amslatex, math, amsmath",
+%%% supported = "yes",
+%%% abstract = "This is a \LaTeX{} package that provides a variety of
+%%% extra mathematical features, largely derived from
+%%% AMS-\TeX{}.",
+%%% 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
+%<*driver>
+\documentclass{amsdtx}
+\raggedbottom
+\begin{document}
+\title{The \pkg{amsmath} package}
+\author{Frank Mittelbach\and Rainer Sch\"opf\and Michael Downes\and
+ David M. Jones}
+\date{Version \fileversion, \filedate}
+\providecommand{\histnote}{}
+\renewenvironment{histnote}{%
+ \trivlist\item[\hspace{\labelsep}\bfseries Historical Note:]%
+}{%
+ \endtrivlist
+}
+\hDocInput{amsmath.dtx}
+\end{document}
+%</driver>
+%\fi
+%
+% \maketitle
+%
+% \MakeShortVerb\|
+%
+% \section{Introduction}
+%
+% A \latex/ package named \pkg{amstex} was created in 1988--1989 by
+% adapting \fn{amstex.tex} for use within \latex/. The \pkg{amsmath}
+% package is the successor of the \pkg{amstex} package. It was
+% substantially overhauled to integrate it with \latex/2e, which
+% arrived on the scene in 1994. It provides more or less the same
+% features, but there are quite a few organizational differences as
+% well as some new features and bug fixes. For example, the
+% \pkg{amstex} package automatically loaded the \pkg{amsfonts}
+% package, but the \pkg{amsmath} package does not. At the present
+% time (November 1999) user-level documentation of the commands
+% provided here is found in the AMSmath Users' Guide,
+% \fn{amsldoc.tex}.
+%
+% \StopEventually{}
+%
+% Standard file identification.
+% \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
+\ProvidesPackage{amsmath}[2000/07/18 v2.13 AMS math features]
+% \end{macrocode}
+%
+% \section{Catcode defenses}
+%
+% Some packages change the catcode of characters that are essential
+% in low-level \tex/ syntax. Any package that does so does not
+% qualify as a PWWO package (\qq{Plays Well With Others}) because it
+% can cause other packages to fail if they are loaded later. \LaTeX{}
+% is partly to blame for this because it fails to provide adequate
+% built-in safeguards in the package loading mechanisms. In the
+% absence of such safeguards, we will provide them here.
+% \begin{macrocode}
+\edef\@temp{\catcode 96=\number\catcode 96 }
+\catcode\string `\`=12
+\def\do#1{\catcode\number`#1=\number\catcode`#1}
+\edef\@temp{%
+ \noexpand\AtEndOfPackage{%
+ \@temp
+ \do\"\do\'\do\(\do\)\do\*\do\+\do\,\do\-\do\.%
+ \do\/\do\<\do\=\do\>\do\[\do\]\do\^\do\_\relax
+ }%
+}
+\@temp
+\def\do#1{\catcode\number`#1=12 }
+\do\"\do\'\do\(\do\)\do\*\do\+\do\,\do\-\do\.
+\do\/\do\<\do\=\do\>\do\[\do\]
+\catcode`\^=7 \catcode`\_=8
+% \end{macrocode}
+%
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \section{Declare some options}
+%
+% Handling of limits on integrals, sums, operatornames.
+% \begin{macrocode}
+\DeclareOption{intlimits}{\let\ilimits@\displaylimits}
+\DeclareOption{nointlimits}{\let\ilimits@\nolimits}
+\DeclareOption{sumlimits}{\let\slimits@\displaylimits}
+\DeclareOption{nosumlimits}{\let\slimits@\nolimits}
+\DeclareOption{namelimits}{\PassOptionsToPackage{namelimits}{amsopn}}
+\DeclareOption{nonamelimits}{%
+ \PassOptionsToPackage{nonamelimits}{amsopn}}
+% \end{macrocode}
+%
+% The following two switches might have been defined already by the
+% documentclass, but it doesn't hurt to re-execute the \cs{newif}'s.
+% \begin{macrocode}
+\newif\ifctagsplit@
+\newif\iftagsleft@
+% \end{macrocode}
+% Right or left placement of equation numbers.
+% \begin{macrocode}
+\DeclareOption{leqno}{\tagsleft@true}
+\DeclareOption{reqno}{\tagsleft@false}
+\DeclareOption{centertags}{\ctagsplit@true}
+\DeclareOption{tbtags}{\ctagsplit@false}
+% \end{macrocode}
+%
+% The \opt{cmex10} option is an escape hatch for people who don't
+% happen to have sizes 7--9 of the \fn{cmex} fonts available to them
+% yet. (Strictly speaking they are considered part of a minimum
+% \latex/ distribution now, i.e., all \LaTeXe{} users should have
+% them, without needing to get the AMSFonts distrib.)
+% \begin{macrocode}
+\DeclareOption{cmex10}{%
+ \ifnum\cmex@opt=\@ne \def\cmex@opt{0}%
+ \else \def\cmex@opt{10}\fi
+}
+% \end{macrocode}
+% To help things work out better with various package loading orders
+% of \pkg{amsmath} and \pkg{amsfonts}, we establish a variable to
+% communicate the status of the cmex font definition. If the
+% \pkg{amsfonts} package was loaded first this variable might be
+% already defined, in which case we want to preserve its value.
+% \begin{macrocode}
+\@ifundefined{cmex@opt}{\def\cmex@opt{7}}{}
+% \end{macrocode}
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \section{Flush-left equations [DMJ]}
+%
+% The left margin of math enviroments is controlled by
+% \cs{@mathmargin}. This can be set to \cs{@centering} to
+% implement the default behaviour, i.e., centered equations, and to
+% something else to implement the flushleft style.
+%
+% In theory, all that's needed to activate the flushleft mode
+% in the AMS document classes is something like this:
+% \begin{verbatim}
+% \DeclareOption{fleqn}{%
+% \AtBeginDocument{\@mathmargin30pt\relax}%
+% }
+% \end{verbatim}
+% (In fact, unless the document class wants to specify the
+% \cs{@mathmargin}, it doesn't need to do anything with the
+% \opt{fleqn} option.)
+% \begin{macrocode}
+\newif\if@fleqn
+%
+\newskip\@mathmargin
+\@mathmargin\@centering
+%
+\DeclareOption{fleqn}{%
+ \@fleqntrue
+ \@mathmargin = -1sp
+ \let\mathindent=\@mathmargin
+ \AtBeginDocument{%
+ \ifdim\@mathmargin= -1sp
+ \@mathmargin\leftmargini minus\leftmargini
+ \fi
+ }%
+}
+% \end{macrocode}
+%
+% DMJ: This ensures that \cs{@mathmargin} is given some sort of
+% sensible default if the class doesn't specify one, while still
+% allowing a user to override the default value in their document
+% preamble. (Incidentally, I'm initializing \cs{@mathmargin} to
+% \cs{leftmargini} for compatibility with \fn{fleqn.clo}, but I'm
+% not at all convinced that's the right thing to do.)
+%
+% The next question is what happens when amsmath is used with
+% one of the standard classes. Unfortunately, \latex/ implements
+% \opt{fleqn} somewhat clumsily; instead of paramaterizing the
+% definitions of the math structures (as I've attempted to do
+% here), \fn{fleqn.clo} declares a dimen \cn{mathindent} that is
+% much like my \cs{@mathmargin} and then redefines \cn\[, \cn\],
+% \cn{equation}, and \cn{eqnarray}. This means that things could
+% get rather messy in 2.09 compatibility mode, since \fn{fleqn.clo}
+% might be loaded after \fn{amsmath.sty}, which could cause a real
+% mess.
+%
+% [mjd,1999/07/07]: Let \cs{mathindent} = \cs{@mathmargin} as
+% envisioned by DMJ. Compatibility-mode documents will all use the
+% \pkg{amstex} package, not \pkg{amsmath}. There is a remote chance
+% of a problem if someone makes an assignment to \cs{mathindent} in a
+% way that implicitly assumes it is a dimen register (inasmuch as it
+% has now become a skip register), and the string ``plus'' follows in
+% the input stream, but if someone's document croaks in that way, I
+% think they will just have to bite the bullet and fix it. The
+% alternative is to penalize a lot of other users with a known
+% handicap.
+%
+% \begin{macrocode}
+\DeclareOption{?}{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\ExecuteOptions{nointlimits,sumlimits,namelimits,centertags}
+% \end{macrocode}
+% The \cs{par} after \cs{ProcessOptions} is to ensure the correct
+% line number on screen if an error occurs during option processing;
+% otherwise the lookahead for a \qc{\*} option would result in \tex/
+% showing the following line instead.
+% \begin{macrocode}
+\ProcessOptions\par
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@ifpackagewith{amsmath}{?}{%
+ \typeout{^^J%
+Documentation for the amsmath package is found in amsldoc.dvi^^J%
+(or .pdf or .tex).^^J%
+^^J%
+See also http://www.ams.org/tex/amslatex.html.^^J%
+^^J%
+Note: Using the first edition of The LaTeX Companion (1994) without^^J%
+errata as a guide for amsmath use is not recommended.^^J%
+ }%
+}{%
+ \typeout{%
+For additional information on amsmath, use the \lq ?\rq\space option.%
+ }%
+}
+% \end{macrocode}
+%
+% Processing to handle the \opt{cmex10} option is a little tricky
+% because of different possible loading orders for \pkg{amsmath} and
+% \pkg{amsfonts}. The package \pkg{amsmath} sets the \cs{cmex@opt}
+% flag to 7 or 10, and the package \pkg{amsfonts} sets the flag to 1
+% or 0.
+% \begin{macrocode}
+\ifnum\cmex@opt=7 \relax
+ \DeclareFontShape{OMX}{cmex}{m}{n}{%
+ <-8>cmex7<8>cmex8<9>cmex9%
+ <10><10.95><12><14.4><17.28><20.74><24.88>cmex10%
+ }{}%
+ \expandafter\let\csname OMX/cmex/m/n/10\endcsname\relax
+\else
+ \ifnum\cmex@opt=\z@ % need to override cmex7 fontdef from amsfonts
+% \end{macrocode}
+% Force reloading of the OMX/cmex font definition file.
+% \begin{macrocode}
+ \begingroup
+ \fontencoding{OMX}\fontfamily{cmex}%
+ \expandafter\let\csname OMX+cmex\endcsname\relax
+ \try@load@fontshape
+ \endgroup
+% \end{macrocode}
+% The \fn{cmex10} font gets special preload handling in the building
+% of the \latex/ format file, need an extra bit here to work around
+% that.
+% \begin{macrocode}
+ \expandafter\let\csname OMX/cmex/m/n/10\endcsname\relax
+ \def\cmex@opt{10}%
+ \fi
+\fi
+% \end{macrocode}
+%
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \section{Call some other packages}
+%
+% The \pkg{amstext} package provides the \cn{text} command. The
+% \pkg{amsbsy} package provides \cn{boldsymbol} and \cn{pmb}. (Since
+% 1997 it is usually better to use the \pkg{bm} package instead; but
+% I think we have to keep \pkg{amsbsy} here for backward
+% compatibility [mjd,1999/11/19].) The \pkg{amsopn} package provides
+% \cn{DeclareMathOperator}.
+% \begin{macrocode}
+\RequirePackage{amstext}[1995/01/25]
+\RequirePackage{amsbsy}[1995/01/20]
+\RequirePackage{amsopn}[1995/01/20]
+% \end{macrocode}
+%
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \section{Miscellaneous}
+%
+% \begin{macro}{\@amsmath@err}
+% Defining this error function saves main mem.
+% \begin{macrocode}
+\def\@amsmath@err{\PackageError{amsmath}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\AmS}
+% The \cs{AmS} prefix can be used to construct the combination
+% |\AmS-\LaTeX|.
+% \begin{macrocode}
+\providecommand{\AmS}{{\protect\AmSfont
+ A\kern-.1667em\lower.5ex\hbox{M}\kern-.125emS}}
+% \end{macrocode}
+% In \cn{AmSfont} we call cmsy directly in lieu of trying to access
+% it through the math fonts setup (e.g. |\the\textfont2|) because
+% math fonts can't be relied on to be properly set up if we are not
+% inside a math formula. This means that if this command is used in a
+% document where CM fonts are not wanted, then a font substitution
+% will need to be declared, e.g.:
+% \begin{verbatim}
+% \DeclareFontShape{OMS}{cmsy}{m}{n}{ <-> sub * xxx/m/n }{}
+% \end{verbatim}
+% where |xxx| is some alternate font family.
+% Taking the first letter of \cs{f@series} will produce |b| or |m|
+% for the most common values (|b,bx,m|). It may produce nonsense for
+% more unusual values of \cs{f@series}, so for safety's sake we have
+% an additional \cs{if} test. We want to avoid setting the series to
+% |bx| because in a standard \latex/ installation the combination
+% |cmsy/bx/n| does not have a font definition, and the user
+% would get a font substitution warning on screen.
+% \begin{macrocode}
+\newcommand{\AmSfont}{%
+ \usefont{OMS}{cmsy}{\if\@xp\@car\f@series\@nil bb\else m\fi}{n}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@mathmeasure}
+% The function |\@mathmeasure| takes three arguments; the third arg
+% is typeset as a math formula in an hbox, using arg |#2| as the
+% mathstyle, and the result is left in the box named by the first
+% arg. It is assumed that we are already in math mode, so we can turn
+% off |\everymath| (in particular, |\check@mathfonts|).
+% \begin{macrocode}
+\def\@mathmeasure#1#2#3{\setbox#1\hbox{\frozen@everymath\@emptytoks
+ \m@th$#2#3$}}
+% \end{macrocode}
+% \end{macro}
+%
+% The \cs{inf@bad} constant is for testing overfull boxes.
+% \begin{macrocode}
+\@ifundefined{inf@bad}{%
+ \newcount\inf@bad \inf@bad=1000000 \relax
+}{}
+% \end{macrocode}
+%
+%\subsection{Math spacing commands}
+%
+% Here we fill in some gaps in the set of spacing commands, and make them
+% all work equally well in or out of math.
+% We want all these commands to be robust but declaring them all with
+% \cs{DeclareRobustCommand} uses up an control sequence name per
+% command; to avoid this, we define a common command \cs{tmspace}
+% (text-or-math space) which carries the robustness burden for all of
+% them. The standard \cs{relax} before the \cs{ifmmode} is not
+% necessary because of the \cs{protect} added by
+% \cs{DeclareRobustCommand}.
+% \begin{macrocode}
+\DeclareRobustCommand{\tmspace}[3]{%
+ \ifmmode\mskip#1#2\else\kern#1#3\fi\relax}
+\renewcommand{\,}{\tmspace+\thinmuskip{.1667em}}
+\let\thinspace\,
+\renewcommand{\!}{\tmspace-\thinmuskip{.1667em}}
+\let\negthinspace\!
+\renewcommand{\:}{\tmspace+\medmuskip{.2222em}}
+\let\medspace\:
+\newcommand{\negmedspace}{\tmspace-\medmuskip{.2222em}}
+\renewcommand{\;}{\tmspace+\thickmuskip{.2777em}}
+\let\thickspace\;
+\newcommand{\negthickspace}{\tmspace-\thickmuskip{.2777em}}
+% \end{macrocode}
+%
+% \begin{macro}{\mspace}
+% And while we're at it, why don't we provide an equivalent of
+% \cn{hspace} for math mode use. This allows use of |mu| units in
+% (for example) constructing compound math symbols.
+% \begin{macrocode}
+\newcommand{\mspace}[1]{\mskip#1\relax}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Vertical bar symbols}
+% Add left/right specific versions of \cn{vert}, \cn{Vert}. Don't
+% assume the delimiter codes are the CM defaults.
+% \begin{macrocode}
+\def\@tempa#1#2\@nil{%
+ \ifx\delimiter#1\@tempcnta#2\relax\else\@tempcnta\z@\fi
+}
+\@xp\@tempa\vert\@empty\@nil
+\ifnum\@tempcnta>\z@
+ \advance\@tempcnta "4000000
+ \xdef\lvert{\delimiter\number\@tempcnta\space }
+ \advance\@tempcnta "1000000
+ \xdef\rvert{\delimiter\number\@tempcnta\space }
+\else
+ \ifx\@@undefined\lvert
+ % Fall back to cmex encoding since we don't know what else to do.
+ \DeclareMathDelimiter{\lvert}
+ {\mathopen}{symbols}{"6A}{largesymbols}{"0C}
+ \DeclareMathDelimiter{\rvert}
+ {\mathclose}{symbols}{"6A}{largesymbols}{"0C}
+ \fi
+\fi
+\@xp\@tempa\Vert\@empty\@nil
+\ifnum\@tempcnta>\z@
+ \advance\@tempcnta "4000000
+ \xdef\lVert{\delimiter\number\@tempcnta\space }
+ \advance\@tempcnta "1000000
+ \xdef\rVert{\delimiter\number\@tempcnta\space }
+\else
+ \ifx\@@undefined\lVert
+ \DeclareMathDelimiter{\lVert}
+ {\mathopen}{symbols}{"6B}{largesymbols}{"0D}
+ \DeclareMathDelimiter{\rVert}
+ {\mathclose}{symbols}{"6B}{largesymbols}{"0D}
+ \fi
+\fi
+% \end{macrocode}
+%
+% \subsection{Fractions}
+% Bury the generalized fraction primitives \cs{over}, \cs{atop},
+% etc., because of their bizarre syntax, which is decidedly out of
+% place in a \latex/ document.
+% \begin{macrocode}
+\@saveprimitive\over\@@over
+\@saveprimitive\atop\@@atop
+\@saveprimitive\above\@@above
+\@saveprimitive\overwithdelims\@@overwithdelims
+\@saveprimitive\atopwithdelims\@@atopwithdelims
+\@saveprimitive\abovewithdelims\@@abovewithdelims
+% \end{macrocode}
+%
+% If someone insists on using \cs{over}, give a warning the first
+% time and then resurrect the old definition. Laissez-faire policy.
+% \begin{macrocode}
+\DeclareRobustCommand{\primfrac}[1]{%
+ \PackageWarning{amsmath}{%
+Foreign command \@backslashchar#1;\MessageBreak
+\protect\frac\space or \protect\genfrac\space should be used instead%
+\MessageBreak
+ }
+ \global\@xp\let\csname#1\@xp\endcsname\csname @@#1\endcsname
+ \csname#1\endcsname
+}
+\renewcommand{\over}{\primfrac{over}}
+\renewcommand{\atop}{\primfrac{atop}}
+\renewcommand{\above}{\primfrac{above}}
+\renewcommand{\overwithdelims}{\primfrac{overwithdelims}}
+\renewcommand{\atopwithdelims}{\primfrac{atopwithdelims}}
+\renewcommand{\abovewithdelims}{\primfrac{abovewithdelims}}
+% \end{macrocode}
+%
+% \cn{frac} calls \cn{@@over} directly instead of via \cn{genfrac}, for
+% better speed because it is so common. \cn{tfrac} and \cn{dfrac} are
+% abbreviations for some commonly needed mathstyle overrides. To
+% conserve csnames we avoid making \cn{dfrac} and \cn{tfrac} robust
+% (\cn{genfrac} is itself robust).
+% \begin{macrocode}
+\DeclareRobustCommand{\frac}[2]{{\begingroup#1\endgroup\@@over#2}}
+\newcommand{\dfrac}{\genfrac{}{}{}0}
+\newcommand{\tfrac}{\genfrac{}{}{}1}
+% \end{macrocode}
+% The \cn{binom} command for binomial notation works like \cn{frac}
+% and has similar variants. Note that we do not use \cs{z@} in
+% \cn{dbinom} and \cn{tbinom} because they are not top-level robust
+% like \cn{binom}, and so the \cs{z@} with the potentially
+% problematic \qc{\@} character would become visible when writing one
+% of those commands to a \fn{.toc} file.
+% \begin{macrocode}
+\DeclareRobustCommand{\binom}{\genfrac()\z@{}}
+\newcommand{\dbinom}{\genfrac(){0pt}0}
+\newcommand{\tbinom}{\genfrac(){0pt}1}
+% \end{macrocode}
+%
+% \begin{macro}{\genfrac}
+% This command provides access to \tex/'s generalized fraction
+% primitives. Args: \arg{1} left delim, \arg{2} right delim, \arg{3}
+% line thickness, \arg{4} mathstyle override, \arg{5} numerator,
+% \arg{6} denominator. But we only read the first four args at first,
+% in order to give us a moment to select the proper generalized
+% fraction primitive. Any of those four args could be empty, and when
+% empty the obvious defaults are selected (no delimiters, default
+% line thickness (normally .4pt), and no mathstyle override).
+% \begin{macrocode}
+\DeclareRobustCommand{\genfrac}[4]{%
+ \def\@tempa{#1#2}%
+ \edef\@tempb{\@nx\@genfrac\@mathstyle{#4}%
+ \csname @@\ifx @#3@over\else above\fi
+ \ifx\@tempa\@empty \else withdelims\fi\endcsname}
+ \@tempb{#1#2#3}}
+% \end{macrocode}
+% \cs{@genfrac} takes the preceding arguments and reads the
+% numerator and denominator. Note that there's no convenient way to
+% make the numerator and denominator \emph{contents}
+% displaystyle, through this interface.
+%
+% Args: \arg{1} mathstyle, \arg{2} fraction primitive,
+% \arg{3} delimiters and rule thickness,
+% \arg{4} numerator, \arg{5} denominator.
+% \begin{macrocode}
+\def\@genfrac#1#2#3#4#5{{#1{\begingroup#4\endgroup#2#3\relax#5}}}
+% \end{macrocode}
+% \end{macro}
+%
+% Empty mathstyle arg: no change; 0 = displaystyle, 1 = textstyle, 2
+% = scriptstyle, 3 = scriptscriptstyle.
+% \begin{macrocode}
+\def\@mathstyle#1{%
+ \ifx\@empty#1\@empty\relax
+ \else\ifcase#1\displaystyle % case 0
+ \or\textstyle\or\scriptstyle\else\scriptscriptstyle\fi\fi}
+% \end{macrocode}
+%
+% \subsection{Sums and Integrals}
+% Default value for sum limits is \cs{displaylimits}, see option
+% `nosumlimits'.
+%
+% We redefine all the cumulative operator symbols to use
+% \cs{slimits@} so that switching between \cs{displaylimits} and
+% \cs{nolimits} can be controlled by package options. Also add
+% \cs{DOTSB} for the benefit of the dots lookahead. But we'd better
+% make sure \cn{coprod} and the others are simple mathchars; if not,
+% the attempted changes will probably fail miserably.
+%
+% \begin{macrocode}
+\begingroup
+\edef\@tempa{\string\mathchar"}
+\def\@tempb#1"#2\@nil{#1"}
+\edef\@tempc{\expandafter\@tempb\meaning\coprod "\@nil}
+\ifx\@tempa\@tempc
+ \global\let\coprod@\coprod
+ \gdef\coprod{\DOTSB\coprod@\slimits@}
+ \global\let\bigvee@\bigvee
+ \gdef\bigvee{\DOTSB\bigvee@\slimits@}
+ \global\let\bigwedge@\bigwedge
+ \gdef\bigwedge{\DOTSB\bigwedge@\slimits@}
+ \global\let\biguplus@\biguplus
+ \gdef\biguplus{\DOTSB\biguplus@\slimits@}
+ \global\let\bigcap@\bigcap
+ \gdef\bigcap{\DOTSB\bigcap@\slimits@}
+ \global\let\bigcup@\bigcup
+ \gdef\bigcup{\DOTSB\bigcup@\slimits@}
+ \global\let\prod@\prod
+ \gdef\prod{\DOTSB\prod@\slimits@}
+ \global\let\sum@\sum
+ \gdef\sum{\DOTSB\sum@\slimits@}
+ \global\let\bigotimes@\bigotimes
+ \gdef\bigotimes{\DOTSB\bigotimes@\slimits@}
+ \global\let\bigoplus@\bigoplus
+ \gdef\bigoplus{\DOTSB\bigoplus@\slimits@}
+ \global\let\bigodot@\bigodot
+ \gdef\bigodot{\DOTSB\bigodot@\slimits@}
+ \global\let\bigsqcup@\bigsqcup
+ \gdef\bigsqcup{\DOTSB\bigsqcup@\slimits@}
+\fi
+\endgroup
+% \end{macrocode}
+%
+% \subsection{Roots and radicals}
+%
+% This root stuff needs syntax work and implementation work. Surely
+% something more compact can be done?? [mjd, 1994/09/05]
+% \begin{macrocode}
+\newcommand{\leftroot}{\@amsmath@err{\Invalid@@\leftroot}\@eha}
+\newcommand{\uproot}{\@amsmath@err{\Invalid@@\uproot}\@eha}
+\newcount\uproot@
+\newcount\leftroot@
+\renewcommand{\root}{\relaxnext@
+ \DN@{\ifx\@let@token\uproot\let\next@\nextii@\else
+ \ifx\@let@token\leftroot\let\next@\nextiii@\else
+ \let\next@\plainroot@\fi\fi\next@}%
+ \def\nextii@\uproot##1{\uproot@##1\relax\FN@\nextiv@}%
+ \def\nextiv@{\ifx\@let@token\@sptoken\DN@. {\FN@\nextv@}\else
+ \DN@.{\FN@\nextv@}\fi\next@.}%
+ \def\nextv@{\ifx\@let@token\leftroot\let\next@\nextvi@\else
+ \let\next@\plainroot@\fi\next@}%
+ \def\nextvi@\leftroot##1{\leftroot@##1\relax\plainroot@}%
+ \def\nextiii@\leftroot##1{\leftroot@##1\relax\FN@\nextvii@}%
+ \def\nextvii@{\ifx\@let@token\@sptoken
+ \DN@. {\FN@\nextviii@}\else
+ \DN@.{\FN@\nextviii@}\fi\next@.}%
+ \def\nextviii@{\ifx\@let@token\uproot\let\next@\nextix@\else
+ \let\next@\plainroot@\fi\next@}%
+ \def\nextix@\uproot##1{\uproot@##1\relax\plainroot@}%
+ \bgroup\uproot@\z@\leftroot@\z@\FN@\next@}
+\def\plainroot@#1\of#2{\setbox\rootbox\hbox{%
+ $\m@th\scriptscriptstyle{#1}$}%
+ \mathchoice{\r@@t\displaystyle{#2}}{\r@@t\textstyle{#2}}
+ {\r@@t\scriptstyle{#2}}{\r@@t\scriptscriptstyle{#2}}\egroup}
+% \end{macrocode}
+%
+% \changes{v2.0}{1999/06/17}{Normalize @@sqrt to sqrtsign}
+
+% Name change from \cs{@@sqrt} to \cs{sqrtsign} happened in the
+% 1995/12/01 release of \latex/. If we were to assume that
+% \cs{sqrtsign} is defined then someone with the 1995/06/01 release
+% of \latex/ would have trouble using this package.
+% \begin{macrocode}
+\@ifundefined{sqrtsign}{\let\sqrtsign\@@sqrt}{}
+\def\r@@t#1#2{\setboxz@h{$\m@th#1\sqrtsign{#2}$}%
+ \dimen@\ht\z@\advance\dimen@-\dp\z@
+ \setbox\@ne\hbox{$\m@th#1\mskip\uproot@ mu$}%
+ \advance\dimen@ by1.667\wd\@ne
+ \mkern-\leftroot@ mu\mkern5mu\raise.6\dimen@\copy\rootbox
+ \mkern-10mu\mkern\leftroot@ mu\boxz@}
+% \end{macrocode}
+%
+% \subsection{Et cetera}
+%
+% \changes{v2.0}{1999/06/18}{Leave Greek cap letters unaltered}
+%
+% Specific names for the variant italic cap Greek letters are not
+% defined by \latex/. If no preceding package defined these, we will
+% define them now.
+% \begin{macrocode}
+\@ifundefined{varGamma}{%
+ \DeclareMathSymbol{\varGamma}{\mathord}{letters}{"00}
+ \DeclareMathSymbol{\varDelta}{\mathord}{letters}{"01}
+ \DeclareMathSymbol{\varTheta}{\mathord}{letters}{"02}
+ \DeclareMathSymbol{\varLambda}{\mathord}{letters}{"03}
+ \DeclareMathSymbol{\varXi}{\mathord}{letters}{"04}
+ \DeclareMathSymbol{\varPi}{\mathord}{letters}{"05}
+ \DeclareMathSymbol{\varSigma}{\mathord}{letters}{"06}
+ \DeclareMathSymbol{\varUpsilon}{\mathord}{letters}{"07}
+ \DeclareMathSymbol{\varPhi}{\mathord}{letters}{"08}
+ \DeclareMathSymbol{\varPsi}{\mathord}{letters}{"09}
+ \DeclareMathSymbol{\varOmega}{\mathord}{letters}{"0A}
+}{}
+% \end{macrocode}
+%
+% \amstex/ redefines \cn{overline} as shown here, for reasons that
+% are probably less important in \latex/: Make it read its argument
+% as a macro argument rather than a ``math field'' (\emph{The
+% \tex/book}, Chapter 26), to avoid problems when something that is
+% apparently a single symbol is actually a non-simple macro (e.g.,
+% \cn{dag}) \emph{and} is given as a single-token argument without
+% enclosing braces.
+% \begin{macrocode}
+\@saveprimitive\overline\@@overline
+\DeclareRobustCommand{\overline}[1]{\@@overline{#1}}
+% \end{macrocode}
+%
+% The \cs{boxed} command is specifically intended to put a box around
+% an equation or piece of an equation. (Not including the equation
+% number.) This isn't trivial for end-users to do it properly
+% with \cs{fbox} so we provide a command for them.
+% \begin{macrocode}
+\newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newcommand{\implies}{\DOTSB\;\Longrightarrow\;}
+\newcommand{\impliedby}{\DOTSB\;\Longleftarrow\;}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\And{\DOTSB\;\mathchar"3026 \;}
+% \end{macrocode}
+%
+% The command \cn{nobreakdash} is designed only for use before a
+% hyphen or dash (|-|, |--|, or |---|).
+% Setting the hyphen in a box and then unboxing it means that the
+% normal penalty will not be added after it---and if the penalty is
+% not there a break will not be taken (unless an explicit penalty
+% or glue follows, thus the final \verb=\nobreak=).
+% \begin{macrocode}
+\newcommand{\nobreakdash}{\leavevmode
+ \toks@\@emptytoks \def\@tempa##1{\toks@\@xp{\the\toks@-}\FN@\next@}%
+ \DN@{\ifx\@let@token-\@xp\@tempa
+ \else\setboxz@h{\the\toks@\nobreak}\unhbox\z@\fi}%
+ \FN@\next@
+}
+% \end{macrocode}
+%
+% \cs{colon} is for a colon in math that resembles a text colon:
+% small space on the left, larger space on the right. The \qc{\:}
+% character by itself is treated as a \cs{mathrel} i.e. large, equal
+% spacing on both sides.
+% \begin{macrocode}
+\renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript
+ \mkern-\thinmuskip{:}\mskip6muplus1mu\relax}
+% \end{macrocode}
+%
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \section{Ellipsis dots}
+%
+% We can't use \cs{newif} for \cs{ifgtest@} because we want
+% to include \cs{global} in the definitions of
+% \cs{gtest@true} and \cs{gtest@false}.
+% \begin{macrocode}
+\let\ifgtest@\iffalse % initial value
+\def\gtest@true{\global\let\ifgtest@\iftrue}
+\def\gtest@false{\global\let\ifgtest@\iffalse}
+\let\DOTSI\relax
+\let\DOTSB\relax
+\let\DOTSX\relax
+{\uccode`7=`\\ \uccode`8=`m \uccode`9=`a \uccode`0=`t \uccode`!=`h
+ \uppercase{%
+ \gdef\math@#1#2#3#4#5#6\math@{\gtest@false\ifx 7#1\ifx 8#2%
+ \ifx 9#3\ifx 0#4\ifx !#5\xdef\meaning@{#6}\gtest@true
+ \fi\fi\fi\fi\fi}}}
+{\uccode`7=`c \uccode`8=`h \uccode`9=`\"
+ \uppercase{\gdef\mathch@#1#2#3#4#5#6\mathch@{\gtest@false
+ \ifx 7#1\ifx 8#2\ifx 9#5\gtest@true\xdef\meaning@{9#6}\fi\fi\fi}}}
+\newcount\classnum@
+\def\getmathch@#1.#2\getmathch@{\classnum@#1 \divide\classnum@4096
+ \ifcase\number\classnum@\or\or\gdef\thedots@{\dotsb@}\or
+ \gdef\thedots@{\dotsb@}\fi}
+{\uccode`4=`b \uccode`5=`i \uccode`6=`n
+ \uppercase{\gdef\mathbin@#1#2#3{\relaxnext@
+ \def\nextii@##1\mathbin@{\ifx\@sptoken\@let@token\gtest@true\fi}%
+ \gtest@false\DN@##1\mathbin@{}%
+ \ifx 4#1\ifx 5#2\ifx 6#3\DN@{\FN@\nextii@}\fi\fi\fi\next@}}}
+{\uccode`4=`r \uccode`5=`e \uccode`6=`l
+ \uppercase{\gdef\mathrel@#1#2#3{\relaxnext@
+ \def\nextii@##1\mathrel@{\ifx\@sptoken\@let@token\gtest@true\fi}%
+ \gtest@false\DN@##1\mathrel@{}%
+ \ifx 4#1\ifx 5#2\ifx 6#3\DN@{\FN@\nextii@}\fi\fi\fi\next@}}}
+{\uccode`5=`m \uccode`6=`a \uccode`7=`c
+ \uppercase{\gdef\macro@#1#2#3#4\macro@{\gtest@false
+ \ifx 5#1\ifx 6#2\ifx 7#3\gtest@true
+ \xdef\meaning@{\macro@@#4\macro@@}\fi\fi\fi}}}
+\def\macro@@#1->#2\macro@@{#2}
+\newcount\DOTSCASE@
+{\uccode`6=`\\ \uccode`7=`D \uccode`8=`O \uccode`9=`T \uccode`0=`S
+ \uppercase{\gdef\DOTS@#1#2#3#4#5{\gtest@false\DN@##1\DOTS@{}%
+ \ifx 6#1\ifx 7#2\ifx 8#3\ifx 9#4\ifx 0#5\let\next@\DOTS@@
+ \fi\fi\fi\fi\fi
+ \next@}}}
+{\uccode`3=`B \uccode`4=`I \uccode`5=`X
+ \uppercase{\gdef\DOTS@@#1{\relaxnext@
+ \def\nextii@##1\DOTS@{\ifx\@sptoken\@let@token\gtest@true\fi}%
+ \DN@{\FN@\nextii@}%
+ \ifx 3#1\global\DOTSCASE@\z@\else
+ \ifx 4#1\global\DOTSCASE@\@ne\else
+ \ifx 5#1\global\DOTSCASE@\tw@\else\DN@##1\DOTS@{}%
+ \fi\fi\fi\next@}}}
+{\uccode`5=`\\ \uccode`6=`n \uccode`7=`o \uccode`8=`t
+ \uppercase{\gdef\not@#1#2#3#4{\relaxnext@
+ \def\nextii@##1\not@{\ifx\@sptoken\@let@token\gtest@true\fi}%
+ \gtest@false\DN@##1\not@{}%
+ \ifx 5#1\ifx 6#2\ifx 7#3\ifx 8#4\DN@{\FN@\nextii@}\fi\fi\fi
+ \fi\next@}}}
+\def\keybin@{\gtest@true
+ \ifx\@let@token+\else\ifx\@let@token=\else
+ \ifx\@let@token<\else\ifx\@let@token>\else
+ \ifx\@let@token-\else\ifx\@let@token*\else\ifx\@let@token:\else
+ \gtest@false\fi\fi\fi\fi\fi\fi\fi}
+% \end{macrocode}
+% Patch to ensure \cs{@ldots} is defined. (Name changed to
+% \cn{mathellipsis} in Dec 94 release of \latex/.)
+% \begin{macrocode}
+\@ifundefined{@ldots}{\def\@ldots{\mathellipsis}}{}
+% \end{macrocode}
+% Reiterate the standard definition of \cs{ldots} to keep it from
+% being clobbered by the redefinition of \cs{dots}.
+% \begin{macrocode}
+\DeclareRobustCommand{\ldots}{%
+ \ifmmode \mathellipsis \else \textellipsis \fi
+}
+\DeclareRobustCommand{\dots}{%
+ \ifmmode \@xp\mdots@\else \@xp\textellipsis \fi
+}
+\def\tdots@{\leavevmode\unskip\relaxnext@
+ \DN@{$\m@th\@ldots\,
+ \ifx\@let@token,\,$\else\ifx\@let@token.\,$\else
+ \ifx\@let@token;\,$\else\ifx\@let@token:\,$\else
+ \ifx\@let@token?\,$\else\ifx\@let@token!\,$\else
+ $ \fi\fi\fi\fi\fi\fi}%
+ \ \FN@\next@}
+\def\mdots@{\FN@\mdots@@}
+\def\mdots@@{\gdef\thedots@{\dotso@}%
+ \ifx\@let@token\boldsymbol \gdef\thedots@\boldsymbol{\boldsymboldots@}%
+ \else\ifx,\@let@token \gdef\thedots@{\dotsc}%
+ \else\ifx\not\@let@token \gdef\thedots@{\dotsb@}%
+ \else\keybin@
+ \ifgtest@\gdef\thedots@{\dotsb@}%
+ \else\xdef\meaning@{\meaning\@let@token..........}%
+ \xdef\meaning@@{\meaning@}%
+ \@xp\math@\meaning@\math@
+ \ifgtest@
+ \@xp\mathch@\meaning@\mathch@
+ \ifgtest@\@xp\getmathch@\meaning@\getmathch@\fi
+ \else\@xp\macro@\meaning@@\macro@
+ \ifgtest@
+ \@xp\not@\meaning@\not@\ifgtest@\gdef\thedots@{\dotsb@}%
+ \else\@xp\DOTS@\meaning@\DOTS@
+ \ifgtest@
+ \ifcase\number\DOTSCASE@\gdef\thedots@{\dotsb@}%
+ \or\gdef\thedots@{\dotsi}\else\fi
+ \else\@xp\math@\meaning@\math@
+ \ifgtest@\@xp\mathbin@\meaning@\mathbin@
+ \ifgtest@\gdef\thedots@{\dotsb@}%
+ \else\@xp\mathrel@\meaning@\mathrel@
+ \ifgtest@\gdef\thedots@{\dotsb@}%
+ \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
+ \thedots@}
+% \end{macrocode}
+%
+% The \qc{\=} character is necessary in the two \cs{let} assignments
+% in \cs{boldsymboldots@}, because the symbol we are making
+% bold might be an \qc{\=} sign.
+% \begin{macrocode}
+\def\boldsymboldots@#1{%
+ \bold@true\let\@let@token=#1\let\delayed@=#1\mdots@@
+ \boldsymbol#1\bold@false}
+% \end{macrocode}
+%
+% The definition of \cs{@cdots} is merely the \fn{plain.tex}
+% definition of \cs{cdots}.
+% \begin{macrocode}
+\def\@cdots{\mathinner{\cdotp\cdotp\cdotp}}
+\newcommand{\dotsi}{\!\@cdots}
+\let\dotsb@\@cdots
+% \end{macrocode}
+%
+% If any new right delimiters are defined, they would need to be
+% added to the definition of \cs{rightdelim@} in order for \cn{dots}
+% to work properly in all cases.
+% \begin{macrocode}
+\def\rightdelim@{\gtest@true
+ \ifx\@let@token)\else
+ \ifx\@let@token]\else
+ \ifx\@let@token\rbrack\else
+ \ifx\@let@token\}\else
+ \ifx\@let@token\rbrace\else
+ \ifx\@let@token\rangle\else
+ \ifx\@let@token\rceil\else
+ \ifx\@let@token\rfloor\else
+ \ifx\@let@token\rgroup\else
+ \ifx\@let@token\rmoustache\else
+ \ifx\@let@token\right\else
+ \ifx\@let@token\bigr\else
+ \ifx\@let@token\biggr\else
+ \ifx\@let@token\Bigr\else
+ \ifx\@let@token\Biggr\else\gtest@false
+ \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
+\def\extra@{%
+ \rightdelim@\ifgtest@
+ \else\ifx\@let@token$\gtest@true
+ \else\xdef\meaning@{\meaning\@let@token..........}%
+ \@xp\macro@\meaning@\macro@\ifgtest@
+ \@xp\DOTS@\meaning@\DOTS@
+ \ifgtest@
+ \ifnum\DOTSCASE@=\tw@\gtest@true\else\gtest@false
+ \fi\fi\fi\fi\fi}
+\newif\ifbold@
+\def\dotso@{\relaxnext@
+ \ifbold@
+ \let\@let@token\delayed@
+ \def\nextii@{\extra@\@ldots\ifgtest@\,\fi}%
+ \else
+ \def\nextii@{\DN@{\extra@\@ldots\ifgtest@\,\fi}\FN@\next@}%
+ \fi
+ \nextii@}
+% \end{macrocode}
+% Why not save some tokens? (space vs. time).
+% \begin{macrocode}
+\def\extrap@#1{%
+ \DN@{#1\,}%
+ \ifx\@let@token,\else
+ \ifx\@let@token;\else
+ \ifx\@let@token.\else\extra@
+ \ifgtest@\else
+ \let\next@#1\fi\fi\fi\fi\next@}
+% \end{macrocode}
+%
+% The \cn{cdots} command.
+% \begin{macrocode}
+\DeclareRobustCommand{\cdots}{\DN@{\extrap@\@cdots}\FN@\next@}
+\let\dotsb\cdots
+\let\dotsm\cdots
+\DeclareRobustCommand{\dotso}{\relax
+ \ifmmode \DN@{\extrap@\@ldots}%
+ \else \let\next@\tdots@\fi
+ \FN@\next@}
+\DeclareRobustCommand{\dotsc}{%
+ \DN@{\ifx\@let@token;\@ldots\,%
+ \else \ifx\@let@token.\@ldots\,%
+ \else \extra@\@ldots \ifgtest@\,\fi
+ \fi\fi}%
+ \FN@\next@}
+\renewcommand{\longrightarrow}{%
+ \DOTSB\protect\relbar\protect\joinrel\rightarrow}
+\renewcommand{\Longrightarrow}{%
+ \DOTSB\protect\Relbar\protect\joinrel\Rightarrow}
+\renewcommand{\longleftarrow}{%
+ \DOTSB\leftarrow\protect\joinrel\protect\relbar}
+\renewcommand{\Longleftarrow}{%
+ \DOTSB\Leftarrow\protect\joinrel\protect\Relbar}
+\renewcommand{\longleftrightarrow}{\DOTSB\leftarrow\joinrel\rightarrow}
+\renewcommand{\Longleftrightarrow}{\DOTSB\Leftarrow\joinrel\Rightarrow}
+\renewcommand{\mapsto}{\DOTSB\mapstochar\rightarrow}
+\renewcommand{\longmapsto}{\DOTSB\mapstochar\longrightarrow}
+\renewcommand{\hookrightarrow}{\DOTSB\lhook\joinrel\rightarrow}
+\renewcommand{\hookleftarrow}{\DOTSB\leftarrow\joinrel\rhook}
+\renewcommand{\iff}{\DOTSB\;\Longleftrightarrow\;}
+% \end{macrocode}
+% The \cn{doteq} command formerly used \cs{buildrel}; we avoid that
+% because it requires `\cn{over}' as part of its syntax. Use 0pt
+% instead of \cs{z@} for robustitude.
+% \begin{macrocode}
+\renewcommand{\doteq}{%
+ \DOTSB\mathrel{\mathop{\kern0pt =}\limits^{\textstyle.}}}
+% \end{macrocode}
+%
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \section{Integral signs}
+%
+% The straightforward \cs{ifinner} test to see if the current math
+% context is non-display, fails if, for instance, we are typesetting
+% a multiline display within an \cs{halign}, with the pieces going
+% into constructions like
+% \begin{verbatim}
+% $\displaystyle...$
+% \end{verbatim}
+% So we need a better test to find out if we are `in a display'. We
+% therefore create \cs{if@display}.
+%
+% \begin{macrocode}
+\newif\if@display
+\everydisplay\@xp{\the\everydisplay \@displaytrue}
+% \end{macrocode}
+%
+% Default value for integral limits is \cs{nolimits}, see the
+% definition of the `nointlimits' option.
+% \begin{macrocode}
+\renewcommand{\int}{\DOTSI\intop\ilimits@}
+\renewcommand{\oint}{\DOTSI\ointop\ilimits@}
+\def\intkern@{\mkern-6mu\mathchoice{\mkern-3mu}{}{}{}}
+\def\intdots@{\mathchoice{\@cdots}%
+ {{\cdotp}\mkern1.5mu{\cdotp}\mkern1.5mu{\cdotp}}%
+ {{\cdotp}\mkern1mu{\cdotp}\mkern1mu{\cdotp}}%
+ {{\cdotp}\mkern1mu{\cdotp}\mkern1mu{\cdotp}}}
+%
+\newcommand{\iint}{\DOTSI\protect\MultiIntegral{2}}
+\newcommand{\iiint}{\DOTSI\protect\MultiIntegral{3}}
+\newcommand{\iiiint}{\DOTSI\protect\MultiIntegral{4}}
+\newcommand{\idotsint}{\DOTSI\protect\MultiIntegral{0}}
+% \end{macrocode}
+%
+% If the \cs{limits} option is applied, use \cs{mathop} and fudge
+% the left-hand space a bit to make the subscript visually centered.
+%
+% \verb'#1' is the multiplicity.
+% \begin{macrocode}
+\newcommand{\MultiIntegral}[1]{%
+ \edef\ints@c{\noexpand\intop
+ \ifnum#1=\z@\noexpand\intdots@\else\noexpand\intkern@\fi
+ \ifnum#1>\tw@\noexpand\intop\noexpand\intkern@\fi
+ \ifnum#1>\thr@@\noexpand\intop\noexpand\intkern@\fi
+ \noexpand\intop
+ \noexpand\ilimits@
+ }%
+ \futurelet\@let@token\ints@a
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\ints@a{%
+ \ifx\limits\@let@token \ints@b
+ \else \ifx\displaylimits\@let@token \ints@b
+ \else\ifx\ilimits@\displaylimits \ints@b
+ \fi\fi\fi
+ \ints@c
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\ints@b{%
+ \mkern-7mu\mathchoice{\mkern-2mu}{}{}{}%
+ \mathop\bgroup
+ \mkern7mu\mathchoice{\mkern2mu}{}{}{}%
+ \let\ilimits@\egroup
+}%
+% \end{macrocode}
+%
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \section{Size dependent definitions}
+%
+% We now define all stuff which has to change whenever a new math
+% size is to be activated. \latex/ provides a hook called
+% |\every@math@size| to support such a need. All assignments in the
+% |\every@math@size| hook that need to take outside effect should be
+% global.
+%
+% \subsection{Struts for math}
+%
+% The various kinds of struts could use some analysis and perhaps
+% consolidation.
+%
+% For example perhaps the \cn{bBigg} delimiters could use
+% \begin{verbatim}
+% 1.2\ht\strutbox (1.8, 2.4, 3.0)
+% \end{verbatim}
+% instead of
+% \begin{verbatim}
+% 1.0\big@size (1.5, 2.0, 2.5)
+% \end{verbatim}
+% since \cs{strut} is reset with every size change [mjd, 1994/10/07].
+% But this change would introduce the possibility of changed line
+% and page breaks in existing documents, so would need to be
+% handled with care.
+%
+% \begin{macro}{\Mathstrut@}
+% \begin{macro}{\Mathstrutbox@}
+% \begin{macro}{\resetMathstrut@}
+% Here comes the code for Spivak's |\Mathstrut@|.
+% \begin{macrocode}
+\newbox\Mathstrutbox@
+\setbox\Mathstrutbox@=\hbox{}
+\def\Mathstrut@{\copy\Mathstrutbox@}
+% \end{macrocode}
+% The setting of the height and depth of the |\Mathstrutbox@| is done
+% in the |\every@math@size| hook since it depends on the height of a
+% paren. As \cs{every@math@size} is triggered by |$| after a font
+% size change, we want to avoid using another math formula |$...$| to
+% measure the math paren height; instead we go through the mathcode
+% of the \qc{\(} character. We assume that the mathcode has a leading
+% hex digit 4 indicating `open delimiter'; this allows us to make a
+% relatively simple function to get the correct font and character
+% position.
+% \begin{macrocode}
+\def\resetMathstrut@{%
+ \setbox\z@\hbox{%
+ \mathchardef\@tempa\mathcode`\(\relax
+ \def\@tempb##1"##2##3{\the\textfont"##3\char"}%
+ \expandafter\@tempb\meaning\@tempa \relax
+ }%
+% \end{macrocode}
+% These height and depth assignments are implicitly global.
+% \begin{macrocode}
+ \ht\Mathstrutbox@\ht\z@ \dp\Mathstrutbox@\dp\z@
+}
+\addto@hook\every@math@size{\resetMathstrut@}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\strut@}
+% \begin{macro}{\strutbox@}
+% Next follows a special internal strut which is supposed to match
+% the height and the depth of a normal |\strut| minus
+% |\normallineskiplimit| according to M. Spivak.
+%
+% This should really go into the definition of \cs{size@update}, and
+% then the box reset could be local; but \cs{size@update} doesn't
+% have any hook and is handled in such a way that it cannot even be
+% changed except by changing \cs{set@fontsize}. So instead we put
+% \cs{reset@strutbox@} into \cs{every@math@size} and make it global.
+% Then because of some complications in the way \cs{glb@settings} and
+% \cs{check@mathfonts} work, we have to re-invoke it at the beginning
+% of every environment that might use \cs{strut@}. Fortunately this
+% can be achieved (more or less) through the \cs{spread@equation}
+% hook. [mjd,2000/03/10]
+% \begin{macrocode}
+\newbox\strutbox@
+\def\strut@{\copy\strutbox@}
+\def\reset@strutbox@{%
+ \global\setbox\strutbox@\hbox{%
+ \lower.5\normallineskiplimit
+ \vbox{\kern-\normallineskiplimit\copy\strutbox}}}
+\addto@hook\every@math@size{\reset@strutbox@}
+\AtBeginDocument{\reset@strutbox@}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Big delimiters}
+%
+% We are now going to redefine the plain \tex/ commands \cn{big},
+% \cn{bigl}, etc., to produce different results in different sizes.
+% Actually we only have to define \cn{big}, \cn{Big}, etc., since
+% they are used to construct the directional versions \cn{bigl},
+% \cn{bigr}, and the rest.
+%
+% \begin{macro}{\big}
+% \begin{macro}{\Big}
+% \begin{macro}{\bigg}
+% \begin{macro}{\Bigg}
+% To save token space we put everything into the common macro
+% |\bBigg@|. The macros are now simply a call to |\bBigg@| with a
+% factor to determine the correct height of the delimiter as an
+% argument. This code should better go into a future version of
+% the \latex/ kernel; the macro |\n@space| is then superfluous (since
+% it is only used once) and should be removed to avoid wasting hash
+% table space unnecessarily.
+% \begin{macrocode}
+\renewcommand{\big}{\bBigg@\@ne}
+\renewcommand{\Big}{\bBigg@{1.5}}
+\renewcommand{\bigg}{\bBigg@\tw@}
+\renewcommand{\Bigg}{\bBigg@{2.5}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\bBigg@}
+% Now we tackle the macro which has to do the real work. It
+% actually has two arguments, the factor and the wanted delimiter.
+% \begin{macrocode}
+\def\bBigg@#1#2{%
+% \end{macrocode}
+% We start with an extra set of braces because we want
+% constructions like |\def\bigl{\mathopen\big}| to work without the
+% overhead of extra arguments.
+% \begin{macrocode}
+ {\@mathmeasure\z@{\nulldelimiterspace\z@}%
+ {\left#2\vcenter to#1\big@size{}\right.}%
+ \box\z@}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\big@size}
+% |\big@size| needs to be set to 1.2 times the height of a math
+% paren. This height is already recorded in |\Mathstrutbox@|.
+% \begin{macrocode}
+\addto@hook\every@math@size{%
+ \global\big@size 1.2\ht\Mathstrutbox@
+ \global\advance\big@size 1.2\dp\Mathstrutbox@ }
+\newdimen\big@size
+% \end{macrocode}
+% \end{macro}
+%
+%
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \section{Math accents}
+%
+% We want to change the leading digit of math accents to be
+% \cs{accentclass@} so that it can vary according to certain internal
+% purposes.
+% \begin{macrocode}
+\def\accentclass@{7}
+\def\noaccents@{\def\accentclass@{0}}
+% \end{macrocode}
+%
+% There are a few \meta{math alphabet}s in the standard fonts where
+% we have to change the extra macros because the standard definitions
+% don't account for these accent problems. The first is for the
+% \cs{mathit} command.
+% \begin{macrocode}
+\DeclareFontEncoding{OML}{}{\noaccents@}
+% \end{macrocode}
+% The next one corrects the \cs{cal} alphabet.
+% \begin{macrocode}
+\DeclareFontEncoding{OMS}{}{\noaccents@}
+% \end{macrocode}
+%
+% Triple and quadruple dot accents.
+% \begin{macrocode}
+\newcommand{\dddot}[1]{%
+ {\mathop{#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@
+ \hbox{\normalfont ...}\vss}}}}
+\newcommand{\ddddot}[1]{%
+ {\mathop{#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@
+ \hbox{\normalfont....}\vss}}}}
+% \end{macrocode}
+%
+% The following code deals with support for compound accents.
+% By redefining \cs{set@mathaccent} we ensure that
+% \cn{DeclareMathAccent} will define accent commands to run our
+% \cs{mathaccentV} function instead of the primitive \cs{mathaccent}.
+% \begin{macrocode}
+\def\set@mathaccent#1#2#3#4{%
+ \xdef#2{\@nx\protect\@nx\mathaccentV
+ {\@xp\@gobble\string#2}\hexnumber@#1#4}%
+}
+% \end{macrocode}
+%
+% We redefine the standard math accent commands to
+% call \cs{mathaccentV}, using the mathgroup/encoding-number
+% information embedded in their previous definitions. If the
+% definition of an accent command does not have the expected form, we
+% leave the accent command alone, but give a warning. For widehat and
+% widetilde, we need to avoid clobbering the definitions done by the
+% \pkg{amsfonts} package. Arbitrating the contention between
+% \pkg{amsmath} and \pkg{amsfonts} to allow doubling a widetilde
+% accent looks tricky, so for the time being [mjd,1999/07/19] we just
+% leave \cn{widehat} and \cn{widetilde} alone. As a result, if the
+% \pkg{amsmath} package is loaded on top of a vanilla \latex/
+% documentclass, everything runs through with no warnings. If a
+% Lucida Math or other math fonts package is loaded in addition to
+% \pkg{amsmath}, there are greater difficulties, but those are
+% addressed elsewhere.
+% \begin{macrocode}
+\def\@tempa#1{\@xp\@tempb\meaning#1\@nil#1}
+\def\@tempb#1>#2#3 #4\@nil#5{%
+ \@xp\ifx\csname#3\endcsname\mathaccent
+ \@tempc#4?"7777\@nil#5%
+ \else
+ \PackageWarningNoLine{amsmath}{%
+ Unable to redefine math accent \string#5}%
+ \fi
+}
+\def\@tempc#1"#2#3#4#5#6\@nil#7{%
+ \chardef\@tempd="#3\relax\set@mathaccent\@tempd{#7}{#2}{#4#5}}
+\@tempa{\hat}
+\@tempa{\check}
+\@tempa{\tilde}
+\@tempa{\acute}
+\@tempa{\grave}
+\@tempa{\dot}
+\@tempa{\ddot}
+\@tempa{\breve}
+\@tempa{\bar}
+\@tempa{\vec}
+\@ifundefined{mathring}{%
+ \DeclareMathAccent{\mathring}{\mathalpha}{operators}{"17}
+}{%
+ \@tempa{\mathring}
+}
+%%\@tempa\widetilde
+%%\@tempa\widehat
+% \end{macrocode}
+%
+% Regression testing of amsmath 2.0 showed that in some documents
+% there occurred fragments of the form
+% \begin{verbatim}
+% \hat\mathcal{G}
+% \end{verbatim}
+% This is not at all correct syntax for the argument of a \latex/
+% command but it produced the intended result anyway because of the
+% internal syntax of the \cs{mathaccent} primitive. With
+% \cs{mathaccentV}, it will yield an error message. We therefore do a
+% special check for such syntax problems in order to make the error
+% message more informative.
+% \begin{macrocode}
+\newcommand{\acc@check}{}
+\newcommand{\acc@error}{}
+\def\acc@check{\@ifnextchar\@empty\relax\acc@error}
+% \end{macrocode}
+% We put most of the tokens in a separate macro so they do not get
+% scanned unless they are actually needed.
+% \begin{macrocode}
+\def\acc@error{%
+ \@amsmath@err{%
+ Improper argument for math accent:\MessageBreak
+ Extra braces must be added to prevent wrong output%
+ }\@ehc
+}
+% \end{macrocode}
+%
+% For \cs{mathaccentV} part of the processing is dependent on the
+% depth of nesting of math accent commands. We introduce a dedicated
+% counter for this instead of using chardef because we want to
+% increment/decrement it during processing, and incrementing a
+% chardef integer is more work.
+% \begin{macrocode}
+\newcount\macc@depth
+% \end{macrocode}
+%
+% Provide this function in case it is not already available.
+% \begin{macrocode}
+\long\def\@gobblethree#1#2#3{}
+% \end{macrocode}
+%
+% The \cs{mathaccentV} function first counts the number of nested
+% math accents by setting the argument in a throw-away box. (This is
+% not as risky as such an operation would normally be because the
+% argument is generally either a simple math symbol or a nested math
+% accent call with a simple math symbol at the bottom of the
+% nesting.)
+%
+% There are two benefits from counting the nesting levels first
+% before doing anything else: (1) we can fall back to a simple
+% \cs{mathaccent} call if the nesting depth is 1, and (2) if the
+% nesting depth is greater than 1, we would like to be able to tell
+% when we have reached the lowest level, because at that point we
+% want to save the argument for later use and place an accent on top
+% of a phantom copy.
+%
+% When we have multiple accents, they will be placed on top of the
+% invisible box, followed by some suitable kerns, then a visible copy
+% of the nucleus. To see why, let us look at what goes wrong with a
+% double application of the \cs{mathaccent} primitive. The standard
+% definition of \cs{hat} is \verb'\mathaccent"705E', so
+% \verb'\hat{\hat{F}}' expands to
+%\begin{verbatim}
+%\mathaccent"705E{\mathaccent"705E{F}}
+%\end{verbatim}
+% The result of this operation is
+%\begin{verbatim}
+%\vbox(12.11111+0.0)x7.81946
+%.\hbox(6.94444+0.0)x0.0, shifted 1.40973
+%..\OT1/cmr/m/n/10 ^
+%.\kern-4.30554
+%.\vbox(9.47221+0.0)x7.81946
+%..\hbox(6.94444+0.0)x0.0, shifted 2.24309
+%...\OT1/cmr/m/n/10 ^
+%..\kern-4.30554
+%..\hbox(6.83331+0.0)x7.81946
+%...\OML/cmm/m/it/10 F
+%\end{verbatim}
+% \tex/ starts by constructing a vbox with the hat character on top
+% of the F. Then it puts another hat character on top of the vbox;
+% but without skew information, because that is only applied by
+% \cs{mathaccent} when the base object is a simple symbol. So the
+% first accent is skewed to the correct position but all later
+% accents are not. By the way, the actual width of the F in the above
+% example is less than 7.81946; the box in which it is packed was
+% automatically lengthened by the width of the F's italic correction
+% (without actually putting in a kern for it).
+%
+% To get the second accent shifted farther to the right we
+% artificially increase the width of the innermost box and add
+% a compensating kern afterward. Furthermore, to get proper placement
+% of a following subscript or superscript, we take the base symbol
+% out, leaving a phantom in its place, and print it by itself
+% following the kern. We then need to increase the kern amount to
+% move the base character backward under the accents again.
+% Here is what the results look like:
+%\begin{verbatim}
+%\vbox(12.11111+0.0)x9.48618
+%.\hbox(6.94444+0.0)x0.0, shifted 2.24309
+%..\OT1/cmr/m/n/10 ^
+%.\kern-4.30554
+%.\vbox(9.47221+0.0)x9.48618
+%..\hbox(6.94444+0.0)x0.0, shifted 2.24309
+%...\OT1/cmr/m/n/10 ^
+%..\kern-4.30554
+%..\hbox(6.83331+0.0)x9.48618
+%...\hbox(6.83331+0.0)x7.81946
+%...\kern 1.66672
+%\kern -9.48618
+%\OML/cmm/m/it/10 F
+%\end{verbatim}
+%
+% Much of this implementation is based on code from the \pkg{accents}
+% package of Javier Bezos. I added the test to revert to a simple
+% \cs{mathaccent} when accents are not nested, and some other
+% refinements to reduce the number of kerns used (to conserve box
+% memory) and the number of cycles through \cs{mathchoice} (to make
+% things run a little faster). It was all rather difficult and my
+% first two attempts had serious bugs but I hope and believe that
+% this version will do better. [mjd,2000/03/15]
+%
+% The \qq{V} in \cs{mathaccentV} is just an indication that it takes
+% five arguments. It is important that the name includes
+% \texttt{mathaccent}, otherwise \cs{DeclareMathAccent} will balk at
+% redefining one of our accent commands, for example when an
+% alternative math font package is loaded.
+% \begin{macrocode}
+\def\mathaccentV#1#2#3#4#5{%
+ \ifmmode
+ \gdef\macc@tmp{\macc@depth\@ne}%
+ \setbox\z@\hbox{%
+ \let\mathaccentV\macc@test
+ \let\use@mathgroup\@gobbletwo \let\select@group\@gobblethree
+ \frozen@everymath{}$#5$%
+ }%
+ \macc@tmp
+ \ifnum\macc@depth=\@ne
+ \global\let\macc@nucleus\@empty
+ \mathaccent"\accentclass@
+ \else
+ \@xp\macc@nested
+ \fi
+ #2#3#4{#5}%
+ \macc@nucleus
+ \else
+ \@xp\nonmatherr@\csname#1\endcsname
+ \fi
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\macc@test#1#2#3#4{\xdef\macc@tmp{\macc@tmp\advance\macc@depth\@ne}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\macc@group{-1}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\macc@nested#1#2#3#4{%
+ \begingroup
+ \let\math@bgroup\@empty \let\math@egroup\macc@set@skewchar
+ \mathsurround\z@ \frozen@everymath{\mathgroup\macc@group\relax}%
+ \macc@set@skewchar\relax
+ \let\mathaccentV\macc@nested@a
+ \macc@nested@a\relax#1#2#3{#4}%
+ \endgroup
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\macc@palette\mathpalette
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\macc@nested@a#1#2#3#4#5{%
+% \end{macrocode}
+% This test saves some work that would otherwise be always repeated
+% fourfold thanks to \cs{mathchoice}.
+% \begin{macrocode}
+ \ifnum\macc@group=\mathgroup
+ \else \macc@set@skewchar\relax \edef\macc@group{\the\mathgroup}%
+ \fi
+ \mathchardef\macc@code "\accentclass@ #2#3#4\relax
+ \macc@palette\macc@a{#5}%
+}
+% \end{macrocode}
+%
+% The reason that \cs{macc@set@skewchar} takes an argument is so that
+% it can serve as a direct substitute for \cs{math@egroup}, in
+% addition to being used separately.
+%
+% Setting a skewchar with this method works for symbols of variable
+% mathgroup (class 7, letters and numbers) but not necessarily for
+% special symbols like \cn{partial} or \cs{xi} whose mathgroup
+% doesn't change; fortunately the most commonly used ones come from
+% mathgroup one, which is the fall-back mathgroup for skewchar.
+% \begin{macrocode}
+\def\macc@set@skewchar#1{%
+ \begingroup
+ \ifnum\mathgroup=\m@ne \let\@tempa\@ne
+ \else
+ \ifnum\skewchar\textfont\mathgroup=\m@ne \let\@tempa\@ne
+ \else \let\@tempa\mathgroup
+ \fi
+ \fi
+ \count@=\skewchar\textfont\@tempa
+ \advance\count@"7100
+ \edef\@tempa{\endgroup
+ \mathchardef\noexpand\macc@skewchar=\number\count@\relax}%
+ \@tempa
+ #1%
+}
+% \end{macrocode}
+%
+% Arg1 is math-style, arg2 is accent base object. We assume that math
+% style doesn't change within the nested group of accents; this means
+% we can set \cs{macc@style} only once and redefine \cs{macc@palette}
+% to use it, in order to run \cs{mathchoice} only once instead of
+% multiplying the calls exponentially as the nesting level increases.
+% \begin{macrocode}
+\def\macc@a#1#2{%
+ \begingroup
+ \let\macc@style#1\relax
+ \def\macc@palette##1{##1\macc@style}%
+ \advance\macc@depth\m@ne
+ \ifnum\macc@depth=\z@
+ \gdef\macc@nucleus{#2}%
+% \end{macrocode}
+% Extra \cs{@empty} tokens are to prevent low-level \tex/ errors from
+% the potential syntactic error that \cs{acc@check} checks for.
+% \begin{macrocode}
+ \setbox\z@\hbox{$#1#2\@empty{}\macc@skewchar$}%
+ \setbox\tw@\hbox{$#1#2\@empty\macc@skewchar$}%
+ \dimen@\tw@\wd\tw@ \advance\dimen@-\tw@\wd\z@
+ \xdef\macc@kerna{\the\dimen@\relax}%
+ \setbox4\hbox{$#1#2\acc@check\@empty$}%
+ \global\setbox\@ne\hbox to\wd4{}%
+ \ht\@ne\ht4 \dp\@ne\dp4
+ \xdef\macc@kernb{\the\wd4\relax}%
+ \mathaccent\macc@code{\box\@ne\kern\macc@kerna}%
+ \else
+ \mathaccent\macc@code{\let\macc@adjust\@empty #1#2\@empty}%
+ \macc@adjust
+ \fi
+ \endgroup
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\macc@adjust{%
+ \dimen@\macc@kerna\advance\dimen@\macc@kernb
+ \kern-\dimen@
+}
+% \end{macrocode}
+%
+% The commands \cs{Hat}, \cs{Tilde}, \ldots, are supported as
+% synonyms of \cs{hat}, \cs{tilde}, \ldots, for backward
+% compatibility.
+% \begin{macrocode}
+\def\Hat{\hat}
+\def\Check{\check}
+\def\Tilde{\tilde}
+\def\Acute{\acute}
+\def\Grave{\grave}
+\def\Dot{\dot}
+\def\Ddot{\ddot}
+\def\Breve{\breve}
+\def\Bar{\bar}
+\def\Vec{\vec}
+% \end{macrocode}
+%
+% This error message about math mode is used several times so we make
+% an abbreviation for it.
+% \begin{macrocode}
+\def\nonmatherr@#1{\@amsmath@err{\protect
+ #1 allowed only in math mode}\@ehd}
+% \end{macrocode}
+%
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \section{Mods, continued fractions, etc.}
+%
+% The commands \cn{bmod}, \cn{pmod}, \cn{pod}, \cn{mod} aren't
+% currently robust. [mjd, 1994/09/05]
+% \begin{macrocode}
+\renewcommand{\bmod}{\nonscript\mskip-\medmuskip\mkern5mu\mathbin
+ {\operator@font mod}\penalty900
+ \mkern5mu\nonscript\mskip-\medmuskip}
+\newcommand{\pod}[1]{\allowbreak
+ \if@display\mkern18mu\else\mkern8mu\fi(#1)}
+\renewcommand{\pmod}[1]{\pod{{\operator@font mod}\mkern6mu#1}}
+\newcommand{\mod}[1]{\allowbreak\if@display\mkern18mu
+ \else\mkern12mu\fi{\operator@font mod}\,\,#1}
+% \end{macrocode}
+%
+% Continued fractions. The optional arg l or r controls horizontal
+% placement of the numerators. The |\kern-\nulldelimiterspace|
+% is needed in the definition if we want the right-hand sides of the
+% fraction rules to line up. The \cs{strut} keeps the numerator of
+% a subsidiary cfrac from coming too close to the fraction rule above
+% it.
+% \begin{macrocode}
+\newcommand{\cfrac}[3][c]{{\displaystyle\frac{%
+ \strut\ifx r#1\hfill\fi#2\ifx l#1\hfill\fi}{#3}}%
+ \kern-\nulldelimiterspace}
+% \end{macrocode}
+%
+% \cn{overset} and \cn{underset} put symbols above, respectively
+% below, a symbol that is not a \cs{mathop} and therefore does not
+% naturally accept limits. \cs{binrel@@} uses information collected
+% by \cs{binrel@} to make the resulting construction be of type
+% mathrel or mathbin if the base symbol is either of those types.
+% \begin{macrocode}
+\newcommand{\overset}[2]{\binrel@{#2}%
+ \binrel@@{\mathop{\kern\z@#2}\limits^{#1}}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newcommand{\underset}[2]{\binrel@{#2}%
+ \binrel@@{\mathop{\kern\z@#2}\limits_{#1}}}
+% \end{macrocode}
+%
+% \cn{sideset} allows placing `adscript' symbols at the four
+% corners of a \cs{mathop}, \emph{in addition to} limits. Left-side
+% adscripts go into arg \arg{1}, in the form |_{...}^{...}|, and
+% right-side adscripts go into arg \arg{2}.
+%
+% As currently written [mjd, 1995/01/21] this is pretty haphazard.
+% In order to really make it work properly in full generality we'd
+% have to read and measure the top and bottom limits and use
+% mathchoice to always get the right mathstyle for each piece,
+% etc., etc.
+% \begin{macrocode}
+\newcommand{\sideset}[3]{%
+ \@mathmeasure\z@\displaystyle{#3}%
+% \end{macrocode}
+% Use a global box assignment here since the depth override is
+% implicitly global. Then move the constructed box to a local box
+% register (2) to ensure it won't get destroyed during the next two
+% mathmeasure statements. This precaution may be more extreme than
+% necessary in practice.
+% \begin{macrocode}
+ \global\setbox\@ne\vbox to\ht\z@{}\dp\@ne\dp\z@
+ \setbox\tw@\box\@ne
+ \@mathmeasure4\displaystyle{\copy\tw@#1}%
+ \@mathmeasure6\displaystyle{#3\nolimits#2}%
+ \dimen@-\wd6 \advance\dimen@\wd4 \advance\dimen@\wd\z@
+ \hbox to\dimen@{}\mathop{\kern-\dimen@\box4\box6}%
+}
+% \end{macrocode}
+%
+% \begin{macro}{\smash}
+% We add to the \cn{smash} command an optional argument
+% denoting the part of the formula to be smashed.
+% \begin{macrocode}
+\renewcommand{\smash}[1][tb]{%
+ \def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}%
+ \edef\finsm@sh{\csname mb@#1\endcsname\z@\z@ \box\z@}%
+ \ifmmode \@xp\mathpalette\@xp\mathsm@sh
+ \else \@xp\makesm@sh
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \section{Extensible arrows}
+%
+% The minus sign used in constructing these arrow fills is smashed so
+% that superscripts above the arrows won't be too high. This
+% primarily affects the \cn{xleftarrow} and \cn{xrightarrow} arrows.
+%
+% \begin{macrocode}
+\mathchardef\std@minus\mathcode`\-\relax
+\mathchardef\std@equal\mathcode`\=\relax
+% \end{macrocode}
+% In case some alternative math fonts are loaded later:
+% \begin{macrocode}
+\AtBeginDocument{%
+ \mathchardef\std@minus\mathcode`\-\relax
+ \mathchardef\std@equal\mathcode`\=\relax
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\relbar{\mathrel{\mathpalette\mathsm@sh\std@minus}}
+\def\Relbar{\mathrel\std@equal}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\arrowfill@#1#2#3#4{%
+ $\m@th\thickmuskip0mu\medmuskip\thickmuskip\thinmuskip\thickmuskip
+ \relax#4#1\mkern-7mu%
+ \cleaders\hbox{$#4\mkern-2mu#2\mkern-2mu$}\hfill
+ \mkern-7mu#3$%
+}
+\def\leftarrowfill@{\arrowfill@\leftarrow\relbar\relbar}
+\def\rightarrowfill@{\arrowfill@\relbar\relbar\rightarrow}
+\def\leftrightarrowfill@{\arrowfill@\leftarrow\relbar\rightarrow}
+\def\Leftarrowfill@{\arrowfill@\Leftarrow\Relbar\Relbar}
+\def\Rightarrowfill@{\arrowfill@\Relbar\Relbar\Rightarrow}
+\def\Leftrightarrowfill@{\arrowfill@\Leftarrow\Relbar\Rightarrow}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\overarrow@#1#2#3{\vbox{\ialign{##\crcr#1#2\crcr
+ \noalign{\nointerlineskip}$\m@th\hfil#2#3\hfil$\crcr}}}
+\renewcommand{\overrightarrow}{%
+ \mathpalette{\overarrow@\rightarrowfill@}}
+\renewcommand{\overleftarrow}{%
+ \mathpalette{\overarrow@\leftarrowfill@}}
+\newcommand{\overleftrightarrow}{%
+ \mathpalette{\overarrow@\leftrightarrowfill@}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\underarrow@#1#2#3{%
+ \vtop{\ialign{##\crcr$\m@th\hfil#2#3\hfil$\crcr
+ \noalign{\nointerlineskip\kern1.3\ex@}#1#2\crcr}}}
+\newcommand{\underrightarrow}{%
+ \mathpalette{\underarrow@\rightarrowfill@}}
+\newcommand{\underleftarrow}{%
+ \mathpalette{\underarrow@\leftarrowfill@}}
+\newcommand{\underleftrightarrow}{%
+ \mathpalette{\underarrow@\leftrightarrowfill@}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%\newcommand{\xrightarrow}[2][]{\ext@arrow 0359\rightarrowfill@{#1}{#2}}
+\def\ext@arrow#1#2#3#4#5#6#7{%
+ \mathrel{\mathop{%
+% \end{macrocode}
+% Measure the superscript and subscript.
+% \begin{macrocode}
+ \setbox\z@\hbox{#5\displaystyle}%
+ \setbox\tw@\vbox{\m@th
+ \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}%
+ \hbox{$\scriptstyle\mkern#3mu{#7}\mkern#4mu$}%
+ \copy\z@
+ }%
+ \hbox to\wd\tw@{\unhbox\z@}}%
+% \end{macrocode}
+% We don't want to place an empty subscript since that will produce
+% too much blank space below the arrow.
+% \begin{macrocode}
+ \limits
+ \@ifnotempty{#7}{^{\if0#1\else\mkern#1mu\fi
+ #7\if0#2\else\mkern#2mu\fi}}%
+ \@ifnotempty{#6}{_{\if0#1\else\mkern#1mu\fi
+ #6\if0#2\else\mkern#2mu\fi}}}%
+}
+% \end{macrocode}
+%
+% Some extensible arrows to serve as mathrels and taking
+% sub/superscripts. These commands are robust because they take an
+% optional argument.
+% \begin{macrocode}
+\newcommand{\xrightarrow}[2][]{\ext@arrow 0359\rightarrowfill@{#1}{#2}}
+\newcommand{\xleftarrow}[2][]{\ext@arrow 3095\leftarrowfill@{#1}{#2}}
+% \end{macrocode}
+%
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \section{Array-related environments}
+% \subsection{Remarks}
+%
+% Because these environments can be nested within the equation
+% structures that allow \cn{tag}, there is some cross-influence in
+% the internal workings of the \cn{\\} command.
+%
+% \subsection{The \cn{substack} command}
+%
+% The \cn{substack} command can be used to set subscripts
+% and superscripts that consist of several lines. Usage:
+% \begin{verbatim}
+% X_{\substack{a=1\\b=2}}
+% \end{verbatim}
+%
+% \changes{v2.0}{1999/06/17}{Removed environment definitions: Sb, Sp}
+%
+% \begin{environment}{subarray}
+% The \env{subarray} environment makes a small-size array suitable
+% for use in a subscript or superscript. At the moment the supported
+% arguments are not the full possibilities of \env{array} but only
+% |c| or |l| for centered or left-aligned. And only one column.
+% \begin{macrocode}
+\newenvironment{subarray}[1]{%
+% \end{macrocode}
+% Note: The predecessors of \env{subarray} (\env{Sb} and \env{Sp},
+% inherited from \amstex/) used \cs{vbox} instead of \cs{vcenter}.
+% But when a multiline subscript is placed in \cs{limits} position
+% \cs{vcenter} is no worse than \cs{vbox}, and when it is placed
+% in the \cs{nolimits} position (e.g., for an integral), \cs{vcenter}
+% provides clearly better positioning than \cs{vbox}.
+% \begin{macrocode}
+ \vcenter\bgroup
+% \end{macrocode}
+% Use \cs{Let@} to set the proper meaning of the \cn{\\} and \cn{\\*}
+% commands. And restore the meaning of \cs{math@cr@@@} to \cs{cr}
+% (see above) in case \env{subarray} is used inside one of the more
+% complicated alignment macros where the meaning of \cs{math@cr@@@}
+% is different. Similarly, call \cs{default@tag} to ensure that a
+% line break here doesn't get an equation number!
+% \begin{macrocode}
+ \Let@ \restore@math@cr \default@tag
+% \end{macrocode}
+% Set the line spacing to be the same as \cs{atop} (when \cs{atop}
+% occurs in \cs{textstyle} or smaller), cf \textit{The \tex/book},
+% Appendix G.
+% \begin{macrocode}
+ \baselineskip\fontdimen10 \scriptfont\tw@
+ \advance\baselineskip\fontdimen12 \scriptfont\tw@
+ \lineskip\thr@@\fontdimen8 \scriptfont\thr@@
+ \lineskiplimit\lineskip
+% \end{macrocode}
+% Start the \cs{vbox} \cs{halign} structure that encloses the
+% contents. Notice that we never get \cs{scriptscriptstyle}. That
+% would require a \cs{mathchoice} (ugh).
+% \begin{macrocode}
+ \ialign\bgroup\ifx c#1\hfil\fi
+ $\m@th\scriptstyle##$\hfil\crcr
+}{%
+ \crcr\egroup\egroup
+}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{macro}{\substack}
+% The \cn{substack} command is just an abbreviation for the
+% most common use of \env{subarray}.
+% \begin{macrocode}
+\newcommand{\substack}[1]{\subarray{c}#1\endsubarray}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Matrices}
+%
+% \begin{environment}{smallmatrix}
+% \env{smallmatrix} is again an alignment, this time in a centered
+% box. The opening incantations are basically the same as those in
+% \cs{multilimits@}, followed by the alignment itself. A remark:
+% the baselineskip (|9\ex@|) used in \amstex/ is too large for
+% use in text with the usual baselineskip of $12$ or $13$ points; we
+% change it here to |6\ex@| and also adjust the \cs{lineskip}
+% and \cs{lineskiplimit} slightly to compensate. (MJD)
+% \begin{macrocode}
+\newenvironment{smallmatrix}{\null\,\vcenter\bgroup
+ \Let@\restore@math@cr\default@tag
+ \baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip
+ \ialign\bgroup\hfil$\m@th\scriptstyle##$\hfil&&\thickspace\hfil
+ $\m@th\scriptstyle##$\hfil\crcr
+}{%
+ \crcr\egroup\egroup\,%
+}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{environment}{matrix}
+% The \env{matrix} environment is just an \env{array} that provides
+% up to ten centered columns, so that users don't have to give the
+% col-spec argument explicitly---unless they want some of the columns
+% noncentered, that is. The maximum number of columns is actually not
+% fixed at ten but given by the counter |MatrixCols|, and can
+% therefore be increased by changing that counter.
+%
+% The extra space of \cn{arraycolsep} that \env{array} adds on each
+% side is a waste so we remove it here (perhaps we should instead
+% remove it from \env{array} in general, but that's a harder task).
+%
+% TODO: Think about re-implementing \cn{matrix} to get rid of the
+% \cs{c@MatrixCols} limit and have hard-wired preamble that doesn't
+% have to be rebuilt each time.
+%
+% We must use \cn{renewenvironment} for \env{matrix} and
+% \env{pmatrix} because \latex/ doesn't kill the definitions found in
+% \fn{plain.tex}, even though it probably should because of their
+% foreign syntax.
+% \begin{macrocode}
+\renewenvironment{matrix}{%
+ \matrix@check\matrix\env@matrix
+}{%
+ \endarray \hskip -\arraycolsep
+}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{macro}{\env@matrix}
+%
+% \begin{macrocode}
+\def\env@matrix{\hskip -\arraycolsep
+ \let\@ifnextchar\new@ifnextchar
+ \array{*\c@MaxMatrixCols c}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\c@MaxMatrixCols}
+% \begin{macrocode}
+\newcount\c@MaxMatrixCols \c@MaxMatrixCols=10
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\matrix@check}
+% For various reasons, authors sometimes use the Plain \TeX{} form of
+% \cn{matrix} or \cn{pmatrix} in \LaTeX{} documents. If they later
+% add an invocation of the \pkg{amsmath} package to their document,
+% the Plain \TeX{} syntax would lead to rather unintelligible error
+% messages. The \cs{matrix@check} function does some checking to
+% forestall that problem.
+% \begin{macrocode}
+\def\matrix@check#1{%
+ \@xp\ifx\csname\@currenvir\endcsname#1%
+ \else\matrix@error#1%
+% \end{macrocode}
+% This error recovery is not that good but is better than the
+% infinite loop that can result from calling \cs{array} without a
+% matching \cs{endarray}. (The array setup leaves \cs{par} empty.)
+% \begin{macrocode}
+ \@xp\@gobble
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\matrix@error}
+%
+% \begin{macrocode}
+\def\matrix@error#1{%
+ \@amsmath@err{%
+Old form `\string#1' should be \string\begin{\@xp\@gobble\string#1}%
+ }{%
+`\string#1{...}' is old Plain-TeX syntax whose use is
+ill-advised in LaTeX.%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\renewenvironment{pmatrix}{%
+ \left(%
+ \matrix@check\pmatrix\env@matrix
+}{
+ \endmatrix\right)%
+}
+\newenvironment{bmatrix}{\left[\env@matrix}{\endmatrix\right]}
+\newenvironment{Bmatrix}{%
+ \left\lbrace\env@matrix
+}{%
+ \endmatrix\right\rbrace
+}
+\newenvironment{vmatrix}{\left\lvert\env@matrix}{\endmatrix\right\rvert}
+\newenvironment{Vmatrix}{\left\lVert\env@matrix}{\endmatrix\right\rVert}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\hdots\@ldots
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newcommand{\hdotsfor}[1]{%
+ \ifx[#1\@xp\shdots@for\else\hdots@for\@ne{#1}\fi}
+\newmuskip\dotsspace@
+\def\shdots@for#1]{\hdots@for{#1}}
+\def\hdots@for#1#2{\multicolumn{#2}c%
+ {\m@th\dotsspace@1.5mu\mkern-#1\dotsspace@
+ \xleaders\hbox{$\m@th\mkern#1\dotsspace@.\mkern#1\dotsspace@$}%
+ \hfill
+ \mkern-#1\dotsspace@}%
+ }
+% \end{macrocode}
+%
+% \begin{environment}{cases}
+% The easiest way to produce the \env{cases} environment is to base
+% it on the \env{array} environment. We must use
+% \cn{renewenvironment} to override the definition of \cn{cases} that
+% \latex/ (unwisely) leaves in place from \fn{plain.tex}.
+% \begin{macrocode}
+\renewenvironment{cases}{%
+ \matrix@check\cases\env@cases
+}{%
+ \endarray\right.%
+}
+\def\env@cases{%
+ \let\@ifnextchar\new@ifnextchar
+ \left\lbrace
+ \def\arraystretch{1.2}%
+ \array{@{}l@{\quad}l@{}}%
+}
+% \end{macrocode}
+% \end{environment}
+%
+%
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \section{Equation sub-numbering}
+%
+% \begin{macrocode}
+\newcounter{parentequation}% Counter for ``parent equation''.
+% \end{macrocode}
+%
+% We can't assume \cs{ignorespacesafterend} is defined since it was
+% not there in the earliest releases of \latex/ 2e. And we need to
+% include the \cs{global} for the same reason.
+% \begin{macrocode}
+\@ifundefined{ignorespacesafterend}{%
+ \def\ignorespacesafterend{\global\@ignoretrue}%
+}{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newenvironment{subequations}{%
+% \end{macrocode}
+% Before sending down the `equation' counter to the subordinate
+% level, add 1 using standard \cn{refstepcounter}.
+% \begin{macrocode}
+ \refstepcounter{equation}%
+% \end{macrocode}
+% Define \cn{theparentequation} equivalent to current
+% \cn{theequation}. \cn{edef} is necessary to expand the current
+% value of the equation counter. This might in rare cases cause
+% something to blow up, in which case the user needs to add
+% \cn{protect}.
+% \begin{macrocode}
+ \protected@edef\theparentequation{\theequation}%
+ \setcounter{parentequation}{\value{equation}}%
+% \end{macrocode}
+% And set the equation counter to 0, so that the normal incrementing
+% processes in the various equation environments will produce the
+% desired results.
+% \begin{macrocode}
+ \setcounter{equation}{0}%
+ \def\theequation{\theparentequation\alph{equation}}%
+ \ignorespaces
+}{%
+ \setcounter{equation}{\value{parentequation}}%
+ \ignorespacesafterend
+}
+% \end{macrocode}
+%
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \section{Equation numbering}
+%
+% In the multiline equation environments provided here, the task
+% of equation numbering is linked to the task of line breaking
+% in the sense that it is the \cn{\\} command that marks where an
+% equation number for the current line will be processed and added to
+% the page.
+%
+% Provide a convenient way to specify that equations should be
+% numbered within sections.
+% \begin{macrocode}
+\newcommand{\numberwithin}[3][\arabic]{%
+ \@ifundefined{c@#2}{\@nocounterr{#2}}{%
+ \@ifundefined{c@#3}{\@nocnterr{#3}}{%
+ \@addtoreset{#2}{#3}%
+ \@xp\xdef\csname the#2\endcsname{%
+ \@xp\@nx\csname the#3\endcsname .\@nx#1{#2}}}}%
+}
+% \end{macrocode}
+%
+% To make references to equation numbers easier, we provide
+% \cn{eqref}. We almost don't need \cn{textup}, except that
+% \cs{tagform@} doesn't supply the italic correction.
+% \begin{macrocode}
+\newcommand{\eqref}[1]{\textup{\tagform@{\ref{#1}}}}
+% \end{macrocode}
+%
+% \subsection{Preliminary macros}
+%
+% The following macros implement the \latex/ syntax for the
+% \cn{\\} command, i.e. the possibility to add an asterisk to
+% inhibit a page break, or an optional argument to denote additional
+% vertical space. They are modelled more or less after the
+% corresponding macros for \latex/'s \env{eqnarray} and \env{array}
+% environments.
+%
+% [We can perhaps use the eqnarray mechanism if we change it so that
+% it also uses \cs{openup}.]
+%
+% \begin{macro}{\dspbrk@lvl}
+% We begin by defining the \cs{dspbrk@lvl} counter. This counter
+% records the desirability of a break after the current row, as a
+% number between $0$ and $4$. Its default value is $-1$ meaning that
+% no explicit \cn{displaybreak} command was given, and the default
+% \cs{interdisplaylinepenalty} is to be used.
+% \begin{macrocode}
+\newcount\dspbrk@lvl
+\dspbrk@lvl=-1
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\interdisplaylinepenalty}
+% We set the \cs{interdisplaylinepenalty} to $10000$.
+% \begin{macrocode}
+\interdisplaylinepenalty\@M
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\allowdisplaybreaks}
+% The \cn{allowdisplaybreaks} command. Since this is intended for use
+% outside displayed formulas (typically in the preamble), it does not
+% need to use \cs{new@ifnextchar}.
+% \begin{macrocode}
+\newcommand{\allowdisplaybreaks}[1][4]{%
+ \interdisplaylinepenalty\getdsp@pen{#1}\relax
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\getdsp@pen}
+% Modelled after \latex/'s \cs{@getpen}. We use higher numbers
+% than would normally be provided by \cs{@lowpenalty},
+% \cs{@medpenalty}, and \cs{@highpenalty}, since display
+% breaks are almost always less desirable.
+% \begin{macrocode}
+\def\getdsp@pen#1{%
+ \ifcase #1\@M \or 9999 \or 6999 \or 2999 \or \z@\fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\displaybreak}
+% \begin{macro}{\dspbrk@}
+% \begin{macro}{\dspbrk@context}
+% \begin{macro}{\nogood@displaybreak}
+% For breaks in a certain row of a alignment.
+% \begin{macrocode}
+\newcommand{\displaybreak}{\new@ifnextchar[\dspbrk@{\dspbrk@[4]}}
+\chardef\dspbrk@context=\sixt@@n
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\dspbrk@[#1]{%
+ \ifmeasuring@
+ \else
+ \ifcase\dspbrk@context % case 0 --- OK
+ \global\dspbrk@lvl #1\relax
+ \or % case 1 --- inside a box
+ \nogood@displaybreak
+ \else % other cases --- outside of a display
+ \@amsmath@err{\Invalid@@\displaybreak}\@eha
+ \fi
+ \fi
+}
+% \end{macrocode}
+%
+% This is the value of \cn{displaybreak} when it occurs inside some
+% structure where it will not work.
+% \begin{macrocode}
+\def\nogood@displaybreak{%
+ \@amsmath@err{\protect
+\displaybreak\space cannot be applied here}%
+{One of the enclosing environments creates an
+ unbreakable box\MessageBreak
+(e.g., split, aligned, gathered, ...).}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\math@cr}
+% The macro \cs{math@cr} ends a row inside one of the equation
+% environments, i.e., this is the internal name of the \cn{\\}
+% commands in these environments. As usual for this kind of macro
+% inside of alignments we insert a special brace into \tex/'s input
+% stream. The initial \cs{relax} is needed to trigger entry into the
+% \textit{u} template of the current column if the author ended the
+% current row with an empty column (i.e., the mathcr was immediately
+% preceded by an ampersand).
+% \begin{macrocode}
+\def\math@cr{\relax\iffalse{\fi\ifnum0=`}\fi
+% \end{macrocode}
+% The first step is now to check whether an asterisk follows.
+% \cs{@eqpen} is used to hold the penalty value to be put on
+% the vertical list.
+% Then we call up \cs{math@cr@} which performs the next step.
+% If an asterisk is read page breaking is inhibited.
+% \begin{macrocode}
+ \@ifstar{\global\@eqpen\@M\math@cr@}%
+% \end{macrocode}
+% Otherwise we have to check the \cs{dspbrk@lvl} value.
+% \begin{macrocode}
+ {\global\@eqpen
+ \ifnum\dspbrk@lvl <\z@ \interdisplaylinepenalty
+ \else -\@getpen\dspbrk@lvl \fi
+ \math@cr@}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\math@cr@}
+% The purpose of \cs{math@cr@} is to check whether an optional
+% argument follows. If not it provides \cs{z@} as default
+% value.
+% \begin{macrocode}
+\def\math@cr@{\new@ifnextchar[\math@cr@@{\math@cr@@[\z@]}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\math@cr@@}
+% \cs{math@cr@@} closes the special brace opened in
+% \cs{math@cr}, and calls \cs{math@cr@@@} which is supposed
+% the `real' row ending command. The meaning of this macro depends
+% on the environment in which it is used.
+% \begin{macrocode}
+\def\math@cr@@[#1]{\ifnum0=`{\fi \iffalse}\fi\math@cr@@@
+% \end{macrocode}
+% Finally we put the additional space onto the vertical list.
+% \begin{macrocode}
+ \noalign{\vskip#1\relax}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Let@}
+% \cs{Let@} is called by all environments where \cn{\\}
+% ends a row of an alignment.
+% \begin{macrocode}
+\def\Let@{\let\\\math@cr}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\restore@math@cr}
+% We mentioned already that the exact meaning of \cs{math@cr@@@}
+% depends on the current environment. Since it is often a simple
+% \cs{cr} we provide \cs{restore@math@cr} to reset it.
+% \begin{macrocode}
+\def\restore@math@cr{\def\math@cr@@@{\cr}}
+% \end{macrocode}
+% This is also the default case.
+% \begin{macrocode}
+\restore@math@cr
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\intertext}
+% \begin{macro}{\intertext@}
+% The \cn{intertext} command is used for inserting text between the
+% rows of an alignment. It might better be done as an environment,
+% but the \cs{begingroup} from \cn{begin} would cause the
+% \cs{noalign} to fail.
+% \begin{macrocode}
+\newcommand{\intertext}{\@amsmath@err{\Invalid@@\intertext}\@eha}
+% \end{macrocode}
+% \cs{intertext@} is called by all environments that allow the use of
+% the \cn{intertext} command.
+% \begin{macrocode}
+\def\intertext@{%
+ \def\intertext##1{%
+% \end{macrocode}
+% If current mode is not vmode, the most likely reason is that the
+% writer forgot the \cn{\\} that is supposed to precede
+% \cn{intertext}. All right, then, let's try adding it our ownself.
+% But, to be slightly careful: \cn{\\} does a futurelet, and it's
+% slightly dangerous to allow a letted token to barge around loose in
+% our internal code when it has been let to a conditional token
+% like \cs{fi}. So let's interpose something in front of the \cs{fi}
+% for the futurelet to take instead. (And careful again: it has to be
+% something evanescent, not (e.g.) \cs{relax} which would cause the
+% next halign cell to fire up and keep \cs{noalign} from working.)
+% \begin{macrocode}
+ \ifvmode\else\\\@empty\fi
+ \noalign{%
+ \penalty\postdisplaypenalty\vskip\belowdisplayskip
+ \vbox{\normalbaselines
+% \end{macrocode}
+% We need to do something extra if the outside environment is a list
+% environment. I don't see offhand an elegant way to test ``are we
+% inside any list environment'' that is both easy and reliable (for
+% example, checking for zero \cs{@totalleftmargin} wouldn't catch the
+% case where \cs{@totalleftmargin} is zero but \cs{linewidth} is less
+% than \cs{columnwidth}), so it seems to me checking \cs{linewidth}
+% is the best practical solution.
+% \begin{macrocode}
+ \ifdim\linewidth=\columnwidth
+ \else \parshape\@ne \@totalleftmargin \linewidth
+ \fi
+ \noindent##1\par}%
+ \penalty\predisplaypenalty\vskip\abovedisplayskip%
+ }%
+}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
+% \subsection{Implementing tags and labels}
+%
+% In this section we describe some of the macros needed to make the
+% \cn{tag} command work in various places. We start by defining a
+% help text to be used when a \cn{tag} command is used somewhere
+% it should not appear.
+%
+% \begin{macro}{\tag@help}
+% This is the default error help text provided when \cn{tag}
+% generates an error message.
+% Note that \cs{newhelp} generates a control sequence name
+% from the string given as its argument so that a leading
+% backslash is provided automatically.
+% \begin{macrocode}
+\newhelp\tag@help
+ {tag cannot be used at this point.\space
+ If you don't understand why^^Jyou should consult
+ the documentation.^^JBut don't worry: just continue, and I'll
+ forget what happened.}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\gobble@tag}
+% This macro is to be used when \cn{tag} should silently
+% skip its argument.
+% It is made to handle the \qc{\*}-form of \cn{tag} as well.
+% \begin{macrocode}
+\def\gobble@tag{\@ifstar\@gobble\@gobble}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\invalid@tag}
+% \cs{invalid@tag} is a macro that should be used whenever
+% \cn{tag} appears in an illegal place.
+% It sets up \cs{tag@help} (as defined above) as help message,
+% prints its argument as error message, and skips \cn{tag}'s
+% argument.
+% \begin{macrocode}
+\def\invalid@tag#1{\@amsmath@err{#1}{\the\tag@help}\gobble@tag}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\dft@tag}
+% \begin{macro}{\default@tag}
+% \cs{dft@tag} provides a convenient way to disallow the
+% use of \cn{tag} at certain points.
+% One simply has to write
+% \begin{verbatim}
+%\let\tag\dft@tag
+% \end{verbatim}
+% and the \cn{tag} command will produce an error message,
+% with a suitable error help text, and discard its argument.
+% \begin{macrocode}
+\def\dft@tag{\invalid@tag{\string\tag\space not allowed here}}
+% \end{macrocode}
+% Since this is used several times we provide an abbreviation for
+% it.
+% \begin{macrocode}
+\def\default@tag{\let\tag\dft@tag}
+% \end{macrocode}
+% Since this is also the default, i.e.\ the \cn{tag} command
+% should not be used except in special places, we issue a
+% \cs{default@tag} command.
+% \begin{macrocode}
+\default@tag
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% Now that we have taken care of the case that \cn{tag} is not
+% allowed we will provide some macros to process tags appropriately.
+% As the user documentation states, a \cn{tag} command (without
+% the asterisk typesets its argument according to the document
+% styles' conventions, whereas a \cn{tag*} command typesets its
+% argument exactly as given. We define therefore the following
+% interface:
+%
+% \begin{macro}{\maketag@@}
+% \begin{macro}{\maketag@@@}
+% \begin{macro}{\tagform@}
+% \cn{tag} is supposed to call \cs{maketag@@} which checks
+% whether an asterisk follows. If this is the case it calls up
+% \cs{maketag@@@} which sets its argument `as is'. Otherwise
+% \cs{tagform@} is called to do the job. (This macro is to be
+% defined appropriately by the document style.)
+% \begin{macrocode}
+\def\maketag@@{\@ifstar\maketag@@@\tagform@}
+% \end{macrocode}
+% We define \cs{maketag@@@} to use the normal font of the document
+% text (since this is the usual practice for numbering of document
+% elements) and to put a box around the tag. Furthermore we use
+% \cs{m@th} for exceptional cases where the tag involves a
+% superscript or some such math. (Probably from an explicit use of
+% \cs{tag*} rather than from the automatic numbering.)
+% \begin{macrocode}
+\def\maketag@@@#1{\hbox{\m@th\normalfont#1}}
+% \end{macrocode}
+% We use the following default definition for \cs{tagform@}
+% that puts only parentheses around the tag.
+% \begin{macrocode}
+\def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% We need to insinuate \cs{tagform@} into \cs{@eqnnum} in case
+% \env{eqnarray} is used (probably in a document that was originally
+% written without use of the \pkg{amsmath} package).
+% \begin{macrocode}
+\iftagsleft@
+ \def\@eqnnum{\hbox to1sp{}\rlap{\normalfont\normalcolor
+ \hskip -\displaywidth\tagform@\theequation}}
+\else
+ \def\@eqnnum{{\normalfont\normalcolor \tagform@\theequation}}
+\fi
+% \end{macrocode}
+%
+% \begin{macro}{\thetag}
+% Sometimes one needs to set a literal tag according to the rules of
+% the document style. To achieve this we provide the \cn{thetag}
+% command. It typesets its argument by calling \cs{tagform@} on
+% it.
+% \begin{macrocode}
+\newcommand{\thetag}{\leavevmode\tagform@}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\df@tag}
+% \begin{macro}{\make@df@tag}
+% \begin{macro}{\make@df@tag@@}
+% \begin{macro}{\make@df@tag@@@}
+% Sometimes it is necessary for a \cn{tag} command to store a tag
+% in a safe place and to process it later, e.g., for a tag in a row
+% of an alignment where the tag can only be typeset when the
+% \cn{\\} at the end of the row was seen. Such a tag is stored in
+% the macro \cs{df@tag} (for `deferred tag'). For this purpose we
+% provide the \cs{make@df@tag} macro. It is built very similar to
+% the \cs{maketag@@} macro above.
+% \begin{macrocode}
+\let\df@tag\@empty
+\def\make@df@tag{\@ifstar\make@df@tag@@\make@df@tag@@@}
+% \end{macrocode}
+% \cs{make@df@tag} sets \cs{@currentlabel} and defines
+% \cs{df@tag} appropriately.
+%
+% To simplify the task of tracking \cs{tag} and \cs{label}
+% commands inside math display environments, we defer \cs{label}
+% commands until the tag is typeset, similar to the way that
+% \cs{tag}s themselves are deferred. This allows arbitrary
+% placement of \cs{label} and \cs{tag} commands and also means we
+% only increment the \cs{equation} counter when we really need to,
+% thus avoiding the \cs{setb@ck} nonsense that used to be required.
+%
+% \begin{macrocode}
+\def\make@df@tag@@#1{%
+ \gdef\df@tag{\maketag@@@{#1}\def\@currentlabel{#1}}}
+% \end{macrocode}
+% Autogenerated number:
+% \begin{macrocode}
+\def\make@df@tag@@@#1{\gdef\df@tag{\tagform@{#1}%
+ \toks@\@xp{\p@equation{#1}}\edef\@currentlabel{\the\toks@}}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\ltx@label}
+% \begin{macro}{\label@in@display}
+% \begin{macro}{\df@label}
+% Next, we store the default definition of \cs{label} in
+% \cs{ltx@label} and then define a new version of \cs{label} for use
+% in math display environments. \cs{label@in@display} merely issues a
+% warning message if there is already a pending label (which will be
+% discarded) and then stores the label in \cs{df@label}.
+% \begin{macrocode}
+\let\ltx@label\label
+%
+\def\label@in@display{%
+ \ifx\df@label\@empty\else
+ \@amsmath@err{Multiple \string\label's:
+ label '\df@label' will be lost}\@eha
+ \fi
+ \gdef\df@label
+}
+% \end{macrocode}
+% In case there is an enumerate inside a minipage inside an equation,
+% we need to reset \cn{label} to its normal value:
+% \begin{macrocode}
+\toks@\@xp{\@arrayparboxrestore \let\label\ltx@label}%
+\edef\@arrayboxrestore{\the\toks@}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\df@label\@empty
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\make@display@tag}
+% Now we define a macro to process \cs{tag} and \cs{label} commands
+% in various display environments. If the |@eqnsw| switch is set,
+% then we should supply an equation number; otherwise, if the
+% |@tag| switch is set, we should use the tag stored in
+% \cs{df@tag}. Finally, we process any pending \cs{label}s.
+%
+% TODO: Arguably, \cs{make@display@tag} should issue a warning
+% message if there is a \cs{label} but neither a tag nor an
+% equation number. Also, it would probably be worthwhile to
+% explore whether \cs{iftag@} could be done away with and replaced
+% by checks to see if \cs{df@tag} is empty or not.
+% \begin{macrocode}
+\def\make@display@tag{%
+ \if@eqnsw \incr@eqnum \print@eqnum
+ \else \iftag@ \df@tag \global\let\df@tag\@empty \fi
+ \fi
+% \end{macrocode}
+% Need to check the \cs{ifmeasuring@} flag otherwise the \cs{write}
+% node from \cn{label} might be discarded in a temp box and clearing
+% \cs{df@label} will keep it from being reiterated on the real
+% typesetting pass.
+% \begin{macrocode}
+ \ifmeasuring@
+ \else
+ \ifx\df@label\@empty
+ \else
+ \@xp\ltx@label\@xp{\df@label}%
+ \global\let\df@label\@empty
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Now we define the special versions of \cn{tag} used within the
+% \env{align} environments.
+%
+% \begin{macro}{\tag@in@align}
+% The \cn{tag} command may only appear once in a row of
+% an alignment. Therefore we first check the switch |tag@|
+% that is set to false at the begin of every row.
+% If this switch is true a \cn{tag} was already given in this
+% row and we define \cs{next@} to expand to a call to
+% \cs{invalid@tag}.
+% \begin{macrocode}
+\def\tag@in@align{%
+ \relax
+ \iftag@
+ \DN@{\invalid@tag{Multiple \string\tag}}%
+ \else
+% \end{macrocode}
+% Otherwise we set the |tag@| switch. But there is more to
+% be done: we must also prevent the automatic generation of a
+% tag. Therefore we also reset the |@eqnsw|.
+% \begin{macrocode}
+ \global\tag@true
+% \end{macrocode}
+% Changed to \cs{nonumber}, since that seems to be all that's
+% required.---dmj, 1994/12/21
+% \begin{macrocode}
+ \nonumber
+% \end{macrocode}
+% Within a row of an \env{align} environment the \cn{tag}
+% command must not typeset the tag immediately since its
+% position can be determined only later.
+% Therefore we use the \cs{make@df@tag} macro defined
+% earlier.
+% Finally we call \cs{next@} to process the argument
+% that follows.
+% \begin{macrocode}
+ \let\next@\make@df@tag
+ \fi
+ \next@
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\raisetag}
+% Usage: \cn{raisetag} \meta{dimen}
+%
+% This will modify the vertical placement of the tag of the current
+% equation by \meta{dimen}. Note that according to the current uses
+% of \cs{raise@tag} in e.g., \cs{place@tag@gather}, no adjustment
+% occurs if the tag falls in its normal position; i.e., \cn{raisetag}
+% has no effect unless the tag has already been shifted off-line.
+%
+% \begin{macrocode}
+\newcommand{\raisetag}[1]{\skip@#1\relax
+ \xdef\raise@tag{\vskip\iftagsleft@\else-\fi\the\skip@\relax}%
+}
+% \end{macrocode}
+% \cn{raise@tag} will be reemptied at the beginning of each equation,
+% which might occur at a |\begin{xxx}| or \cn{\\}.
+% \begin{macrocode}
+\let\raise@tag\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\notag}
+% For consistency we provide \cn{notag}, equivalent to
+% \cn{nonumber}. The alternative would have been to rename
+% \cn{tag} as \cn{number} to go along with \cn{nonumber},
+% but of course \cs{number} is a \tex/ primitive that should not
+% be redefined.
+% \begin{macrocode}
+\newcommand{\notag}{\nonumber}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\nonumber}
+% Need to add some additional code to \cn{nonumber} to deal with some
+% complications related to nested environments.
+% \begin{macrocode}
+\renewcommand{\nonumber}{%
+ \if@eqnsw
+ \ifx\incr@eqnum\@empty \addtocounter{equation}\m@ne \fi
+ \fi
+ \let\print@eqnum\@empty \let\incr@eqnum\@empty
+ \global\@eqnswfalse
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\print@eqnum{\tagform@\theequation}
+\def\incr@eqnum{\refstepcounter{equation}\let\incr@eqnum\@empty}
+% \end{macrocode}
+% \end{macro}
+%
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \section{Multiline equation environments}
+%
+% \subsection{Remarks}
+%
+% In late 1994 David M. Jones did a thorough overhaul of these
+% environments so that the number placement and a few other aspects
+% are substantially improved over the original versions that were
+% ported essentially unchanged from \fn{amstex.tex} in 1989. Most of
+% the commentary in this section is DMJ's, and comments of any
+% significance that I added are marked by my initials and date
+% [mjd, 1995/01/11].
+%
+% \subsection{Preliminaries}
+%
+% \begin{macro}{\ifinalign@}
+% \begin{macro}{\ifingather@}
+% We define two switches that are set to true in certain
+% alignments: |inalign@| and |ingather@| inside of
+% the \env{align} and \env{gather} environments.
+% These switches are needed to control certain actions that
+% depend on the surrounding conditions, more specifically:
+% on the setting already done by the surrounding environments.
+% \begin{macrocode}
+\newif\ifinalign@
+\newif\ifingather@
+% \end{macrocode}
+% \begin{histnote}
+% Removed the \cs{ifinany@} test [mjd,1999/06/28] since it was mainly
+% used for the purpose now handled by \cs{spread@equation}.
+% \changes{v1.2g}{1999/06/28}{Removed ifinany@}
+% \end{histnote}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\@arrayparboxrestore}
+% Here we must reset a few additional parameters.
+% \begin{macrocode}
+\@xp\def\@xp\@arrayparboxrestore\@xp{\@arrayparboxrestore
+ \ingather@false\inalign@false \default@tag
+ \let\spread@equation\@spread@equation
+ \let\reset@equation\@empty
+ \def\print@eqnum{\tagform@\theequation}%
+ \def\incr@eqnum{\refstepcounter{equation}\let\incr@eqnum\@empty}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\iftag@}
+% The switch |tag@| is set to false at the beginning of every
+% row and set to true by a \cn{tag} command.
+% This allows us to check whether there is more than one tag on
+% a row.
+% \begin{macrocode}
+\newif\iftag@
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ifst@rred}
+% The switch |st@rred| is set to true by all starred
+% environments
+% and set to false by the unstarred versions.
+% \begin{macrocode}
+\newif\ifst@rred
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ifmeasuring@}
+% All display environments get typeset twice---once during a
+% ``measuring'' phase and then again during a ``production'' phase;
+% \cs{ifmeasuring@} will be used to determine which case we're in,
+% so we can take appropriate action.
+%
+% \begin{macrocode}
+\newif\ifmeasuring@
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ifshifttag@}
+% \cs{ifshifttag@} is used by \env{gather} to communicate between
+% \cs{calc@shift@gather} and \cs{place@tag@gather} whether an
+% equation tag should be shifted to a separate line. It's also
+% used by \env{multline}.
+% \begin{macrocode}
+\newif\ifshifttag@
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\row@}
+% \begin{macrocode}
+\newcount\row@
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\column@}
+% The counter \cs{column@} is used by the alignment macros to
+% keep track of the current column.
+%
+% \begin{macrocode}
+\newcount\column@
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\column@plus}
+% \cs{\column@plus} is a useful abbreviation.
+% \begin{macrocode}
+\def\column@plus{%
+ \global\advance\column@\@ne
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\maxfields@}
+% \begin{macrocode}
+\newcount\maxfields@
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\add@amp}
+% \begin{macro}{\add@amps}
+% \begin{macrocode}
+\def\add@amp#1{\if m#1&\@xp\add@amp\fi}
+\def\add@amps#1{%
+ \begingroup
+ \count@#1\advance\count@-\column@
+ \edef\@tempa{\endgroup
+ \@xp\add@amp\romannumeral\number\count@ 000q}%
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\andhelp@}
+% The help text stored in \cs{andhelp@} is used for errors
+% generated by too many \qc{\&} characters in a row.
+% \begin{macrocode}
+\newhelp\andhelp@
+{An extra & here is so disastrous that you should probably exit^^J
+and fix things up.}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\eqnshift@}
+% \cs{eqnshift@} is used by \env{align} and \env{gather} as the
+% indentation of the lines of the environment from the left margin.
+% \begin{macrocode}
+\newdimen\eqnshift@
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\alignsep@}
+% \begin{macrocode}
+\newdimen\alignsep@
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\tagshift@}
+% \begin{macrocode}
+\newdimen\tagshift@
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\mintagsep}
+% \cs{mintagsep} is the minimum allowable separation between an
+% equation and its tag. We set it to half a quad in
+% \cs{textfont}2, which is \tex/'s built-in value.
+% \begin{macrocode}
+\newcommand{\mintagsep}{.5\fontdimen6\textfont\tw@}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\minalignsep}
+% This should probably be a skip register [mjd,1999/06/18]
+% \begin{macrocode}
+\newcommand{\minalignsep}{10pt}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\tagwidth@}
+% \begin{macrocode}
+\newdimen\tagwidth@
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\totwidth@}
+% \begin{macrocode}
+\newdimen\totwidth@
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\lineht@}
+% The dimen register \cs{lineht@} is used to keep track of the
+% height (or depth, if tags are on the right) of a row in an
+% alignment.
+% \begin{macrocode}
+\newdimen\lineht@
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\tag@width}
+% \begin{macro}{\savetaglength@}
+% \begin{macro}{\shift@tag}
+% \begin{macro}{\tag@shifts}
+% \begin{macrocode}
+\def\tag@width#1{%
+ \ifcase\@xp#1\tag@lengths\fi
+}
+
+\def\savetaglength@{%
+ \begingroup
+ \let\or\relax
+ \xdef\tag@lengths{\tag@lengths\or \the\wdz@}%
+ \endgroup
+}
+
+\def\shift@tag#1{%
+ \ifcase\@xp#1\tag@shifts\fi\relax
+}
+
+\let\tag@shifts\@empty
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\saveshift@}
+% \begin{macrocode}
+\def\saveshift@#1{%
+ \begingroup
+ \let\or\relax
+ \xdef\tag@shifts{\or#1\tag@shifts}%
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\spread@equation}
+% This does the line-spacing adjustment that is normally wanted for
+% displayed equations. We also call \cs{reset@strutbox@} here because
+% otherwise a preceding font size change might leave \cs{strutbox@}
+% with wrong contents. This is a less-than-ideal solution but
+% probably good enough for now, until the situation can be
+% overhauled.
+% \begin{macrocode}
+\def\spread@equation{\reset@strutbox@
+ \openup\jot \let\spread@equation\@empty}
+\let\@spread@equation\spread@equation
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\displ@y}
+% \begin{macro}{\displ@y@}
+% \begin{macro}{\@display@init}
+% \cs{displ@y} is from \fn{plain.tex}, with
+% \cs{interdisplaylinepenalty} changed to \cs{@eqpen}. Also we
+% transplanted most of its internal organs to \cs{@display@init} to
+% support \cs{displ@y@} and other possibilities. Don't try to make
+% sense of these naming conventions! They are a narrowly calculated
+% mishmash of Knuth/Spivak/Lamport/Mittelbach precedents. The reason
+% for not cleaning them up and forcing all names to a consistent
+% scheme is that then in principle we'd have to do it everywhere else
+% too. And we programmers are paranoid about the side effects of name
+% changes.
+% \begin{macrocode}
+\def\displ@y{\@display@init{}}
+\def\@display@init#1{%
+ \global\dt@ptrue \spread@equation
+ \everycr{%
+ \noalign{%
+ #1%
+ \ifdt@p
+ \global\dt@pfalse
+ \vskip-\lineskiplimit
+ \vskip\normallineskiplimit
+ \else
+ \penalty\@eqpen \global\dspbrk@lvl\m@ne
+ \fi
+ }%
+ }%
+}
+% \end{macrocode}
+% \cs{displ@y@} is nearly the same; it additionally sets the |tag@|
+% switch and the \cs{column@} and \cs{dspbrk@lvl} counters to their
+% default values. The argument is normally a bit of code to empty out
+% \cs{raise@tag}, but in \env{multline} we don't want that to happen
+% in \cs{everycr}.
+% \begin{macrocode}
+\def\displ@y@{\@display@init{%
+ \global\column@\z@ \global\dspbrk@lvl\m@ne
+ \global\tag@false \global\let\raise@tag\@empty
+}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\black@}
+% This macro is made to produce an overfull box message and
+% possibly (depending on the value of \cs{overfullrule})
+% a rule in the margin if the total width of an alignment
+% is larger than the value of \cs{displaywidth}.
+% \begin{macrocode}
+\def\black@#1{%
+ \noalign{%
+ \ifdim#1>\displaywidth
+ \dimen@\prevdepth
+ \nointerlineskip
+ \vskip-\ht\strutbox@
+ \vskip-\dp\strutbox@
+ \vbox{\noindent\hbox to#1{\strut@\hfill}}%
+ \prevdepth\dimen@
+ \fi
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\savecounters@}
+% \begin{macro}{\restorecounters@}
+% These are used during the measuring phase of the various display
+% math environments to save and restore the values of all \latex/
+% counters. We make these local to a group, so nested environments
+% works.
+%
+% Changed \cn{stepcounter} to |\csname c@...\endcsname| to avoid
+% overhead of ifundefined test [mjd, 1995/01/20].
+% \begin{macrocode}
+\def\savecounters@{%
+ \begingroup
+ \def\@elt##1{%
+ \global\csname c@##1\endcsname\the\csname c@##1\endcsname}%
+ \xdef\@gtempa{%
+ \cl@@ckpt
+ \let\@nx\restorecounters@\@nx\@empty
+ }%
+ \endgroup
+ \let\restorecounters@\@gtempa
+}
+%
+\let\restorecounters@\@empty
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\savealignstate@}
+% \begin{macro}{\restorealignstate@}
+% These are used to save the values of various parameters that are
+% shared by \env{align} and \env{gather} when the former is used
+% inside the latter.
+% \begin{macrocode}
+\def\savealignstate@{%
+ \begingroup
+ \let\or\relax
+ \xdef\@gtempa{%
+ \global\totwidth@\the\totwidth@
+ \global\row@\the\row@
+ \gdef\@nx\tag@lengths{\tag@lengths}%
+ \let\@nx\restorealignstate@\@nx\@empty
+ }%
+ \endgroup
+ \let\restorealignstate@\@gtempa
+}
+
+\let\restorealignstate@\@empty
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\savecolumn@}
+% \begin{macro}{\restorecolumn@}
+%
+% \begin{macrocode}
+\def\savecolumn@{%
+ \edef\restorecolumn@{%
+ \global\column@\number\column@
+ \let\@nx\restorecolumn@\@nx\@empty
+ }%
+}
+\let\restorecolumn@\@empty
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Scanning the environment's body}
+%
+% Several of the math alignment macros must scan their body twice:
+% once to determine how wide the columns are and then to actually
+% typeset them. This means that we must collect all text in this body
+% before calling the environment macros.
+%
+% \begin{macro}{\@envbody}
+% We start by defining a token register to contain the body.
+% \begin{macrocode}
+\newtoks\@envbody
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\addto@envbody}
+% Then we define a macro to add something (i.e.\ its argument) to the
+% token register \cs{@envbody}.
+% \begin{macrocode}
+\def\addto@envbody#1{\global\@envbody\@xp{\the\@envbody#1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\collect@body}
+% The macro \cs{collect@body} starts the scan for the |\end{...}|
+% command of the current environment. It takes a macro name as
+% argument. This macro is supposed to take the whole body of the
+% environment as its argument. For example, |\begin{align}| would
+% call |\collect@body\@align| if |@align#1{...}| is the macro that
+% sets the alignment with body \arg{1}.
+%
+% \begin{macrocode}
+\def\collect@body#1{%
+ \@envbody{\@xp#1\@xp{\the\@envbody}}%
+ \edef\process@envbody{\the\@envbody\@nx\end{\@currenvir}}%
+ \@envbody\@emptytoks \def\begin@stack{b}%
+% \end{macrocode}
+%
+% If we simply called \cs{collect@@body} directly,
+% the error message for a \cn{par} token (usually from a blank line)
+% would be
+% \begin{verbatim}
+% ! Paragraph ended before \collect@@body was complete.
+% \end{verbatim}
+% But we use a little finesse to get a more intelligible error
+% message:
+% \begin{verbatim}
+% ! Paragraph ended before \multline* was complete.
+% \end{verbatim}
+% In order to avoid using up csnames unnecessarily we use the actual
+% environment name as the name of the temporary function that is
+% \cs{let} to \cs{collect@@body}; but then in order to preserve the
+% theoretical possibility of nesting for environments that use
+% \cs{collect@body} (not currently required by any \pkg{amsmath}
+% environment [mjd,1999/06/23]), we do the \cs{let} inside a group.
+% \begin{macrocode}
+ \begingroup
+ \@xp\let\csname\@currenvir\endcsname\collect@@body
+% \end{macrocode}
+% This small twist eliminates the need for \cs{expandafter}'s in
+% \cs{collect@@body}.
+% \begin{macrocode}
+ \edef\process@envbody{\@xp\@nx\csname\@currenvir\endcsname}%
+ \process@envbody
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\push@begins}
+% When adding a piece of the current environment's contents to
+% \cs{@envbody}, we scan it to check for additional \cn{begin}
+% tokens, and add a `b' to the stack for any that we find.
+% \begin{macrocode}
+\def\push@begins#1\begin#2{%
+ \ifx\end#2\else b\@xp\push@begins\fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\collect@@body}
+% \cs{collect@@body} takes two arguments: the first will consist of
+% all text up to the next \cn{end} command, the second will be the
+% \cn{end} command's argument. If there are any extra \cn{begin}
+% commands in the body text, a marker is pushed onto a stack by the
+% \cs{push@begins} function. Empty state for this stack means that we
+% have reached the \cn{end} that matches our original \cn{begin}.
+% Otherwise we need to include the \cn{end} and its argument in the
+% material that we are adding to our environment body accumulator.
+%
+% \begin{histnote}
+% In a former implementation, the error messages resulting from a
+% typo in the environment name were unsatisfactory, because it was
+% matching of the environment name that was used to determine the end
+% of our environment body, instead of counting begin-end pairs.
+% Thanks to Lars Hellstr\"{o}m for a suggestion that led to this
+% improvement. [mjd,1999/06/23]
+% \end{histnote}
+% \begin{macrocode}
+\def\collect@@body#1\end#2{%
+ \edef\begin@stack{\push@begins#1\begin\end \@xp\@gobble\begin@stack}%
+ \ifx\@empty\begin@stack
+ \endgroup
+ \@checkend{#2}%
+ \addto@envbody{#1}%
+ \else
+ \addto@envbody{#1\end{#2}}%
+ \fi
+ \process@envbody % A little tricky! Note the grouping
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsection{Simple aligning environments}
+%
+% \begin{macro}{\math@cr@@@aligned}
+% From tabskip we get an extra space of minalignsep after every
+% second column; but when this falls at the right edge of the whole
+% aligned structure, we need to cancel that space.
+% \begin{macrocode}
+\def\math@cr@@@aligned{%
+ \ifodd\column@ \let\next@\@empty
+ \else \def\next@{&\kern-\alignsep@}%
+ \fi
+ \next@ \cr
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\start@aligned}
+% The \env{aligned} and \env{alignedat} environments are identical
+% except that the latter takes a mandatory argument to specify the
+% number of align structures, while the former allows any number of
+% align structures automatically (the use of \env{alignedat} is
+% deprecated). So, they will be defined in terms of
+% \cs{start@aligned}, which will take two arguments. The first
+% argument specifies the placement of the environments; it is
+% either |c|, |t|, or |b|. The second is the number of align
+% structures; a value of~$-1$ means that an arbitrary number are
+% allowed.
+% \begin{macrocode}
+\newcommand{\start@aligned}[2]{%
+ \RIfM@\else
+ \nonmatherr@{\begin{\@currenvir}}%
+ \fi
+ \savecolumn@ % Assumption: called inside a group
+% \end{macrocode}
+% The \cs{null} here is to keep the \cs{,} glue from causing the
+% invocation of the clause in \tex/'s built-in tag placement
+% algorithm that can cause an equation to be shifted all the way over
+% to the margin.
+% \begin{macrocode}
+ \null\,%
+ \if #1t\vtop \else \if#1b \vbox \else \vcenter \fi \fi \bgroup
+ \maxfields@#2\relax
+ \ifnum\maxfields@>\m@ne
+ \multiply\maxfields@\tw@
+% \end{macrocode}
+% Introduced new \cs{math@cr@@@} so we can provide standard error
+% message for too many \qc{\&}'s in \env{alignedat}.
+% \begin{macrocode}
+ \let\math@cr@@@\math@cr@@@alignedat
+ \alignsep@\z@skip
+ \else
+ \let\math@cr@@@\math@cr@@@aligned
+ \alignsep@\minalignsep
+ \fi
+% \end{macrocode}
+% Reset the meaning of \cn{\\}.
+% \begin{macrocode}
+ \Let@ \chardef\dspbrk@context\@ne
+% \end{macrocode}
+% Restore the default definition of \cn{tag} (error message), in
+% case \env{aligned} is used inside, e.g., a \env{gather}
+% environment that accepts \cn{tag}.
+% \begin{macrocode}
+ \default@tag
+ \spread@equation % no-op if already called
+% \end{macrocode}
+% Finally we start the alignment itself. For \env{aligned} we add
+% \cs{minalignsep} after every second column to mimic the
+% behavior of \env{align}. For \env{alignedat} the user has to
+% specify interalign space explicitly.
+% \begin{macrocode}
+ \global\column@\z@
+ \ialign\bgroup
+ &\column@plus
+ \hfil
+ \strut@
+ $\m@th\displaystyle{##}$%
+ \tabskip\z@skip
+ &\column@plus
+ $\m@th\displaystyle{{}##}$%
+ \hfil
+ \tabskip\alignsep@
+ \crcr
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\math@cr@@@aligned}
+% \cs{math@cr@@@aligned} checks to make sure the user hasn't put in
+% too many \qc{\&}s in \env{alignedat}. Since \env{alignedat}
+% doesn't use \cs{displ@y@}, we also reset \cs{column@} here. Note
+% than in \env{aligned}, \cs{column@} will increase without bound,
+% since it never gets reset, but this is harmless.
+% \begin{macrocode}
+\def\math@cr@@@alignedat{%
+ \ifnum\column@>\maxfields@
+ \begingroup
+ \measuring@false
+ \@amsmath@err{Extra & on this line}%
+ {\the\andhelp@}% "An extra & here is disastrous"
+ \endgroup
+ \fi
+ \global\column@\z@
+ \cr
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\alignsafe@testopt}
+% Testing for an optional argument can be really, really tricky in
+% certain complicated contexts. This we discovered by getting some
+% bug reports for uses of \env{aligned}. So here is a safer
+% form of \latex/'s \cs{@testopt} function.
+% \begin{macrocode}
+\def\alignsafe@testopt#1#2{%
+ \relax\iffalse{\fi\ifnum`}=0\fi
+ \@ifnextchar[%
+ {\let\@let@token\relax \ifnum`{=\z@\fi\iffalse}\fi#1}%
+ {\let\@let@token\relax \ifnum`{=\z@\fi\iffalse}\fi#1[#2]}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{environment}{aligned}
+% The \env{aligned} environment takes an optional argument that
+% indicates its vertical position in relation to surrounding
+% material: |t|, |c|, or |b| for top, center, or bottom.
+% \begin{macrocode}
+\newenvironment{aligned}{%
+ \let\@testopt\alignsafe@testopt
+ \aligned@a
+}{%
+ \crcr\egroup
+ \restorecolumn@
+ \egroup
+}
+\newcommand{\aligned@a}[1][c]{\start@aligned{#1}\m@ne}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{environment}{alignedat}
+% To get a top or bottom positioned \env{alignedat} structure, you
+% would write something like
+% \begin{verbatim}
+% \begin{alignedat}[t]{3}
+% \end{verbatim}
+%
+% \begin{macrocode}
+\newenvironment{alignedat}{%
+ \let\@testopt\alignsafe@testopt
+ \alignedat@a
+}{%
+ \endaligned
+}
+\newcommand{\alignedat@a}[1][c]{\start@aligned{#1}}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{environment}{gathered}
+% The \env{gathered} environment is for several lines that are
+% centered independently.
+% \begin{macrocode}
+\newenvironment{gathered}[1][c]{%
+ \RIfM@\else
+ \nonmatherr@{\begin{gathered}}%
+ \fi
+ \null\,%
+ \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi \bgroup
+ \Let@ \chardef\dspbrk@context\@ne \restore@math@cr
+ \spread@equation
+ \ialign\bgroup
+ \hfil\strut@$\m@th\displaystyle##$\hfil
+ \crcr
+}{%
+ \endaligned
+}
+% \end{macrocode}
+% \end{environment}
+%
+%
+% \subsection{The \env{gather} environment}
+%
+% \begin{macro}{\start@gather}
+% \begin{macrocode}
+\def\start@gather#1{%
+ \RIfM@
+ \nomath@env
+ \DN@{\@namedef{end\@currenvir}{}\@gobble}%
+ \else
+ $$%
+ #1%
+ \ifst@rred \else \global\@eqnswtrue \fi
+ \let\next@\gather@
+ \fi
+ \collect@body\next@
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{environment}{gather}
+% \begin{environment}{gather*}
+% \begin{macrocode}
+\newenvironment{gather}{%
+ \start@gather\st@rredfalse
+}{%
+ \math@cr \black@\totwidth@ \egroup
+ $$\ignorespacesafterend
+}
+
+\newenvironment{gather*}{%
+ \start@gather\st@rredtrue
+}{%
+ \endgather
+}
+% \end{macrocode}
+% \end{environment}
+% \end{environment}
+%
+% \begin{macro}{\gather@}
+% \begin{macrocode}
+\def\gather@#1{%
+ \ingather@true \let\split\insplit@
+ \let\tag\tag@in@align \let\label\label@in@display
+ \chardef\dspbrk@context\z@
+ \intertext@ \displ@y@ \Let@
+ \let\math@cr@@@\math@cr@@@gather
+ \gmeasure@{#1}%
+ \global\shifttag@false
+ \tabskip\z@skip
+ \global\row@\@ne
+ \halign to\displaywidth\bgroup
+ \strut@
+ \setboxz@h{$\m@th\displaystyle{##}$}%
+ \calc@shift@gather
+ \set@gather@field
+ \tabskip\@centering
+ &\setboxz@h{\strut@{##}}%
+ \place@tag@gather
+ \tabskip \iftagsleft@ \gdisplaywidth@ \else \z@skip \span\fi
+ \crcr
+ #1%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\gmeasure@}
+% \begin{macrocode}
+\def\gmeasure@#1{%
+ \begingroup
+ \measuring@true
+ \totwidth@\z@
+ \global\let\tag@lengths\@empty
+ \savecounters@
+ \setbox\@ne\vbox{%
+ \everycr{\noalign{\global\tag@false
+ \global\let\raise@tag\@empty \global\column@\z@}}%
+ \let\label\@gobble
+ \halign{%
+ \setboxz@h{$\m@th\displaystyle{##}$}%
+ \ifdim\wdz@>\totwidth@
+ \global\totwidth@\wdz@
+ \fi
+ &\setboxz@h{\strut@{##}}%
+ \savetaglength@
+ \crcr
+ #1%
+ \math@cr@@@
+ }%
+ }%
+ \restorecounters@
+ \if@fleqn
+ \global\advance\totwidth@\@mathmargin
+ \fi
+ \iftagsleft@
+ \ifdim\totwidth@>\displaywidth
+ \global\let\gdisplaywidth@\totwidth@
+ \else
+ \global\let\gdisplaywidth@\displaywidth
+ \fi
+ \fi
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\math@cr@@@gather}
+% Modified \cs{math@cr@@@gather} so that it always puts in the
+% final field, which needs to be done under the new method for
+% determining tag placement. This is probably more efficient
+% anyway.
+%
+% \begin{macrocode}
+\def\math@cr@@@gather{%
+ \ifst@rred\nonumber\fi
+ &\relax
+ \make@display@tag
+ \ifst@rred\else\global\@eqnswtrue\fi
+% \end{macrocode}
+% We advance \cs{row@} here, rather than at the beginning of the
+% preamble, because otherwise the \env{split} environment will
+% cause \cs{row@} to be advanced twice instead of once.
+% \begin{macrocode}
+ \global\advance\row@\@ne
+ \cr
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\calc@shift@gather}
+% \cs{calc@shift@gather} has must make two decisions: (1) whether the
+% equation tag for the current line should be put on a separate
+% line and (2) what the distance between the equation and the
+% equation tag should be. We implement \tex/'s built-in
+% tag-placement as well as possible, with one improvement: the
+% minimum separation between tag and equation is now a
+% user-settable parameter.
+%
+% [1995/01/17] Added a check to make sure that the width of the tag
+% on the current line is $>0$ before testing to see if tagwidth +
+% linewidth + mintagsep $>$ displaywidth. Since an imbedded align
+% shows up as line with width \cn{displaywidth}, and even lines
+% without a tag get processed as if an empty tag were present, the
+% result was that the empty tag assigned to the line containing the
+% align was being shifted downwards, creating extra space after the
+% align.
+% \begin{macrocode}
+\def\calc@shift@gather{%
+ \dimen@\mintagsep\relax
+ \tagwidth@\tag@width\row@\relax
+% \end{macrocode}
+% If we're in \opt{fleqn} mode, there is no flexibility about
+% placement of the equation, so all we can do is see if there's
+% room for the tag in the given margin.
+% \begin{macrocode}
+ \if@fleqn
+ \global\eqnshift@\@mathmargin
+ \ifdim\tagwidth@>\z@
+ \advance\dimen@\tagwidth@
+ \iftagsleft@
+ \ifdim\dimen@>\@mathmargin
+ \global\shifttag@true
+ \fi
+ \else
+ \advance\dimen@\@mathmargin
+ \advance\dimen@\wdz@
+ \ifdim\dimen@>\displaywidth
+ \global\shifttag@true
+ \fi
+ \fi
+ \fi
+ \else
+ \global\eqnshift@\displaywidth
+ \global\advance\eqnshift@-\wdz@
+ \ifdim\tagwidth@>\z@
+ \multiply\dimen@\tw@
+ \advance\dimen@\wdz@
+ \advance\dimen@\tagwidth@
+ \ifdim\dimen@>\displaywidth
+ \global\shifttag@true
+ \else
+ \ifdim\eqnshift@<4\tagwidth@
+ \global\advance\eqnshift@-\tagwidth@
+ \fi
+ \fi
+ \fi
+ \global\divide\eqnshift@\tw@
+ \iftagsleft@
+ \global\eqnshift@-\eqnshift@
+ \global\advance\eqnshift@\displaywidth
+ \global\advance\eqnshift@-\wdz@
+ \fi
+ \ifdim\eqnshift@<\z@
+ \global\eqnshift@\z@
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\place@tag@gather}
+% \begin{macro}{\set@gather@field}
+% \begin{macrocode}
+\def\place@tag@gather{%
+ \iftagsleft@
+ \kern-\gdisplaywidth@
+ \ifshifttag@
+ \rlap{\vbox{%
+ \normalbaselines
+ \boxz@
+ \vbox to\lineht@{}%
+ \raise@tag
+ }}%
+ \global\shifttag@false
+ \else
+ \rlap{\boxz@}%
+ \fi
+ \else
+ \ifdim\totwidth@>\displaywidth
+ \dimen@\totwidth@
+ \advance\dimen@-\displaywidth
+ \kern-\dimen@
+ \fi
+ \ifshifttag@
+ \llap{\vtop{%
+ \raise@tag
+ \normalbaselines
+ \setbox\@ne\null
+ \dp\@ne\lineht@
+ \box\@ne
+ \boxz@
+ }}%
+ \global\shifttag@false
+ \else
+ \llap{\boxz@}%
+ \fi
+ \fi
+}
+%
+\def\set@gather@field{%
+ \iftagsleft@
+ \global\lineht@\ht\z@
+ \else
+ \global\lineht@\dp\z@
+ \fi
+ \kern\eqnshift@
+ \boxz@
+ \hfil
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
+% \subsection{The \env{align} family of environments}
+%
+% The \env{align}, \env{flalign}, \env{alignat}, \env{xalignat},
+% and \env{xxalignat} environments are virtually
+% identical, and thus will share much code. We'll refer to the
+% environments generically as ``\env{align}'' and will
+% distinguish between them explicitly
+% only when necessary.
+%
+% \begin{macro}{\ifxxat@}
+% \begin{macro}{\ifcheckat@}
+% \begin{macro}{\xatlevel@}
+% The \cs{xatlevel@} macro will be used, informally speaking, to
+% distinguish between the \env{alignat} and \env{xalignat}, and
+% \env{xxalignat} environments.
+%
+% \begin{macrocode}
+\newif\ifxxat@
+
+\newif\ifcheckat@
+
+\let\xatlevel@\@empty
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\start@align}
+% \cs{start@align} will be called by all of the \env{align}-like
+% environments. The first argument will be the \cs{xatlevel@},
+% i.e., 0, 1, or~2; the second argument will be either
+% \cs{st@rredtrue} or \cs{st@rredfalse}. The third argument will
+% be the number of aligned
+% structures in the environment (either as supplied by the user, or
+% $-1$ to indicate that checking shouldn't be done). After
+% performing the appropriate error detection and initialization,
+% \cs{start@align} calls \cs{align@}.
+%
+% Note that the \cs{equation} counter is no longer stepped at the
+% beginning of these environments.
+%
+% TODO: Implement \cs{shoveleft} and \cs{shoveright} for
+% \env{align}.
+% \begin{macrocode}
+\def\start@align#1#2#3{%
+ \let\xatlevel@#1% always \z@, \@ne, or \tw@
+ \maxfields@#3\relax
+ \ifnum\maxfields@>\m@ne
+ \checkat@true
+ \ifnum\xatlevel@=\tw@
+ \xxat@true
+ \fi
+ \multiply\maxfields@\tw@
+ \else
+ \checkat@false
+ \fi
+ \ifingather@
+ \iffalse{\fi\ifnum0=`}\fi
+ \DN@{\vcenter\bgroup\savealignstate@\align@#2}%
+ \else
+ \ifmmode
+ \if@display
+ \DN@{\align@recover}%
+ \else
+ \nomath@env
+ \DN@{\@namedef{end\@currenvir}{}\@gobble}%
+ \fi
+ \else
+ $$%
+ \let\split\insplit@
+ \DN@{\align@#2}%
+ \fi
+ \fi
+ \collect@body\next@
+}
+% \end{macrocode}
+%
+% With version 1.2 of \pkg{amsmath}, it was possible to use
+% \env{align*} and relatives in certain wrong contexts without
+% getting an error, e.g.
+% \begin{verbatim}
+% \begin{equation*}
+% \begin{align*}
+% ...
+% \end{align*}
+% \end{equation*}
+% \end{verbatim}
+%
+% For backward compatibility we therefore give only a warning for
+% this condition instead of a full error, and try to recover using
+% the \env{aligned} environment. The alignment of the material may be
+% adversely affected but it will at least remain readable.
+% \begin{macrocode}
+\def\align@recover#1#2#3{%
+ \endgroup
+ \@amsmath@err{%
+Erroneous nesting of equation structures;\MessageBreak
+trying to recover with `aligned'%
+ }\@ehc
+ \begin{aligned}\relax#1\end{aligned}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{environment}{align}
+% \begin{environment}{align*}
+% \begin{environment}{flalign}
+% \begin{environment}{flalign*}
+% \begin{environment}{alignat}
+% \begin{environment}{alignat*}
+% \begin{environment}{xalignat}
+% \begin{environment}{xalignat*}
+% \begin{environment}{xxalignat}
+% The definitions of the various \env{align} environments are quite
+% straight-forward.
+%
+% \begin{macrocode}
+\newenvironment{alignat}{%
+ \start@align\z@\st@rredfalse
+}{%
+ \endalign
+}
+\newenvironment{alignat*}{%
+ \start@align\z@\st@rredtrue
+}{%
+ \endalign
+}
+\newenvironment{xalignat}{%
+ \start@align\@ne\st@rredfalse
+}{%
+ \endalign
+}
+\newenvironment{xalignat*}{%
+ \start@align\@ne\st@rredtrue
+}{%
+ \endalign
+}
+\newenvironment{xxalignat}{%
+ \start@align\tw@\st@rredtrue
+}{%
+ \endalign
+}
+\newenvironment{align}{%
+ \start@align\@ne\st@rredfalse\m@ne
+}{%
+ \math@cr \black@\totwidth@
+ \egroup
+ \ifingather@
+ \restorealignstate@
+ \egroup
+ \nonumber
+ \ifnum0=`{\fi\iffalse}\fi
+ \else
+ $$%
+ \fi
+ \ignorespacesafterend
+}
+\newenvironment{align*}{%
+ \start@align\@ne\st@rredtrue\m@ne
+}{%
+ \endalign
+}
+\newenvironment{flalign}{%
+ \start@align\tw@\st@rredfalse\m@ne
+}{%
+ \endalign
+}
+\newenvironment{flalign*}{%
+ \start@align\tw@\st@rredtrue\m@ne
+}{%
+ \endalign
+}
+% \end{macrocode}
+% \end{environment}
+% \end{environment}
+% \end{environment}
+% \end{environment}
+% \end{environment}
+% \end{environment}
+% \end{environment}
+% \end{environment}
+% \end{environment}
+%
+%
+% \begin{macro}{\align@}
+% TODO: Some of these sets of initializations show up in multiple
+% places. It might be worth making an abbreviation for them.
+%
+% \begin{macrocode}
+\def\align@#1#2{%
+ \inalign@true \intertext@ \Let@ \chardef\dspbrk@context\z@
+ \ifingather@\else\displ@y@\fi
+ \let\math@cr@@@\math@cr@@@align
+ \ifxxat@\else \let\tag\tag@in@align \fi
+ \let\label\label@in@display
+ #1% set st@r
+ \ifst@rred\else \global\@eqnswtrue \fi
+ \measure@{#2}%
+ \global\row@\z@
+ \tabskip\eqnshift@
+ \halign\bgroup
+ \span\align@preamble\crcr
+ #2%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\math@cr@@@align}
+% \begin{macrocode}
+\def\math@cr@@@align{%
+ \ifst@rred\nonumber\fi
+ \if@eqnsw \global\tag@true \fi
+ \global\advance\row@\@ne
+ \add@amps\maxfields@
+ \omit
+ \kern-\alignsep@
+ \iftag@
+ \setboxz@h{\@lign\strut@{\make@display@tag}}%
+ \place@tag
+ \fi
+ \ifst@rred\else\global\@eqnswtrue\fi
+ \global\lineht@\z@
+ \cr
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\math@cr@@@align@measure}
+% \begin{macrocode}
+\def\math@cr@@@align@measure{%
+ &\omit
+ \global\advance\row@\@ne
+ \ifst@rred\nonumber\fi
+ \if@eqnsw \global\tag@true \fi
+ \ifnum\column@>\maxfields@
+ \ifcheckat@
+ \begingroup
+ \measuring@false
+ \@amsmath@err{Extra & on this line}%
+ {\the\andhelp@}% "An extra & here is disastrous"
+ \endgroup
+ \else
+ \global\maxfields@\column@
+ \fi
+ \fi
+ \setboxz@h{\@lign\strut@{%
+ \if@eqnsw
+ \stepcounter{equation}%
+ \tagform@\theequation
+ \else
+ \iftag@\df@tag\fi
+ \fi
+ }}%
+ \savetaglength@
+ \ifst@rred\else\global\@eqnswtrue\fi
+ \cr
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\field@lengths}
+% \begin{macro}{\savefieldlength@}
+% \begin{macro}{\fieldlengths@}
+% \begin{macrocode}
+\let\field@lengths\@empty
+
+\def\savefieldlength@{%
+ \begingroup
+ \let\or\relax
+ \xdef\field@lengths{%
+ \field@lengths
+ \ifnum\column@=0
+ \or
+ \else
+ ,%
+ \fi
+ \the\wdz@
+ }%
+ \endgroup
+}
+
+\def\fieldlengths@#1{%
+ \ifcase\@xp#1\field@lengths\fi
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\maxcolumn@widths}
+% \cs{maxcolumn@widths} will be used to hold the widths of the
+% fields of the \env{alignat} environment. The widths will be
+% separated by the token \cn{or}, making it easy to extract a given
+% width using \cn{ifcase}.
+% \begin{macrocode}
+\let\maxcolumn@widths\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\maxcol@width}
+% \cs{maxcol@width} $n$ = maximum width of $n$th column of the current
+% \env{alignat} (i.e., the $n$th field of \cs{maxcolumn@widths}.)
+% It expands to a \<dimen>, so it can be used as the right-hand
+% side of a \<variable assignment> or \<arithmetic> statement.
+% It's argument can be any \<number>, \<integer variable> or macro
+% that expands to one of these. [Check to make sure this is true.]
+%
+% This is subtler than it looks.
+% \begin{macrocode}
+\def\maxcol@width#1{%
+ \ifcase\@xp#1\maxcolumn@widths\fi\relax
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Now comes the real fun. A typical \env{align} environments looks
+% something like this, where the vertical bars mark the edges of
+% the fields of the underlying \cs{halign}:
+% \[
+% \makeatletter\tabskip\@centering\offinterlineskip
+% \halign to\displaywidth{%^^A
+% &$\strut$\vrule\hfil$\m@th\displaystyle{\@lign#}$\vrule
+% \tabskip1pt&\vrule$\m@th\displaystyle{\@lign#}$\hfil\vrule
+% \tabskip\@centering\cr
+% \omit\small\hfil 1\hfil &\omit\small\hfil 2 &\omit\small\hfil
+% 3\hfil &\omit\small\hfil 4\hfil & \omit\small\hfil 5\hfil
+% &\omit\small\hfil 6\hfil\cr
+% \noalign{\vskip8pt\relax}
+% V_i + q_i v_j & =v_i , & X_i & = x_i - q_i x_j,
+% & U_i & = u_i,\qquad
+% \hbox{for $i\ne j$;} %&\omit\hfill \llap{(3)}
+% \cr
+% V_j & = v_j, & X_j & = x_j,
+% & U_j & = u_j + \sum_{i\ne j} q_i u_i. %&\omit\hfill \llap{(4)}
+% \cr}
+% \]
+% Note that each align structure consists of two fields, with no
+% space between them (a small space has been added here to
+% highlight the boundaries). Furthermore, the text inside the
+% odd-numbered fields is flushright, while the text inside the
+% even-numbered fields is flushleft. The equation tags (shown on
+% the right here) can be on either the right or the left. If there
+% is not room (in a sense to be defined shortly) for the tag on the
+% same line as the equation, the tag will be shifted to a separate
+% line.
+%
+% Each environment also has a certain number of ``flexible
+% spaces,'' meaning spaces whose width we are allowed to adjust to
+% take up the amount of ``free space'' in the line, meaning the
+% space not taken up by the equation tag and the fields of the
+% underlying \cs{halign}.
+%
+% The flexible spaces come in two flavors: interalign spaces and
+% margin spaces. If there are $n$ align structures ($n=3$ in the
+% illustration above), there are $n-1$ interalign spaces, unless we
+% are in an \env{alignat} environment, in which case there are no
+% flexible interalign spaces.
+%
+% The number of margin spaces is a little more complicated:
+% Normally, there are two, but if we're in \opt{fleqn} mode, there
+% is only one. Furthermore, if we're in an \env{xxalignat} or
+% \env{flalign} environment (corresponding to $\cs{xatlevel@} = 2$,
+% then there are no flexible margin spaces.
+%
+% Calculating the interalign and margin spaces is done in two
+% stages.
+%
+% First, the total amount of free space is divided uniformly among
+% all the flexible spaces, without regard for the lengths of the tags
+% on the various lines. For the non-\opt{fleqn} case, this
+% corresponds to centering the align structures between the margins.
+% Note that in \opt{fleqn} mode, the right margin is still allowed to
+% be larger than \cs{@mathmargin}. This introduces an element of
+% asymmetry into the appearance of the environment, but it has the
+% advantage of leaving more space for equation tags in the right
+% margin. If the right margin were constrained to be equal to the
+% left margin in this case, tags would need to be shifted to a
+% separate line more often than would be desirable.
+%
+% Ordinarily, all flexible spaces will be given the same width.
+% However, this is not invariably true, since the interalign spaces
+% are constrained to be at least \cs{minalignsep} wide, while---in
+% the absence of equation tags, at least---the margin spaces are
+% allowed to shrink to zero. As we shall see in a minute, if there
+% are tags in the environment, then the margins are also bounded
+% below by \cs{mintagsep}.
+%
+% Next, we examine each line of the environment that has a tag to
+% see if there is a gap of at least \cs{mintagsep} between the
+% equation and its tag. If there isn't, we attempt to center the
+% equation between the tag and the opposite margin, leaving a gap
+% of at least \cs{mintagsep} on either side, in order to preserve
+% some symmetry, i.e., we want the equation to \emph{look} like
+% it's centered between the margin and the tag, so we don't want
+% the margin space to be less than the gap between the tag and the
+% equation. (Arguably, it would be better to allow the margin
+% space to shrink to zero in this case in order to avoid shifting
+% the tag to a separate line at any cost, but that would require
+% all of our calculations to be a little more complicated and hence
+% a little slower.) Finally, if no values of the interalign spaces
+% and the margins (with the constraints outlined above) will
+% produce an acceptable distance between the equation and its tag,
+% then the tag will be shifted to a separate line.
+%
+% \begin{macro}{\measure@}
+% \cs{measure@} collects the various bits of information that we'll
+% need to perform the calculations outlined above, namely, the
+% number of align structures in the environment, the natural
+% lengths of the fields on each row, the maximum widths of each
+% column, and the widths of the equation tags on each line. It
+% also calculates the number of flexible interalign and margin
+% spaces and computes the initial values of the parameters
+% \cs{eqnshift@} and \cs{alignsep@}, which correspond to the widths
+% of the margins and the interalign spaces, respectively.
+% \begin{macrocode}
+\def\measure@#1{%
+ \begingroup
+ \measuring@true
+ \global\eqnshift@\z@
+ \global\alignsep@\z@
+ \global\let\tag@lengths\@empty
+ \global\let\field@lengths\@empty
+ \savecounters@
+ \global\setbox0\vbox{%
+ \let\math@cr@@@\math@cr@@@align@measure
+ \everycr{\noalign{\global\tag@false
+ \global\let\raise@tag\@empty \global\column@\z@}}%
+ \let\label\@gobble
+ \global\row@\z@
+ \tabskip\z@
+ \halign{\span\align@preamble\crcr
+ #1%
+ \math@cr@@@
+ \global\column@\z@
+ \add@amps\maxfields@\cr
+ }%
+ }%
+ \restorecounters@
+% \end{macrocode}
+% It's convenient to have \cs{maxfields@} rounded up to the nearest
+% even number, so that \cs{maxfields@} is precisely twice the
+% number of align structures.
+% \begin{macrocode}
+ \ifodd\maxfields@
+ \global\advance\maxfields@\@ne
+ \fi
+% \end{macrocode}
+% It doesn't make sense to have a single align structure in either
+% \env{flalign} or \env{xxalignat}. So, we check for that case now
+% and, if necessary, switch to an \env{align} or \env{alignat}.
+% Arguably, we should issue a warning message, but why bother?
+% \begin{macrocode}
+ \ifnum\xatlevel@=\tw@
+ \ifnum\maxfields@<\thr@@
+ \let\xatlevel@\z@
+ \fi
+ \fi
+% \end{macrocode}
+% |\box0| now contains the lines of the \cs{halign}. After the
+% following maneuver, |\box1| will contain the last line of the
+% \cs{halign}, which is what we're interested in. (Incidentally,
+% the penalty we're removing is the \cs{@eqpen} inserted by
+% \cs{math@cr}. Normally, this is \cs{interdisplaylinepenalty},
+% unless the user has overridden that with a \cs{displaybreak}
+% command.)
+% \begin{macrocode}
+ \setbox\z@\vbox{%
+ \unvbox\z@ \unpenalty \global\setbox\@ne\lastbox
+ }%
+% \end{macrocode}
+% |\box1| begins with \cs{tabskip} glue and contains alternating
+% \cs{hbox}es (the fields whose widths we're trying to get) and
+% \cs{tabskip} glue [need better diagram]:
+% \begin{verbatim}
+% \hbox{\tabskip\hbox\tabskip...\hbox\tabskip}\end{verbatim}
+% In fact, all the \cs{tabskip} glue will be 0pt, because all the
+% \cs{tabskip}s in an \env{alignat} environment have a natural
+% width of 0pt, and the \cs{halign} has been set in its natural
+% width.
+%
+% One nice result of this is that we can read \cs{totwidth@} off
+% immediately, since it is just the width of |\box1|, plus
+% \cs{@mathmargin} if we're in \opt{fleqn} mode. (Actually, we
+% also have to take \cs{minalignsep} into account, but we'll do
+% that later):
+% \begin{macrocode}
+ \global\totwidth@\wd\@ne
+ \if@fleqn \global\advance\totwidth@\@mathmargin \fi
+% \end{macrocode}
+% Now we initialize \cs{align@lengths} and start peeling the boxes
+% off, one by one, and adding their widths to \cs{align@lengths}.
+% We stop when we run out of boxes, i.e., when \cs{lastbox} returns
+% a void box. We're going to build a list using \cs{or} as a
+% delimiter, so we want to disable it temporarily.
+% \begin{macrocode}
+ \global\let\maxcolumn@widths\@empty
+ \begingroup
+ \let\or\relax
+ \loop
+ \global\setbox\@ne\hbox{%
+ \unhbox\@ne \unskip \global\setbox\thr@@\lastbox
+ }%
+ \ifhbox\thr@@
+ \xdef\maxcolumn@widths{ \or \the\wd\thr@@ \maxcolumn@widths}%
+ \repeat
+ \endgroup
+% \end{macrocode}
+% Now we calculate the number of flexible spaces and the initial
+% values of \cs{eqnshift@} and \cs{alignsep@}.
+% We start by calculating $\cs{displaywidth}-\cs{totwidth@}$,
+% which gives us the total amount of ``free space'' in a row.
+% \begin{macrocode}
+ \dimen@\displaywidth
+ \advance\dimen@-\totwidth@
+% \end{macrocode}
+% Next we calculate the number of columns of flexible spaces in the
+% display, which depends on whether we're in \opt{fleqn} mode and
+% in which particular environment we are in.
+%
+% We use \cs{@tempcnta} to store the total number of flexible spaces
+% in the align and \cs{@tempcntb} for the number of interalign
+% spaces.
+% \begin{macrocode}
+ \ifcase\xatlevel@
+% \end{macrocode}
+% In \env{alignat}, the interalign spaces are under user control,
+% not ours. So, we set \cs{alignsep@} and \cs{minalignsep} both
+% equal to 0pt. Later, when calculating a new value for
+% \cs{alignsep@}, we will only save the new value if it is less
+% than the current value of \cs{alignsep@} (i.e., \cs{alignsep@}
+% will never increase). Since the values we calculate will never
+% be negative, this will ensure that \cs{alignsep@} remains zero in
+% \env{alignat}.
+% \begin{macrocode}
+ \global\alignsep@\z@
+ \let\minalignsep\z@
+ \@tempcntb\z@
+% \end{macrocode}
+% In \opt{fleqn} mode, the left margin---and hence the right margin
+% in this case---is fixed. Otherwise, we divide the free space
+% equally between the two margins.
+% \begin{macrocode}
+ \if@fleqn
+ \@tempcnta\@ne
+ \global\eqnshift@\@mathmargin
+ \else
+ \@tempcnta\tw@
+ \global\eqnshift@\dimen@
+ \global\divide\eqnshift@\@tempcnta
+ \fi
+ \or
+% \end{macrocode}
+% In an \env{align} or \env{xalignat} environment with $n$ aligned
+% structures, there are $n-1$ interalign spaces and either 1 or~2
+% flexible margins, depending on whether we're in \opt{fleqn} mode
+% or not.
+% \begin{macrocode}
+ \@tempcntb\maxfields@
+ \divide\@tempcntb\tw@
+ \@tempcnta\@tempcntb
+ \advance\@tempcntb\m@ne
+% \end{macrocode}
+% If we are in \opt{fleqn} mode, we fix the left margin and divide
+% the free space equally among the interalign spaces and the right
+% margin.
+% \begin{macrocode}
+ \if@fleqn
+ \global\eqnshift@\@mathmargin
+ \global\alignsep@\dimen@
+ \global\divide\alignsep@\@tempcnta
+ \else
+% \end{macrocode}
+% Otherwise, we divide the free space equally among the interalign
+% spaces and both margins.
+% \begin{macrocode}
+ \global\advance\@tempcnta\@ne
+ \global\eqnshift@\dimen@
+ \global\divide\eqnshift@\@tempcnta
+ \global\alignsep@\eqnshift@
+ \fi
+ \or
+% \end{macrocode}
+% Finally, if we're in an \env{flalign} or \env{xxalignat}
+% environment, there are no flexible margins and $n-1$ flexible
+% interalign spaces.
+% \begin{macrocode}
+ \@tempcntb\maxfields@
+ \divide\@tempcntb\tw@
+ \global\advance\@tempcntb\m@ne
+ \global\@tempcnta\@tempcntb
+ \global\eqnshift@\z@
+ \global\alignsep@\dimen@
+% \end{macrocode}
+% If we're in \opt{fleqn} mode, we need to add back the
+% \cs{@mathmargin} that was removed when \cs{dimen@} was originally
+% calculated above.
+% \begin{macrocode}
+ \if@fleqn
+ \global\advance\alignsep@\@mathmargin\relax
+ \fi
+ \global\divide\alignsep@\@tempcntb
+ \fi
+% \end{macrocode}
+% Now we make sure \cs{alignsep@} isn't too small.
+% \begin{macrocode}
+ \ifdim\alignsep@<\minalignsep\relax
+ \global\alignsep@\minalignsep\relax
+ \ifdim\eqnshift@>\z@
+ \if@fleqn\else
+ \global\eqnshift@\displaywidth
+ \global\advance\eqnshift@-\totwidth@
+ \global\advance\eqnshift@-\@tempcntb\alignsep@
+ \global\divide\eqnshift@\tw@
+ \fi
+ \fi
+ \fi
+ \ifdim\eqnshift@<\z@
+ \global\eqnshift@\z@
+ \fi
+ \calc@shift@align
+% \end{macrocode}
+% Next, we calculate the value of \cs{tagshift@}. This is the glue
+% that will be inserted in front of the equation tag to make sure
+% it lines up flush against the appropriate margin.
+% \begin{macrocode}
+ \global\tagshift@\totwidth@
+ \global\advance\tagshift@\@tempcntb\alignsep@
+ \if@fleqn
+ \ifnum\xatlevel@=\tw@
+ \global\advance\tagshift@-\@mathmargin\relax
+ \fi
+ \else
+ \global\advance\tagshift@\eqnshift@
+ \fi
+ \iftagsleft@ \else
+ \global\advance\tagshift@-\displaywidth
+ \fi
+% \end{macrocode}
+% Finally, we increase \cs{totwidth@} by an appropriate multiple of
+% \cs{minalignsep}. If the result is greater than
+% \cs{displaywidth}, it means that at least one line in the
+% \env{align} is overfull and we will issue an appropriate warning
+% message (via \cs{bl@ck}) at the end of the environment.
+% \begin{macrocode}
+ \dimen@\minalignsep\relax
+ \global\advance\totwidth@\@tempcntb\dimen@
+ \ifdim\totwidth@>\displaywidth
+ \global\let\displaywidth@\totwidth@
+ \else
+ \global\let\displaywidth@\displaywidth
+ \fi
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% The code for calculating the appropriate placement of equation
+% tags in the \env{align} environments is quite complicated and
+% varies wildly depending on the settings of the |tagsleft@| and
+% |@fleqn| switches. To minimize memory and hash space usage, we
+% only define the variant appropriate for the current setting of
+% those switches.
+%
+% It would be worthwhile to examine this code more closely someday
+% and see if it could be optimized any.
+%
+% \paragraph{Tag placement when \cs{tagsleft@true},
+% \cs{@fleqntrue}.}
+%
+% We begin with the version of \cs{calc@shift@align} appropriate
+% for flush-left equations with tags on the left.
+%
+% \begin{macro}{\calc@shift@align}
+% This is the simplest case. Since the left margin is fixed, in
+% general the only thing to do is check whether there is room for
+% the tag in the left margin. The only exception is that if
+% $\cs{eqnshift@} = 0\,\mathrm{pt}$---meaning that we're in a
+% \env{flalign} environment and this is the first line with a tag
+% that we've encountered---then we set $\cs{eqnshift@} =
+% \cs{@mathmargin}$ and recalculate \cs{alignsep@}. This is done
+% by \cs{x@calc@shift@lf}.
+% \begin{macrocode}
+\iftagsleft@\if@fleqn
+ \def\calc@shift@align{%
+ \global\let\tag@shifts\@empty
+ \begingroup
+% \end{macrocode}
+% \cs{@tempdima} is initialized to $\cs{@mathmargin} -
+% \cs{mintagsep}$, which yields the maximum size of a tag that will
+% not be shifted to another line.
+% \begin{macrocode}
+ \@tempdima\@mathmargin\relax
+ \advance\@tempdima-\mintagsep\relax
+% \end{macrocode}
+% Now we examine each row in turn. If the width of the tag on the
+% line is non-positive---meaning either that there is no tag or
+% else that the user has forced it to have zero width---we mark the
+% tag to remain unshifted. Otherwise, we call \cs{x@calc@shift@lf}
+% to determine whether any adjustments need to be made to
+% \cs{eqnshift@} and \cs{alignsep@}. Note the difference in
+% treatment of zero-width tags between this code and \tex/'s
+% built-in algorithm: here, a width of zero prohibits the tag from
+% being shifted, while in \tex/'s built-in algorithm, a width of
+% zero forces the tag to be shifted.
+% \begin{macrocode}
+ \loop
+ \ifnum\row@>0
+ \ifdim\tag@width\row@>\z@
+ \x@calc@shift@lf
+ \else
+ \saveshift@0%
+ \fi
+ \advance\row@\m@ne
+ \repeat
+ \endgroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\x@calc@shift@lf}
+% As mentioned above, \cs{x@calc@shift@lf} first checks to see if
+% the current left margin is set to 0 and, if so, resets it to
+% \cs{@mathmargin} and recalculates \cs{alignsep@}. Next, it
+% checks whether the length of the current tag exceeds the
+% previously calculated limit and, if so, marks the tag to be
+% shifted to a separate line.
+% \begin{macrocode}
+ \def\x@calc@shift@lf{%
+ \ifdim\eqnshift@=\z@
+ \global\eqnshift@\@mathmargin\relax
+ \alignsep@\displaywidth
+ \advance\alignsep@-\totwidth@
+ \global\divide\alignsep@\@tempcntb
+ \ifdim\alignsep@<\minalignsep\relax
+ \global\alignsep@\minalignsep\relax
+ \fi
+ \fi
+ \ifdim\tag@width\row@>\@tempdima
+ \saveshift@1%
+ \else
+ \saveshift@0%
+ \fi
+ }
+\fi\fi
+% \end{macrocode}
+% \end{macro}
+%
+% \paragraph{Tag placement when \cs{tagsleft@false},
+% \cs{@fleqntrue}.}
+%
+% Next we consider the case when equations are flush-left, but tags
+% are on the right. This case is somewhat more complicated than
+% the previous one, since we can adjust the right margin by varying
+% the inter-align separatin. Thus, when a tag is found to be too
+% close to its equation, we first attempt to decrease
+% \cs{alignsep@} enough to move the equation off to an acceptable
+% distance. Only if that would require a value of \cs{alignsep@}
+% less than \cs{minalignsep} do we move the tag to a separate line.
+%
+% \begin{macro}{\calc@shift@align}
+% This version of \cs{calc@shift@align} differs from the previous
+% version only in calling \cs{x@calc@shift@rf} rather than
+% \cs{x@calc@shift@lf}.
+% \begin{macrocode}
+\iftagsleft@\else\if@fleqn
+ \def\calc@shift@align{%
+ \global\let\tag@shifts\@empty
+ \begingroup
+ \loop
+ \ifnum\row@>0
+ \ifdim\tag@width\row@>\z@
+ \x@calc@shift@rf
+ \else
+ \saveshift@0%
+ \fi
+ \advance\row@\m@ne
+ \repeat
+ \endgroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\x@calc@shift@rf}
+% To start, we need to know two quantities: the number of align
+% structures in the current row and the ``effective length'' of the
+% row, defined as the distance from the left margin to the
+% right edge of the text assuming that \cs{eqnshift@} and
+% \cs{alignsep@} are both~0. To get the number of align
+% structures, we first count the number of columns by counting the
+% number of entries in the \cs{fieldlengths@} for the current row.
+% The effective length is calcuated by \cs{x@rcalc@width} and put
+% in the temporary register \cs{@tempdimc}, using \cs{@tempdimb} as
+% an auxiliary variable.
+% \begin{macrocode}
+ \def\x@calc@shift@rf{%
+ \column@\z@
+ \@tempdimb\z@
+ \@tempdimc\z@
+ \edef\@tempb{\fieldlengths@\row@}%
+ \@for\@tempa:=\@tempb\do{%
+ \advance\column@\@ne
+ \x@rcalc@width
+ }%
+ \begingroup
+% \end{macrocode}
+% If there are $n$ columns in the current row, then there are
+% $\lfloor (n+1)/2 \rfloor$ align structures and $\lfloor (n-1)/2
+% \rfloor$ interalign spaces.
+% \begin{macrocode}
+ \advance\column@\m@ne
+ \divide\column@\tw@
+% \end{macrocode}
+% If this is smaller than the maximum number of interalign spaces
+% in the environment, then we need to reduce \cs{@tempcnta} (the
+% total number of flexible spaces in the current line) by
+% $\cs{@tempcntb} - \cs{column@}$ and reset \cs{@tempcntb} to
+% \cs{column@}.
+% \begin{macrocode}
+ \ifnum\@tempcntb>\column@
+ \advance\@tempcnta-\@tempcntb
+ \advance\@tempcnta\column@
+ \@tempcntb\column@
+ \fi
+% \end{macrocode}
+% Next, we add the width of the tag and the (fixed) left margin to
+% the effective length calculated above. This can be used to
+% calculate how much ``free space'' there is in the current line
+% and thus how much leeway we have to increase the amount of space
+% between the tag and the equation.
+% \begin{macrocode}
+ \tagwidth@\tag@width\row@\relax
+ \@tempdima\eqnshift@
+ \advance\@tempdima\@tempdimc\relax
+ \advance\@tempdima\tagwidth@
+% \end{macrocode}
+% The first thing to check is whether the tag should be shifted to
+% a separate line. To do this, we add the minimum interalign
+% separation and the \cs{mintagsep} to the value of \cs{@tempdima}
+% just calculated. This yields the minimum acceptable length of
+% the current line. If that is greater than \cs{displaywidth}, we
+% mark the tag to be calculated. Otherwise, we mark the tag to be
+% kept on the same line and then check to see if the \cs{alignsep@}
+% needs to be reduced to make room for the tag.
+% \begin{macrocode}
+ \dimen@\minalignsep\relax
+ \multiply\dimen@\@tempcntb
+ \advance\dimen@\mintagsep\relax
+ \advance\dimen@\@tempdima
+ \ifdim\dimen@>\displaywidth
+ \saveshift@1%
+ \else
+ \saveshift@0%
+% \end{macrocode}
+% Now we perform essentially the same calculation, but using the
+% current value of \cs{alignsep@} instead of \cs{minalignsep}.
+% This gives the current length of the line. If this is greater
+% than \cs{displaywidth}, we recalculate \cs{alignsep@} to make
+% room for the tag.
+% \begin{macrocode}
+ \dimen@\alignsep@\relax
+ \multiply\dimen@\@tempcntb
+ \advance\dimen@\@tempdima
+ \advance\dimen@\tagwidth@
+ \ifdim\dimen@>\displaywidth
+ \dimen@\displaywidth
+ \advance\dimen@-\@tempdima
+ \ifnum\xatlevel@=\tw@
+ \advance\dimen@-\mintagsep\relax
+ \fi
+ \divide\dimen@\@tempcnta
+ \ifdim\dimen@<\minalignsep\relax
+ \global\alignsep@\minalignsep\relax
+ \else
+ \global\alignsep@\dimen@
+ \fi
+ \fi
+ \fi
+ \endgroup
+ }
+\fi\fi
+% \end{macrocode}
+% \end{macro}
+%
+% \paragraph{Tag placement when \cs{tagsleft@false},
+% \cs{@fleqnfalse}.}
+%
+% This is similar to the previous case, except for the added
+% complication that both \cs{alignsep@} and \cs{eqnshift@} can
+% vary, which makes the computations correspondingly more
+% complicated.
+%
+% \begin{macro}{\calc@shift@align}
+% \begin{macrocode}
+\iftagsleft@\else\if@fleqn\else
+ \def\calc@shift@align{%
+ \global\let\tag@shifts\@empty
+ \begingroup
+ \loop
+ \ifnum\row@>0
+ \ifdim\tag@width\row@>\z@
+ \x@calc@shift@rc
+ \else
+ \saveshift@0%
+ \fi
+ \advance\row@\m@ne
+ \repeat
+ \endgroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\x@calc@shift@rc}
+% \begin{macrocode}
+ \def\x@calc@shift@rc{%
+ \column@\z@
+ \@tempdimb\z@
+ \@tempdimc\z@
+ \edef\@tempb{\fieldlengths@\row@}%
+ \@for\@tempa:=\@tempb\do{%
+ \advance\column@\@ne
+ \x@rcalc@width
+ }%
+ \begingroup
+ \advance\column@\m@ne
+ \divide\column@\tw@
+ \ifnum\@tempcntb>\column@
+ \advance\@tempcnta-\@tempcntb
+ \advance\@tempcnta\column@
+ \@tempcntb\column@
+ \fi
+ \tagwidth@\tag@width\row@\relax
+ \@tempdima\@tempdimc
+ \advance\@tempdima\tagwidth@
+ \dimen@\minalignsep\relax
+ \multiply\dimen@\@tempcntb
+ \advance\dimen@\mintagsep\relax
+ \ifnum\xatlevel@=\tw@ \else
+ \advance\dimen@\mintagsep\relax
+ \fi
+ \advance\dimen@\@tempdima
+ \ifdim\dimen@>\displaywidth
+ \saveshift@1%
+ \else
+ \saveshift@0%
+ \dimen@\eqnshift@
+ \advance\dimen@\@tempdima
+ \advance\dimen@\@tempcntb\alignsep@
+ \advance\dimen@\tagwidth@
+ \ifdim\dimen@>\displaywidth
+ \dimen@\displaywidth
+ \advance\dimen@-\@tempdima
+ \ifnum\xatlevel@=\tw@
+ \advance\dimen@-\mintagsep\relax
+ \fi
+ \divide\dimen@\@tempcnta
+ \ifdim\dimen@<\minalignsep\relax
+ \global\alignsep@\minalignsep\relax
+ \eqnshift@\displaywidth
+ \advance\eqnshift@-\@tempdima
+ \advance\eqnshift@-\@tempcntb\alignsep@
+ \global\divide\eqnshift@\tw@
+ \else
+ \ifdim\dimen@<\eqnshift@
+ \ifdim\dimen@<\z@
+ \global\eqnshift@\z@
+ \else
+ \global\eqnshift@\dimen@
+ \fi
+ \fi
+ \ifdim\dimen@<\alignsep@
+ \global\alignsep@\dimen@
+ \fi
+ \fi
+ \fi
+ \fi
+ \endgroup
+ }
+\fi\fi
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\x@rcalc@width}
+% \begin{macrocode}
+\iftagsleft@\else
+ \def\x@rcalc@width{%
+ \ifdim\@tempa > \z@
+ \advance\@tempdimc\@tempdimb
+ \ifodd\column@
+ \advance\@tempdimc\maxcol@width\column@
+ \@tempdimb\z@
+ \else
+ \advance\@tempdimc\@tempa\relax
+ \@tempdimb\maxcol@width\column@
+ \advance\@tempdimb-\@tempa\relax
+ \fi
+ \else
+ \advance\@tempdimb\maxcol@width\column@\relax
+ \fi
+ }
+\fi
+% \end{macrocode}
+% \end{macro}
+%
+% \paragraph{Tag placement when \cs{tagsleft@true},
+% \cs{@fleqnfalse}.}
+%
+% \begin{macro}{\calc@shift@align}
+% \begin{macrocode}
+\iftagsleft@\if@fleqn\else
+ \def\calc@shift@align{%
+ \global\let\tag@shifts\@empty
+ \begingroup
+ \loop
+ \ifnum\row@>\z@
+ \ifdim\tag@width\row@>\z@
+ \x@calc@shift@lc
+ \else
+ \saveshift@0%
+ \fi
+ \advance\row@\m@ne
+ \repeat
+ \endgroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\x@calc@shift@lc}
+% \begin{macrocode}
+ \def\x@calc@shift@lc{%
+ \column@\z@
+% \end{macrocode}
+% \cs{@tempdima} will (eventually) be set to the effective width of
+% the current row, defined as the distance from the leftmost point
+% of the current line to the end of the last field of the
+% \cs{halign}, ignoring any intervening \cs{tabskip}s, plus the
+% width of the current tag. That is, it will be the width of the
+% first non-empty field plus the sum of the maximum widths of all
+% following fields, plus the tag width.
+%
+% \cs{@tempdimb} will be the ``indentation'' of leftmost end of
+% text, ignoring the \cs{tabskip} glue, i.e., it will be the sum of
+% the maximum widths of any fields to the left of the first
+% non-empty field, plus whatever empty space there is at the
+% beginning of the first non-empty field.
+% \begin{macrocode}
+ \@tempdima\z@ % ``width of equation''
+ \@tempdimb\z@ % ``indent of equation''
+ \edef\@tempb{\fieldlengths@\row@}%
+ \@for\@tempa:=\@tempb\do{%
+ \advance\column@\@ne
+ \x@lcalc@width
+ }%
+ \begingroup
+ \tagwidth@\tag@width\row@\relax
+% \end{macrocode}
+% \cs{@tempdima} is now easy to calculate, since it is just
+% $\cs{totwidth@} - \cs{@tempdimb} + \cs{tagwidth@}$.
+% \begin{macrocode}
+ \@tempdima\totwidth@
+ \advance\@tempdima-\@tempdimb
+ \advance\@tempdima\tagwidth@
+% \end{macrocode}
+% Next, we check to see whether there is room for both the equation
+% and the tag on the same line, by calculating the minimum
+% acceptable length of the current row and comparing that to
+% \cs{displaywidth}. Note that here we use \cs{@tempcntb}, i.e.,
+% the number of interalign spaces after the first non-empty align
+% structure.
+% \begin{macrocode}
+ \dimen@\minalignsep\relax
+ \multiply\dimen@\@tempcntb
+ \advance\dimen@\mintagsep\relax
+ \ifnum\xatlevel@=\tw@ \else
+ \advance\dimen@\mintagsep\relax
+ \fi
+ \advance\dimen@\@tempdima
+% \end{macrocode}
+% If the minimum acceptable width of the current line is greater
+% than \cs{displaywidth}, we mark the current tag to be shifted to
+% a separate line.
+% \begin{macrocode}
+ \ifdim\dimen@>\displaywidth
+ \saveshift@1%
+ \else
+% \end{macrocode}
+% Otherwise, the tag can stay on the same line as the equation, but
+% we need to check whether it is too close to the equation. So, we
+% calculate the distance between the left margin and the left side
+% of the equation, using the current values of \cs{eqnshift@} and
+% \cs{alignsep@}. Note that we use \cs{count@} here, not
+% \cs{@tempcntb}, as above.
+% \begin{macrocode}
+ \saveshift@0%
+ \dimen@\alignsep@
+ \multiply\dimen@\count@
+ \advance\dimen@\eqnshift@
+ \advance\dimen@\@tempdimb
+% \end{macrocode}
+% If the left margin is less than twice the tag width, we calculate
+% new values of \cs{eqnshift@} and \cs{alignsep@} to move the
+% equation further away from the tag. In particular, we center the
+% current line between its tag and the right margin. Note that
+% although we later will need to transform \cs{dimen@} into a value
+% suitable for use as \cs{eqnshift@}, for the time being it is more
+% useful to think of it as the space separating the tag from the
+% equation.
+% \begin{macrocode}
+ \ifdim\dimen@<2\tagwidth@
+ \dimen@\displaywidth
+ \advance\dimen@-\@tempdima
+ \ifnum\xatlevel@=\tw@
+ \advance\dimen@-\mintagsep\relax
+ \fi
+% \end{macrocode}
+% In certain circumstances we will get a divide-by-zero error here
+% unless we guard against it. Use of \cs{@tempcnta} is complicated,
+% sometimes it is assigned globally, sometimes locally. Need to sort
+% it out one of these days [mjd,2000/06/02].
+% \begin{macrocode}
+ \ifnum\@tempcnta>\z@
+ \divide\dimen@\@tempcnta
+ \else \dimen@\z@
+ \fi
+% \end{macrocode}
+% As usual, we check to make sure we don't set \cs{alignsep@}
+% smaller than \cs{minalignsep} and, in any case, that we don't
+% replace \cs{alignsep@} by a larger value.
+% \begin{macrocode}
+ \ifdim\dimen@<\minalignsep\relax
+ \global\alignsep@\minalignsep\relax
+ \dimen@\displaywidth
+ \advance\dimen@-\@tempdima
+ \advance\dimen@-\@tempcntb\alignsep@
+ \global\divide\dimen@\tw@
+ \else
+ \ifdim\dimen@<\alignsep@
+ \global\alignsep@\dimen@
+ \fi
+ \fi
+% \end{macrocode}
+% Next, we calculate an appropriate value of \cs{eqnshift@},
+% assuming that \cs{dimen@} is the desired separation between the
+% tag and equation of the current line. This means that we first
+% need to adjust \cs{dimen@} if we're in an \env{flalign}
+% environment.
+% \begin{macrocode}
+ \ifnum\xatlevel@=\tw@
+ \dimen@\mintagsep\relax
+ \fi
+% \end{macrocode}
+% Now we calculate the value of \cs{eqnshift@} needed to produce a
+% separation of \cs{dimen@} between the equation tag and the
+% beginning of the equation. To do this, we need the following
+% equation to hold:
+% \[
+% \cs{eqnshift@} + n\cs{alignsep@} + \cs{@tempdimb}
+% = \cs{tagwidth@} + \cs{dimen@}
+% \]
+% where $n = \cs{count@}$ is the number of interalign spaces before
+% the first non-empty field of the current line.
+% \begin{macrocode}
+ \advance\dimen@\tagwidth@
+ \advance\dimen@-\@tempdimb
+ \advance\dimen@-\count@\alignsep@
+% \end{macrocode}
+% The value of \cs{eqnshift@} just calculated is the minimum
+% acceptable value; thus, we save it only if it is larger than the
+% current value.
+% \begin{macrocode}
+ \ifdim\dimen@>\eqnshift@
+ \global\eqnshift@\dimen@
+ \fi
+ \fi
+ \fi
+ \endgroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\x@lcalc@width}
+% This macro calculates the ``indentation'' of the current row, as
+% defined above under the description of \cs{x@calc@shift@lc}.
+% This macro is called for each field of the current line, with
+% \cs{@tempa} set to the width of the current field. Ideally, the
+% loop enclosing \cs{x@lcalc@width} would terminate as soon as
+% \cs{@tempa} is non-zero, but that would be a bit tricky to
+% arrange. Instead, we use \cs{@tempdima} as a flag to signal when
+% we've encountered the first non-empty field.
+%
+% \begin{macrocode}
+ \def\x@lcalc@width{%
+ \ifdim\@tempdima = \z@
+% \end{macrocode}
+% If the current field is empty (i.e., $\cs{@tempa} =
+% \mathrm{0\,pt}$, then we increment \cs{@tempdimb} by the width of
+% the current field). Otherwise, we set $\cs{@tempdima} =
+% \mathrm{1\,pt}$ as a signal value and increment \cs{@tempdimb} by
+% the width of whatever empty space there might be at the left of
+% the current field.
+% \begin{macrocode}
+ \ifdim\@tempa > \z@
+ \@tempdima\p@
+ \ifodd\column@
+ \advance\@tempdimb \maxcol@width\column@
+ \advance\@tempdimb-\@tempa
+ \fi
+% \end{macrocode}
+% In addition, we need to adjust the values of \cs{@tempcnta} and
+% \cs{@tempcntb} to account for any empty align structures that
+% might occur at the beginning of the current line. More
+% specifically, we first set \cs{count@} equal to the number of
+% interalign spaces preceding the current field (namely, $\lfloor
+% (\cs{\column@}-1)/2 \rfloor$), and then subtract \cs{count@} from
+% both \cs{@tempcnta} and \cs{@tempcntb}. The rationale is that
+% for the purposes of adjusting the spacing between the tag and the
+% equation, the only flexible interalign spaces are those after
+% the first non-empty align structure, so we need to treat those
+% different from the ones before the first non-empty align
+% structure.
+% \begin{macrocode}
+ \count@\column@
+ \advance\count@\m@ne
+ \divide\count@\tw@
+ \advance\@tempcnta-\count@
+ \advance\@tempcntb-\count@
+ \else
+ \advance\@tempdimb \maxcol@width\column@\relax
+ \fi
+ \fi
+ }
+\fi\fi
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\place@tag}
+% \cs{place@tag} takes care of the placment of tags in the
+% \env{align} environments.
+% \begin{macrocode}
+\def\place@tag{%
+ \iftagsleft@
+ \kern-\tagshift@
+ \if1\shift@tag\row@\relax
+ \rlap{\vbox{%
+ \normalbaselines
+ \boxz@
+ \vbox to\lineht@{}%
+ \raise@tag
+ }}%
+ \else
+ \rlap{\boxz@}%
+ \fi
+ \kern\displaywidth@
+ \else
+ \kern-\tagshift@
+ \if1\shift@tag\row@\relax
+% \end{macrocode}
+% Added depth to correct vertical spacing of shifted
+% equation tags.---dmj, 1994/12/29
+% \begin{macrocode}
+ \llap{\vtop{%
+ \raise@tag
+ \normalbaselines
+ \setbox\@ne\null
+ \dp\@ne\lineht@
+ \box\@ne
+ \boxz@
+ }}%
+ \else
+ \llap{\boxz@}%
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\align@preamble}
+% \begin{macrocode}
+\def\align@preamble{%
+ &\hfil
+ \strut@
+ \setboxz@h{\@lign$\m@th\displaystyle{##}$}%
+ \ifmeasuring@\savefieldlength@\fi
+ \set@field
+ \tabskip\z@skip
+ &\setboxz@h{\@lign$\m@th\displaystyle{{}##}$}%
+ \ifmeasuring@\savefieldlength@\fi
+ \set@field
+ \hfil
+ \tabskip\alignsep@
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\set@field}
+% \cs{set@field} increments the column counter, tracks the value of
+% \cs{lineht@} and finally inserts the box containing the contents
+% of the current field.
+% \begin{macrocode}
+\def\set@field{%
+ \column@plus
+ \iftagsleft@
+ \ifdim\ht\z@>\lineht@
+ \global\lineht@\ht\z@
+ \fi
+ \else
+ \ifdim\dp\z@>\lineht@
+ \global\lineht@\dp\z@
+ \fi
+ \fi
+ \boxz@
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsection {The \env{split} environment}
+%
+% \begin{macro}{\split@err}
+% A special error function for \env{split} to conserve main mem (at a
+% cost of string pool/hash size.
+% \begin{macrocode}
+\edef\split@err#1{%
+ \@nx\@amsmath@err{%
+ \string\begin{split} won't work here%
+ }{%
+ \@xp\@nx\csname
+ Did you forget a preceding \string\begin{equation}?^^J%
+ If not, perhaps the `aligned' environment is what
+ you want.\endcsname}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{environment}{split}
+% If the \env{split} environment occurs inside \env{align} or
+% \env{gather}, it can make use of the enclosing halign; if it is
+% called inside a simple equation, we add an implicit `gather'
+% container.
+%
+% \begin{macrocode}
+\newenvironment{split}{%
+ \if@display
+ \ifinner
+ \@xp\@xp\@xp\split@aligned
+ \else
+ \ifst@rred \else \global\@eqnswtrue \fi
+ \fi
+ \else \let\endsplit\@empty \@xp\collect@body\@xp\split@err
+ \fi
+ \collect@body\gather@split
+}{%
+ \crcr
+ \egroup
+ \egroup
+ \iftagsleft@ \@xp\lendsplit@ \else \@xp\rendsplit@ \fi
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\split@tag\relax % init
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\gather@split#1#2#3{%
+ \@xp\endgroup \reset@equation % math@cr will handle equation numbering
+ \iftag@
+ \toks@\@xp{\df@tag}%
+ \edef\split@tag{%
+ \gdef\@nx\df@tag{\the\toks@}%
+ \global\@nx\tag@true \@nx\nonumber
+ }%
+ \else \let\split@tag\@empty
+ \fi
+ \spread@equation
+% \end{macrocode}
+% The extra vcenter wrapper here is not really a good thing but
+% without it there are compatibility problems with old documents that
+% throw in some extra material between \verb'\begin{equation}' and
+% \verb'\begin{split}' (for example, \verb'\hspace{-1pc}' or
+% \verb'\left\{'). [mjd,1999/09/20]
+% \begin{macrocode}
+ \vcenter\bgroup
+ \gather@{\split@tag \begin{split}#1\end{split}}%
+ \def\endmathdisplay@a{%
+ \math@cr \black@ \totwidth@ \egroup
+ \egroup
+ }%
+}
+% \end{macrocode}
+%
+% \end{environment}
+%
+% \begin{macro}{\insplit@}
+% \begin{macrocode}
+\def\insplit@{%
+ \global\setbox\z@\vbox\bgroup
+ \Let@ \chardef\dspbrk@context\@ne \restore@math@cr
+ \default@tag % disallow use of \tag here
+ \ialign\bgroup
+ \hfil
+ \strut@
+ $\m@th\displaystyle{##}$%
+ &$\m@th\displaystyle{{}##}$%
+ \hfill % Why not \hfil?---dmj, 1994/12/28
+ \crcr
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rendsplit@}
+% Moved the box maneuvers inside the \cs{ifinalign@}, since that is
+% the only place they are needed.---dmj, 1994/12/28
+%
+% TODO: Explore interaction of tag-placement algorithm with
+% \env{split}. Is there any way for \env{split} to pass the
+% relevant information out to the enclosing \env{gather} or
+% \env{align}?
+% \begin{macrocode}
+\def\rendsplit@{%
+ \ifinalign@
+% \end{macrocode}
+% Changed |\box9| into a \cs{vtop} here for better spacing.
+% \begin{macrocode}
+ \global\setbox9 \vtop{%
+ \unvcopy\z@
+ \global\setbox8 \lastbox
+ \unskip
+ }%
+ \setbox\@ne\hbox{%
+ \unhcopy8
+ \unskip
+ \global\setbox\tw@\lastbox
+ \unskip
+ \global\setbox\thr@@\lastbox
+ }%
+ \ifctagsplit@
+ \gdef\split@{%
+ \hbox to\wd\thr@@{}%
+ &\vcenter{\vbox{\moveleft\wd\thr@@\boxz@}}%
+ }%
+ \else
+ \global\setbox7 \hbox{\unhbox\tw@\unskip}%
+% \end{macrocode}
+% Added \cs{add@amps} to make sure we put the last line of the
+% \env{split} into the proper column of an \env{align} environment
+% with multiple align structures.---dmj, 1994/12/28
+%
+% Special care has to be taken in this case because the \env{split}
+% turns into two lines of the \env{align} instead of just one. So,
+% we have to make sure that the first line produced by the
+% \env{split} doesn't upset our bookkeeping, hence we call
+% \cs{savetaglength@} to insert 0\,pt as the tag for this
+% pseudo-line, and we advance the \cs{row@} counter and reset
+% \cs{lineht@} afterwards. It would be nice if we could just
+% replace the \cs{crcr} by \cs{math@cr@@@}, but that would cause
+% problems with the tag processing.
+% \begin{macrocode}
+ \gdef\split@{%
+ \global\@tempcnta\column@
+ &\setboxz@h{}%
+ \savetaglength@
+ \global\advance\row@\@ne
+ \vbox{\moveleft\wd\thr@@\box9}%
+ \crcr
+ \noalign{\global\lineht@\z@}%
+ \add@amps\@tempcnta
+ \box\thr@@
+ &\box7
+ }%
+ \fi
+ \else
+ \ifctagsplit@
+ \gdef\split@{\vcenter{\boxz@}}%
+ \else
+% \end{macrocode}
+% Changed to just \cs{boxz@}, otherwise last line gets centered
+% rather than aligned properly with respect to the rest of the
+% lines. But this means that we can't see inside of the last line
+% to decide whether the tag needs to be moved. Will have to think
+% about this.---dmj, 1994/12/28
+% \begin{macrocode}
+ \gdef\split@{%
+ \boxz@
+% \box9
+% \crcr
+% \hbox{\box\thr@@\box7}%
+ }%
+ \fi
+ \fi
+ \aftergroup\split@
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\lendsplit@}
+% \begin{macrocode}
+\def\lendsplit@{%
+ \global\setbox9\vtop{\unvcopy\z@}%
+ \ifinalign@
+% \end{macrocode}
+% Moved following two boxes inside the \cs{ifinalign@}, since they
+% are only used in that case. In fact, if we just kept track of
+% the width of the first column, we could dispense with this
+% entirely. Surely that would be more efficient than all these box
+% copies.---dmj, 1994/12/28
+% \begin{macrocode}
+ \setbox\@ne\vbox{%
+ \unvcopy\z@
+ \global\setbox8\lastbox
+ }%
+ \setbox\@ne\hbox{%
+ \unhcopy8%
+ \unskip
+ \setbox\tw@\lastbox
+ \unskip
+ \global\setbox\thr@@\lastbox
+ }%
+ \ifctagsplit@
+ \gdef\split@{%
+ \hbox to\wd\thr@@{}%
+ &\vcenter{\vbox{\moveleft\wd\thr@@\box9}}%
+ }%
+ \else
+ \gdef\split@{%
+ \hbox to\wd\thr@@{}%
+ &\vbox{\moveleft\wd\thr@@\box9}%
+ }%
+ \fi
+ \else
+ \ifctagsplit@
+ \gdef\split@{\vcenter{\box9}}%
+ \else
+ \gdef\split@{\box9}%
+ \fi
+ \fi
+ \aftergroup\split@
+}
+% \end{macrocode}
+% \end{macro}
+%
+% With \pkg{amsmath} 1.2 it was possible to put things like
+% \verb'\left\{' between \verb'\begin{equation}' and
+% \verb'\begin{split}' without getting any error message. For
+% backward compatibility we try to avoid a fatal error in this case
+% and instead attempt recovery with \env{aligned}.
+% \begin{macrocode}
+\def\split@aligned#1#2{%
+ \iffalse{\fi\ifnum0=`}\fi
+ \collect@body\split@al@a}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\split@al@a#1#2#3{%
+ \split@warning
+ \endgroup
+% \end{macrocode}
+% If the \opt{fleqn} and \opt{tbtags} options are both in effect then
+% we will need to add an optional argument on the \env{aligned}
+% environment.
+% \begin{macrocode}
+ \toks@{\begin{aligned}}%
+ \if@fleqn \split@al@tagcheck \fi
+% \end{macrocode}
+% The \cs{relax} here is to prevent \cs{@let@token} from being left
+% equal to an ampersand if that happens to be the first thing in the body.
+% \begin{macrocode}
+ \the\toks@\relax#1\end{aligned}%
+ \ifnum0=`{\fi\iffalse}\fi
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\split@al@tagcheck{%
+ \ifctagsplit@
+ \else
+ \iftagsleft@ \toks@\@xp{\the\toks@ [t]}%
+ \else \toks@\@xp{\the\toks@ [b]}%
+ \fi
+ \fi
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\split@warning{%
+ \PackageWarning{amsmath}{%
+Cannot use `split' here;\MessageBreak trying to recover with `aligned'}%
+}
+% \end{macrocode}
+%
+% \subsection{The \env{multline} environment}
+%
+% In the original \amstex/, \cn{multlinegap} is a macro with an
+% argument that resets an internal dimension (one with an \qc{\@}
+% character in its name). Here, to save control sequence names, we
+% define \cn{multlinegap} to be the dimension itself and the
+% documentation instructs users to use \cn{setlength} if they
+% need to change it.
+% \begin{macro}{\multlinegap}
+% \begin{macro}{\multlinetaggap}
+% Changed \cs{multlinegap} and \cs{multlinetaggap} to skip
+% registers. Also changed name to \cs{multlinetaggap} from
+% \cs{multlinetaggap@}.
+% \begin{macrocode}
+\newskip\multlinegap
+\multlinegap10pt
+\newskip\multlinetaggap
+\multlinetaggap10pt
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\start@multline}
+% \begin{macrocode}
+\def\start@multline#1{%
+ \RIfM@
+ \nomath@env
+ \DN@{\@namedef{end\@currenvir}{}\@gobble}%
+ \else
+ $$%
+ #1%
+ \ifst@rred
+ \nonumber
+ \else
+ \global\@eqnswtrue
+ \fi
+ \let\next@\multline@
+ \fi
+ \collect@body\next@
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{environment}{multline}
+% \begin{environment}{multline*}
+% \begin{macrocode}
+\newenvironment{multline}{%
+ \start@multline\st@rredfalse
+}{%
+ \iftagsleft@ \@xp\lendmultline@ \else \@xp\rendmultline@ \fi
+ \ignorespacesafterend
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newenvironment{multline*}{\start@multline\st@rredtrue}{\endmultline}
+% \end{macrocode}
+% \end{environment}
+% \end{environment}
+%
+% \begin{macro}{\multline@}
+% \begin{macrocode}
+\def\multline@#1{%
+ \Let@
+% \end{macrocode}
+%
+% For multline neither \cs{displ@y} no \cs{displ@y@} is quite right;
+% we want to advance the row number and (I suppose?) the
+% display-pagebreak level, but we only want to do tag-related stuff
+% once before the first line, not repeat it for every line. (Recall
+% that the arg of \cs{@display@init} goes into \cs{everycr}.)
+% \begin{macrocode}
+ \@display@init{\global\advance\row@\@ne \global\dspbrk@lvl\m@ne}%
+ \chardef\dspbrk@context\z@
+ \restore@math@cr
+% \end{macrocode}
+% The \env{multline} environment is somewhat unusual, in that
+% \cs{tag} and \cs{label} are enabled only during the measuring
+% phase and disabled during the production phase.
+% Here we disable \cs{tag} and \cs{label}; \cs{mmeasure@} will
+% re-enable them temporarily.
+% \begin{macrocode}
+ \let\tag\tag@in@align
+ \global\tag@false \global\let\raise@tag\@empty
+ \mmeasure@{#1}%
+ \let\tag\gobble@tag \let\label\@gobble
+ \tabskip \if@fleqn \@mathmargin \else \z@skip \fi
+ \totwidth@\displaywidth
+ \if@fleqn
+ \advance\totwidth@-\@mathmargin
+ \fi
+ \halign\bgroup
+ \hbox to\totwidth@{%
+% \end{macrocode}
+% In order to get the spacing of the last line right in fleqn
+% mode, we need to play a little game here. Normally the
+% stretchability of the \cs{hskip} here will be suppressed by the
+% \cs{hfil} at the end of the template, except inside the last line,
+% when that \cs{hfil} will be removed by the \cs{hfilneg} in
+% \cs{lendmultline@}.
+% \begin{macrocode}
+ \if@fleqn
+ \hskip \@centering \relax
+ \else
+ \hfil
+ \fi
+ \strut@
+ $\m@th\displaystyle{}##\endmultline@math
+ \hfil
+ }%
+ \crcr
+% \end{macrocode}
+% In \opt{fleqn} mode, it's the \cs{tabskip} of \cs{@mathmargin}
+% that needs to be removed in the first line, not the \cs{hfil} at
+% the beginning of the template.
+% \begin{macrocode}
+ \if@fleqn
+ \hskip-\@mathmargin
+ \def\multline@indent{\hskip\@mathmargin}% put it back
+ \else
+ \hfilneg
+ \def\multline@indent{\hskip\multlinegap}%
+ \fi
+ \iftagsleft@
+ \iftag@
+ \begingroup
+ \ifshifttag@
+ \rlap{\vbox{%
+ \normalbaselines
+ \hbox{%
+ \strut@
+ \make@display@tag
+ }%
+ \vbox to\lineht@{}%
+ \raise@tag
+ }}%
+% \end{macrocode}
+% If the equation tag doesn't fit on the same line with the first
+% line of the display, we'll indent the first line by
+% \cn{multlinegap}. This is a change from \pkg{amstex}, where the
+% first line would have been flush against the left margin in this
+% case. A corresponding change will be made in \cs{rendmultline@}.
+% \begin{macrocode}
+ \multline@indent
+ \else
+ \setbox\z@\hbox{\make@display@tag}%
+ \dimen@\@mathmargin \advance\dimen@-\wd\z@
+ \ifdim\dimen@<\multlinetaggap
+ \dimen@\multlinetaggap
+ \fi
+ \box\z@ \hskip\dimen@\relax
+ \fi
+ \endgroup
+ \else
+ \multline@indent
+ \fi
+ \else
+ \multline@indent
+ \fi
+ #1%
+}
+% \end{macrocode}
+%
+% An extra level of indirection for the closing \verb'$' in multline
+% allows us to avoid getting an extra thinmuskip from a final
+% mathpunct in the equation contents, when equation numbers are on
+% the right. If we did not use this workaround, the sequence of
+% elements for a final comma would be, e.g.,
+% \begin{verbatim}
+% ... ,<hskip><box containing equation number>
+% \end{verbatim}
+% which is equivalent to a sequence \verb'<mathpunct><mathord>' as
+% far as the automatic math spacing is concerned.
+% \begin{macrocode}
+\def\endmultline@math{$}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\lendmultline@}
+% Bug fix: changed \cs{crcr} to \cs{math@cr} so that \cs{@eqpen}
+% gets reset properly if \cs{displaybreak} is used on the
+% penultimate line of an \env{align}.
+% \begin{macrocode}
+\def\lendmultline@{%
+ \hfilneg
+ \hskip\multlinegap
+ \math@cr
+ \egroup
+ $$%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rendmultline@}
+% \begin{macrocode}
+\def\rendmultline@{%
+ \iftag@
+ $\let\endmultline@math\relax
+ \ifshifttag@
+ \hskip\multlinegap
+% \end{macrocode}
+% Added depth to correct vertical spacing of shifted equation
+% tags.---dmj, 1994/12/29
+% \begin{macrocode}
+ \llap{\vtop{%
+ \raise@tag
+ \normalbaselines
+ \setbox\@ne\null
+ \dp\@ne\lineht@
+ \box\@ne
+ \hbox{\strut@\make@display@tag}%
+ }}%
+ \else
+ \hskip\multlinetaggap
+ \make@display@tag
+ \fi
+ \else
+ \hskip\multlinegap
+ \fi
+ \hfilneg
+% \end{macrocode}
+% Use \cs{math@cr} rather than just \cs{crcr} so that \cs{@eqpen}
+% gets reset properly if \cs{displaybreak} is used.
+% \begin{macrocode}
+ \math@cr
+ \egroup$$%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\mmeasure@}
+% \begin{macrocode}
+\def\mmeasure@#1{%
+ \begingroup
+ \measuring@true
+% \end{macrocode}
+% We use \cs{begin/endgroup} rather than |{}| in this definition of
+% \cn{label} because the latter would create an extra (wasteful of
+% main mem) null box in the current math list. [mjd, 1995/01/17]
+% \begin{macrocode}
+ \def\label##1{%
+ \begingroup\measuring@false\label@in@display{##1}\endgroup}%
+ \def\math@cr@@@{\cr}%
+ \let\shoveleft\@iden \let\shoveright\@iden
+ \savecounters@
+ \global\row@\z@
+ \setbox\@ne\vbox{%
+ \global\let\df@tag\@empty
+ \halign{%
+ \setboxz@h{\@lign$\m@th\displaystyle{}##$}%
+ \iftagsleft@
+ \ifnum\row@=\@ne
+ \global\totwidth@\wdz@
+ \global\lineht@\ht\z@
+ \fi
+ \else
+ \global\totwidth@\wdz@
+ \global\lineht@\dp\z@
+ \fi
+ \crcr
+ #1%
+ \crcr
+ }%
+ }%
+ \ifx\df@tag\@empty\else\global\tag@true\fi
+ \if@eqnsw\global\tag@true\fi
+ \iftag@
+ \setboxz@h{%
+ \if@eqnsw
+ \stepcounter{equation}%
+ \tagform@\theequation
+ \else
+ \df@tag
+ \fi
+ }%
+ \global\tagwidth@\wdz@
+ \dimen@\totwidth@
+ \advance\dimen@\tagwidth@
+ \advance\dimen@\multlinetaggap
+ \iftagsleft@\else
+ \if@fleqn
+ \advance\dimen@\@mathmargin
+ \fi
+ \fi
+ \ifdim\dimen@>\displaywidth
+ \global\shifttag@true
+ \else
+ \global\shifttag@false
+ \fi
+ \fi
+ \restorecounters@
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\shoveleft}
+% \begin{macro}{\shoveright}
+% \cs{shoveleft} and \cs{shoveright} need to do slightly different
+% things depending on whether tags are on the left or the right and
+% whether we're in \opt{fleqn} mode. For compactness of code, we
+% make the appropriate decisions at ``compile'' time rather than at
+% load time.
+%
+% TODO: Investigate making \cs{shoveright} behave ``properly''(?) if
+% used on the first line of a \env{multline} and make \cs{shoveleft}
+% behave properly if used on the last line of a \env{multline}. But
+% in his \fn{amstex.doc} Spivak indicates those commands should never
+% be used on a first or last line. Perhaps better to leave the
+% question open unless/until real-life examples turn up.
+% \begin{macrocode}
+\iftagsleft@
+ \def\shoveright#1{%
+ #1%
+ \hfilneg
+ \hskip\multlinegap
+ }
+\else
+ \def\shoveright#1{%
+ #1%
+ \hfilneg
+ \iftag@
+ \ifshifttag@
+ \hskip\multlinegap
+ \else
+ \hskip\tagwidth@
+ \hskip\multlinetaggap
+ \fi
+ \else
+ \hskip\multlinegap
+ \fi
+ }
+\fi
+
+\if@fleqn
+ \def\shoveleft#1{#1}%
+\else
+ \iftagsleft@
+ \def\shoveleft#1{%
+ \setboxz@h{$\m@th\displaystyle{}#1$}%
+ \setbox\@ne\hbox{$\m@th\displaystyle#1$}%
+ \hfilneg
+ \iftag@
+ \ifshifttag@
+ \hskip\multlinegap
+ \else
+ \hskip\tagwidth@
+ \hskip\multlinetaggap
+ \fi
+ \else
+ \hskip\multlinegap
+ \fi
+ \hskip.5\wd\@ne
+ \hskip-.5\wdz@
+ #1%
+ }
+ \else
+ \def\shoveleft#1{%
+ \setboxz@h{$\m@th\displaystyle{}#1$}%
+ \setbox\@ne\hbox{$\m@th\displaystyle#1$}%
+ \hfilneg
+ \hskip\multlinegap
+ \hskip.5\wd\@ne
+ \hskip-.5\wdz@
+ #1%
+ }
+ \fi
+\fi
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{The \env{equation} environment}
+%
+% Rewritten from the ground up for version 2.0 to fix no-shrink and
+% no-shortskips bugs [mjd,2000/01/06].
+%
+% Standard \latex/ provides three environments for one-line equations:
+% \cn{[}\cn{]}, \env{equation}, and \env{displaymath}. We add
+% \env{equation*} as a synonym for \env{displaymath}.
+% \begin{macrocode}
+\@saveprimitive\leqno\@@leqno
+\@saveprimitive\eqno\@@eqno
+\def\eqno{\@@eqno\let\eqno\relax\let\leqno\relax}
+\def\leqno{\@@leqno\let\leqno\relax\let\eqno\relax}
+%
+\let\veqno=\@@eqno
+\iftagsleft@ \let\veqno=\@@leqno \fi
+% \end{macrocode}
+%
+% Support for the \pkg{showkeys} package: provide no-op definitions
+% for a couple of SK functions, if they are not already defined. Then
+% we can just call them directly in our code without any extra fuss.
+% If the \pkg{showkeys} package is loaded later, our trivial
+% definitions will get overridden and everything works fine.
+% \begin{macrocode}
+\@ifundefined{SK@@label}{%
+ \let\SK@@label\relax \let\SK@equationtrue\relax
+}{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\reset@equation\@empty
+% \end{macrocode}
+%
+% Cf \cs{tag@in@align}. This is a bit of a mess though. Could use
+% some work. [mjd,1999/12/21]
+% \begin{macrocode}
+\let\alt@tag\@empty
+\def\tag@in@display#1#{\relax\tag@in@display@a{#1}}
+\def\tag@in@display@a#1#2{%
+ \iftag@
+ \invalid@tag{Multiple \string\tag}\relax
+ \else
+ \global\tag@true \nonumber \reset@equation \st@rredtrue
+ \if *\string#1%
+ \gdef\alt@tag{\def\SK@tagform@{#2\@gobble}%
+ \ifx\SK@@label\relax \let\tagform@\SK@tagform@ \fi
+ }%
+ \make@df@tag@@{#2}%
+ \else
+ \make@df@tag@@@{#2}%
+ \fi
+ \fi
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\restore@hfuzz\@empty
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\mathdisplay#1{%
+ \ifmmode \@badmath
+ \else
+ $$\def\@currenvir{#1}%
+% \end{macrocode}
+% Allow use of \cn{displaybreak}.
+% \begin{macrocode}
+ \let\dspbrk@context\z@
+% \end{macrocode}
+% Although in some cases simpler label handling would seem to be
+% sufficient, always using \cs{label@in@display} makes it easier to
+% support the \pkg{showkeys} package.
+% \begin{macrocode}
+ \let\tag\tag@in@display \let\label\label@in@display \SK@equationtrue
+ \global\let\df@label\@empty \global\let\df@tag\@empty
+ \global\tag@false
+ \let\mathdisplay@push\mathdisplay@@push
+ \let\mathdisplay@pop\mathdisplay@@pop
+ \if@fleqn
+% \end{macrocode}
+% Turn off overfull box messages temporarily\mdash otherwise there
+% would be unwanted extra ones emitted during our measuring
+% operations.
+% \begin{macrocode}
+ \edef\restore@hfuzz{\hfuzz\the\hfuzz\relax}%
+ \hfuzz\maxdimen
+% \end{macrocode}
+% Initially set the equation body in a box of displaywidth. Then if
+% the box is not overfull, as we find by checking \cs{badness}, we
+% have acquired useful information for the subsequent processing.
+% \begin{macrocode}
+ \setbox\z@\hbox to\displaywidth\bgroup
+ \let\split@warning\relax \restore@hfuzz
+ \everymath\@emptytoks \m@th $\displaystyle
+ \fi
+ \fi
+}
+% \end{macrocode}
+%
+% Arg 1 is not currently used. I thought it might come in handy for
+% error messages.
+% \begin{macrocode}
+\def\endmathdisplay#1{%
+ \ifmmode \else \@badmath \fi
+ \endmathdisplay@a
+ $$%
+% \end{macrocode}
+% I guess the following code means this structure is non-reentrant.
+% But there is plenty of scope for tricky bugs here; suppressing them
+% by brute force at least makes it possible to get things working
+% correctly for normal use. [mjd,2000/01/06]
+% \begin{macrocode}
+ \global\let\df@label\@empty \global\let\df@tag\@empty
+ \global\tag@false \global\let\alt@tag\@empty
+ \global\@eqnswfalse
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\endmathdisplay@a{%
+ \if@eqnsw \gdef\df@tag{\tagform@\theequation}\fi
+ \if@fleqn \@xp\endmathdisplay@fleqn
+ \else \ifx\df@tag\@empty \else \veqno \alt@tag \df@tag \fi
+ \ifx\df@label\@empty \else \@xp\ltx@label\@xp{\df@label}\fi
+ \fi
+ \ifnum\dspbrk@lvl>\m@ne
+ \postdisplaypenalty -\@getpen\dspbrk@lvl
+ \global\dspbrk@lvl\m@ne
+ \fi
+}
+% \end{macrocode}
+%
+% A boolean variable: Was that last box overfull or not? A value of 0
+% means yes, it was overfull.
+% \begin{macrocode}
+\let\too@wide\@ne
+% \end{macrocode}
+%
+% Special handling is needed for flush-left equations. We need to
+% measure the equation body (found in box 0 after we close it with
+% the \cs{egroup}). Then after a fairly normal test to see if it fits
+% within the available space, we need to consider overlapping into
+% the displayindent area if displayindent is nonzero (as in an
+% indented list). If there is an equation number we may have to shift
+% it by hand to a separate line when there is not enough room;
+% we can no longer take advantage of the automatic shifting provided
+% by the \cn{leqno}, \cn{eqno} primitives.
+%
+% We initially add \cs{@mathmargin} glue at the end of box 0 to get
+% an accurate overfull test. If \cs{@mathmargin} contains any shrink
+% then we cannot reliably tell whether the box will be overfull or
+% not simply by doing hand calculations from the actual width of the
+% equation body. We have to actually set the box and find out what
+% happens.
+%
+% On the other hand if we put the \cs{@mathmargin} glue at the
+% beginning of the box it's awkward to remove it afterwards. So we
+% first put it in at the end and later we will move it to the
+% beginning as needed.
+%
+% \begin{macrocode}
+\def\endmathdisplay@fleqn{%
+ $\hfil\hskip\@mathmargin\egroup
+% \end{macrocode}
+% We need to save the information about whether box 0 was overfull in
+% a variable, otherwise it will disappear in the next setbox
+% operation. And we couldn't set the equation number box earlier than
+% now, because the body of the equation might have contained a
+% \cs{tag} command (well, it could have been done, but this way
+% we can reuse the tag-handling code from elsewhere).
+% \begin{macrocode}
+ \ifnum\badness<\inf@bad \let\too@wide\@ne \else \let\too@wide\z@ \fi
+ \ifx\@empty\df@tag
+ \else
+ \setbox4\hbox{\df@tag
+ \ifx\df@label\@empty \else \@xp\ltx@label\@xp{\df@label}\fi
+ }%
+ \fi
+ \csname emdf@%
+ \ifx\df@tag\@empty U\else \iftagsleft@ L\else R\fi\fi
+ \endcsname
+}
+% \end{macrocode}
+%
+% For an unnumbered flush-left equation we hope first that the
+% the contents fit within displaywidth. If not we need to fall back
+% on a more complicated reboxing operation.
+% \begin{macrocode}
+\def\emdf@U{%
+ \restore@hfuzz
+ \ifodd\too@wide % not too wide: just need to swap the glue around
+ \hbox to\displaywidth{\hskip\@mathmargin\unhbox\z@\unskip}%
+ \else % M+B > displaywidth
+ \emdf@Ua
+ \fi
+}
+% \end{macrocode}
+%
+% Some notation: $M$ \cs{@mathmargin}, $B$ the width of the equation
+% body, $I$ \cs{displayindent}, $D$ \cs{displaywidth}, $N$ the width
+% of the equation number (aka the tag), $S$ \cs{mintagsep}, $C$
+% \cs{columnwidth}. If $M+B > \mbox{displaywidth}$, and if we assume
+% $M$ contains shrink, then the only solution left is to encroach
+% into the displayindent space.
+% \begin{macrocode}
+\def\emdf@Ua{%
+ \hbox to\columnwidth{%
+ \ifdim\displayindent>\z@
+ \hskip\displayindent minus\displayindent
+ \fi
+ \hskip\@mathmargin \unhbox\z@ \unskip
+ }%
+ \displayindent\z@ \displaywidth\columnwidth
+}
+% \end{macrocode}
+%
+% Find out first if the tag fits in ideal position. If so we can just
+% plunk down box 2. Otherwise we need to do something more complicated.
+% \begin{macrocode}
+\def\emdf@R{%
+ \setbox\tw@\hbox to\displaywidth{%
+ \hskip\@mathmargin \unhcopy\z@\unskip\hfil\hskip\mintagsep\copy4
+ }%
+ \restore@hfuzz
+ \ifnum\badness<\inf@bad \box\tw@ \else \emdf@Ra \fi
+}
+% \end{macrocode}
+%
+% We shift the equation number to line 2 if it does not fit within
+% \cs{displaywidth}. Note that we do not first attempt to let the
+% equation body shift leftward into the \cs{displayindent} space. If
+% that is desired it will have to be done by hand by adding negative
+% space at the beginning of the equation body. I don't expect this to
+% arise very often in practice since most of the time
+% \cs{displayindent} is zero anyway.
+% \begin{macrocode}
+\def\emdf@Ra{%
+ \skip@\displayindent minus\displayindent
+ \displayindent\z@ \displaywidth\columnwidth
+ \spread@equation \everycr{}\tabskip\z@skip
+ \halign{\hbox to\displaywidth{##}\cr
+ \relax
+ \ifdim\skip@>\z@ \hskip\skip@ \fi
+ \hskip\@mathmargin\unhbox\z@\unskip\hfil\cr
+ \noalign{\raise@tag}%
+ \hfil\box4 \cr}%
+}
+% \end{macrocode}
+%
+% Find out first if the tag fits in ideal position. If so we can just
+% plunk down box 2. Otherwise we need to do something more
+% complicated.
+% \begin{macrocode}
+\def\emdf@L{%
+% \end{macrocode}
+% Calculate the difference between $M$ and $N+S$. If the latter is
+% greater, we don't want to add any extra glue between the number and
+% the equation body. Otherwise the amount that we want to add is
+% \verb'x minus x' where $x=M-(N+S)$. I.e., the distribution of
+% spaces across the line is $N,S,x minus x,B,hfil$.
+% \begin{macrocode}
+ \@tempdima\@mathmargin
+ \advance\@tempdima-\wd4 \advance\@tempdima-\mintagsep
+ \skip@\@tempdima minus\@tempdima
+ \setbox\tw@\hbox to\displaywidth{%
+ \copy4\hskip\mintagsep
+ \ifdim\skip@>\z@ \hskip\skip@\fi
+ \unhcopy\z@\unskip
+ }%
+ \restore@hfuzz
+ \ifnum\badness<\inf@bad \box\tw@ \else \emdf@La \fi
+}
+% \end{macrocode}
+%
+% If the equation body and equation number will not fit on the same
+% line, we put the number on line 1 and the body on line 2, with the
+% body positioned as for an unnumbered equation.
+% \begin{macrocode}
+\def\emdf@La{%
+ \spread@equation \everycr{}\tabskip\z@skip
+ \halign{\hbox to\displaywidth{##}\cr
+ \box4 \hfil \cr
+ \noalign{\raise@tag}%
+ \hskip\@mathmargin\unhbox\z@\unskip\hfil\cr}%
+}
+% \end{macrocode}
+%
+% If someone has \verb'\[ \]' nested inside a minipage environment
+% nested inside a numbered equation, the mathdisplay variables that
+% are global will get out of whack unless we take extra care. So we
+% make a stack and push all the variables before entering mathdisplay
+% and pop them afterwards. But we can save a little work by not doing
+% this at the top level, only at inner levels.
+% \begin{macrocode}
+\newtoks\mathdisplay@stack
+\let\mathdisplay@push\@empty
+\def\mathdisplay@@push{%
+ \begingroup
+ \toks@\@xp{\df@label}\@temptokena\@xp{\df@tag}%
+ \toks8\@xp{\alt@tag}%
+ \edef\@tempa{%
+ \global\if@eqnsw\@nx\@eqnswtrue\else\@nx\@eqnswfalse\fi
+ \global\iftag@\@nx\tag@false\else\@nx\tag@true\fi
+ \gdef\@nx\df@label{\the\toks@}\gdef\@nx\df@tag{\the\@temptokena}%
+ \gdef\@nx\alt@tag{\the\toks8}%
+ \global\mathdisplay@stack{\the\mathdisplay@stack}%
+ }%
+ \global\mathdisplay@stack\@xp{\@tempa}
+ \endgroup
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\mathdisplay@pop\@empty
+\def\mathdisplay@@pop{\the\mathdisplay@stack}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\renewenvironment{equation}{%
+ \incr@eqnum
+ \mathdisplay@push
+ \st@rredfalse \global\@eqnswtrue
+ \mathdisplay{equation}%
+}{%
+ \endmathdisplay{equation}%
+ \mathdisplay@pop
+ \ignorespacesafterend
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newenvironment{equation*}{%
+ \mathdisplay@push
+ \st@rredtrue \global\@eqnswfalse
+ \mathdisplay{equation*}%
+}{%
+ \endmathdisplay{equation*}%
+ \mathdisplay@pop
+ \ignorespacesafterend
+}
+% \end{macrocode}
+%
+% Note: \latex/ defines the \env{displaymath} environment in
+% terms of \cn{[} and \cn{]}.
+% \begin{macrocode}
+\DeclareRobustCommand{\[}{\begin{equation*}}
+\DeclareRobustCommand{\]}{\end{equation*}}
+% \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}
+%
+% \section{Credits}
+%
+% Much of the code for the \pkg{amsmath} package had its orgin in
+% \fn{amstex.tex}, written by Michael Spivak. The initial work of
+% porting \fn{amstex.tex} to \fn{amstex.sty} was done in 1988--1989
+% by Frank Mittelbach and Rainer Sch\"opf. In 1994 David M. Jones
+% added the support for the \opt{fleqn} option and did extensive
+% improvements to the \env{align[at]} family of environments and to
+% the equation number handling in general. Michael Downes at the AMS
+% served as coordinator for the efforts of Mittelbach, Sch\"opf, and
+% Jones, and has contributed various bug fixes and additional
+% refinements over time.
+%
+% Versions 1.0 and 1.1 of the package carried the name \pkg{amstex}
+% instead of \pkg{amsmath}, to indicate its origins; the name was
+% changed in 1994 to make it user-oriented rather than
+% history-oriented.
+%
+% \changes{v1.2b}{1995/02/15}{Added kern -alignsep@ to math@cr@@@align}
+% \changes{v1.2b}{1995/02/15}{Modified one piece of measure@}
+% \changes{v1.2b}{1995/02/15}{Cleaned out some obsolete commentary}
+% \changes{v1.2b}{1995/02/15}{Changed kern tagshift@ to kern -tagshift@
+% in the reqno case of place@tag}
+%
+% \changes{v1.2c}{1996/11/01}{Changed `over etc from error to warning}
+%
+% \changes{v1.2d}{1997/03/20}{%
+% Removed dependency on mixed-case fd file names}
+%
+% \CheckSum{6699}
+% \Finale
diff --git a/Master/texmf-dist/source/latex/amslatex/amsmidx.dtx b/Master/texmf-dist/source/latex/amslatex/amsmidx.dtx
new file mode 100644
index 00000000000..3692d6cc76c
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/amsmidx.dtx
@@ -0,0 +1,241 @@
+%%% ====================================================================
+%%% @LaTeX-file{
+%%% filename = "amsmidx.dtx",
+%%% version = "2.01",
+%%% date = "2004/08/03",
+%%% time = "14:45:42 EDT",
+%%% checksum = "63234 241 948 8307",
+%%% author = "American Mathematical Society",
+%%% copyright = "Copyright 1995, 2004 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.",
+%%% address = "American Mathematical Society,
+%%% Technical Support,
+%%% Publications Technical Group,
+%%% 201 Charles Street,
+%%% Providence, RI 02904,
+%%% USA",
+%%% telephone = "401-455-4080 or (in the USA and Canada)
+%%% 800-321-4AMS (321-4267)",
+%%% FAX = "401-331-3842",
+%%% email = "tech-support@ams.org (Internet)",
+%%% codetable = "ISO/ASCII",
+%%% keywords = "latex, amslatex, multiple indexes",
+%%% supported = "yes",
+%%% abstract = "This is part of the AMS-\LaTeX{} distribution.
+%%% It contains code to support the creation and
+%%% typesetting of multiple indexes with AMS-LaTeX{}
+%%% document classes, superseding the single-index
+%%% facilities built into those document classes.
+%%% It also provides a facility to insert a paragraph
+%%% of comments between the title and the index proper",
+%%% 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
+%<*driver>
+\documentclass{amsdtx}
+\begin{document}
+\title{The \pkg{amsmidx} package}
+\author{American Mathematical Society\\Barbara Beeton}
+\date{Version \fileversion, \filedate}
+\hDocInput{amsmidx.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \maketitle
+%
+% \MakeShortVerb\|
+%
+% \section{Introduction}
+%
+% This package provides the facility to produce multiple indexes
+% with \amslatex/ document classes (particularly \fn{amsbook} and
+% the AMS author packages for books), superseding the built-in
+% index facility which can accommodate only one index. This may
+% in the future be incorporated as an option into the \amslatex/
+% document classes.
+%
+% This package is based on \pkg{multind.sty} by F.W. Long.
+%
+% \StopEventually{}
+%
+% Standard file identification.
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}[1995/06/01]
+\ProvidesPackage{amsmidx}[2004/08/03 v2.01 multiple indexes for AMS classes]
+% \end{macrocode}
+%
+% \section{User instructions}
+%
+% In the preamble, invoke \cn{makeindex} with a file name to provide
+% as many indexes as desired:
+%\begin{verbatim}
+% \makeindex{filename-a}
+% \makeindex{filename-b}
+%\end{verbatim}
+% This will initiate the creation of \fn{filename-a.idx} etc.
+%
+% In the body of the text, use the \cn{index} command with two
+% arguments
+%\begin{verbatim}
+% \index{filename-a}{index term}
+%\end{verbatim}
+% as appropriate to populate the \fn{.idx} files.
+%
+% In the \cn{backmatter} segment of the driver file, insert the
+% \cn{Printendex} command to print the indexes; the second argument
+% gives the title to be printed at the top of the index:
+%\begin{verbatim}
+% \Printindex{filename-a}{First Index}
+% \Printindex{filename-b}{Second Index}
+%\end{verbatim}
+%
+% On the first pass, the \fn{.idx} files will be created. Process
+% each \fn{.idx} file with \textit{MakeIndex} to generate an \fn{.ind}
+% file, which will then be read in by \cn{Printindex}. Whenever any
+% page references change, be sure to run \textit{MakeIndex} again,
+% and process the entire job with \latex/ once more to get the correct
+% page references in the indexes.
+%
+% To include a paragraph of comments below the index title, insert
+% the text as an \cn{indexcomment} before the relevant \cn{Printindex}:
+%\begin{verbatim}
+% \indexcomment{Text of comments}
+% \Printindex{...}{...}
+%\end{verbatim}
+% The \cn{indexcomment} text will be cleared after use.
+%
+%
+% \section{Implementation}
+%
+% \begin{macro}{makeindex}
+% Redefine \cn{makeindex} to create a new \fn{.idx} file with the
+% name provided by argument |#1|.
+% \begin{macrocode}
+\renewcommand{\makeindex}[1]{%
+ \begingroup
+ \makeatletter
+ \if@filesw \expandafter\newwrite\csname #1@idxfile\endcsname
+ \expandafter\immediate\openout \csname #1@idxfile\endcsname #1.idx\relax
+ \typeout{Writing index file #1.idx }\fi
+ \endgroup}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{index}
+% Redefine \cn{index} to specify into which file/index the term is
+% to be placed. Argument |#1| identifies the file, |#2| provides
+% the text of the term to be indexed.
+% \begin{macrocode}
+\renewcommand{\index}[1]{%
+ \@bsphack
+ \begingroup
+ \def\protect##1{\string##1\space}\@sanitize\@wrindex{#1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{@wrindex}
+% \cs{@wrindex} checks to make sure that the requested file is available,
+% and writes an entry into the file or emits an error message.
+% \begin{macrocode}
+\renewcommand{\@wrindex}[2]{%
+ \let\thepage\relax
+ \xdef\@gtempa{%
+ \@ifundefined{#1@idxfile}{%
+ \PackageError{\@packagename}{%
+ The requested file, #1@idxfile.idx, does not exist;\MessageBreak
+ index term #2 will not be be written out.%
+ }%
+ }{%
+ \expandafter\write\csname #1@idxfile\endcsname
+ {\string\indexentry{#2}{\thepage}}%
+ }%
+ }%
+ \endgroup\@gtempa
+ \if@nobreak \ifvmode\nobreak\fi\fi
+ \@esphack
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{printindex}
+% \begin{macro}{Printindex}
+% Redefine \cs{printindex} to specify the file to be included; provide
+% an alternate command \cs{Printindex} that specifies both the file and
+% the index title to be printed. Argument |#1| identifies the file,
+% |#2| provides the title. Also modify some formatting commands to
+% improve the appearance of index entries, especially long ones in
+% the presence of three index levels.
+% \begin{macrocode}
+\renewcommand{\printindex}[1]{\@input{#1.ind}}
+\newcommand{\Printindex}[2]{%
+ \begingroup
+ \cleardoublepage
+ \def\indexname{#2}%
+ \raggedright
+ \hyphenpenalty=10000
+ \renewcommand{\seename}{see~also}
+ \renewcommand{\subitem}{\par\hangindent 3em\hspace*{1em}}
+ \@input{#1.ind}%
+ \endgroup
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{indexcomment}
+% \begin{macro}{indexchap}
+% Format comments in a block somewhat narrower than the full page
+% width, and redefine \cn{indexchap} to insert the block below the
+% title, before starting the two-column index. Clear out
+% \cs{indexcomment} after use.
+% \begin{macrocode}
+\newdimen\@indexcommentwidth
+\@indexcommentwidth=\textwidth
+\ifdim\@indexcommentwidth > 26pc
+ \advance\@indexcommentwidth-6pc
+\else
+ \advance\@indexcommentwidth-4pc
+\fi
+\newcommand{\indexcomment}[1]{%
+ \def\theindexcomment{%
+ \vskip\baselineskip
+ \parbox[t]{\@indexcommentwidth}{\normalsize\mdseries#1}%
+ }%
+ }
+\let\theindexcomment\@empty
+\renewcommand{\indexchap}[1]{%
+ \global\topskip 7.5pc\relax
+ \twocolumn[\fontsize{\@xivpt}{18}%
+ \vskip\topskip\vskip-\baselineskip\hbox{}% adjust top space
+ \bfseries\centering #1\par
+ \ifx\theindexcomment\@empty
+ \else \theindexcomment
+ \global\let\theindexcomment\@empty
+ \fi
+ ]%
+ \global\topskip 34\p@
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% 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}
+%
+% \CheckSum{131}
+% \Finale
diff --git a/Master/texmf-dist/source/latex/amslatex/amsopn.dtx b/Master/texmf-dist/source/latex/amslatex/amsopn.dtx
new file mode 100644
index 00000000000..fd60965d788
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/amsopn.dtx
@@ -0,0 +1,254 @@
+%%% ====================================================================
+%%% @LaTeX-file{
+%%% filename = "amsopn.dtx",
+%%% version = "2.01",
+%%% date = "1999/12/14",
+%%% time = "17:30:59 EST",
+%%% checksum = "46904 254 1037 9431",
+%%% author = "American Mathematical Society",
+%%% copyright = "Copyright 1995, 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.",
+%%% 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",
+%%% email = "tech-support@ams.org (Internet)",
+%%% codetable = "ISO/ASCII",
+%%% keywords = "operator name, amsopn, DeclareMathOperator",
+%%% supported = "yes",
+%%% abstract = "This is a \LaTeX{} package that provides a
+%%% DeclareMathOperator command for defining named
+%%% operators like sin and lim.",
+%%% 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
+%<*driver>
+\documentclass{amsdtx}
+\begin{document}
+\title{The \pkg{amsopn} package}
+\author{Michael Downes}
+\date{Version \fileversion, \filedate}
+\hDocInput{amsopn.dtx}
+\end{document}
+%</driver>
+%\fi
+%
+% \maketitle
+%
+% \MakeShortVerb\|
+%
+% \section{Introduction}
+%
+% The \pkg{amsopn} package provides a command
+% \cn{DeclareMathOperator} for defining new `math operator names'
+% similar to the standard function names \cn{sin}, \cn{lim},
+% \cn{max}, etc.
+%
+% \StopEventually{}
+%
+% Standard file identification.
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
+[1994/12/01]% LaTeX date must December 1994 or later
+\ProvidesPackage{amsopn}[1999/12/14 v2.01 operator names]
+% \end{macrocode}
+%
+% What \cs{nolimits@} does is keep a \cn{limits} typed by the user
+% from having any effect. This is used for operatornames whose
+% standard usage is never to have limits.
+% \begin{macrocode}
+\def\nolimits@{\@ifnextchar\limits{\nolimits\@gobble}{\nolimits}}
+% \end{macrocode}
+%
+% In operator names, it is sometimes desired to have text-mode
+% punctuation characters such as |*-/:'|.
+% Because the body of an
+% operator name is set in math mode, these few punctuation
+% characters will not come out right (wrong symbol/and or wrong
+% spacing). The purpose of \cs{newmcodes@} is to make them act like
+% their normal text versions.
+%
+% Where practical, we use decimal numbers to cut down main mem
+% usage (\qc{\"} not needed).
+% \begin{macrocode}
+\begingroup \catcode`\"=12
+\gdef\newmcodes@{\mathcode`\'39\mathcode`\*42\mathcode`\."613A%
+% \end{macrocode}
+% Define \cs{std@minus} for \cs{relbar} use; otherwise there are
+% problems with arrows constructed with relbar.
+% \begin{macrocode}
+ \ifnum\mathcode`\-=45 \else
+ \mathchardef\std@minus\mathcode`\-\relax
+ \fi
+ \mathcode`\-45\mathcode`\/47\mathcode`\:"603A\relax}
+\endgroup
+% \end{macrocode}
+%
+% The command \cs{operatorname} prints its argument as a `math
+% operator' like \cs{sin} or \cs{det}, with proper font and spacing.
+% \begin{macrocode}
+\DeclareRobustCommand{\operatorname}{%
+ \@ifstar{\qopname\newmcodes@ m}%
+ {\qopname\newmcodes@ o}}%
+% \end{macrocode}
+% In the interior of the \cs{mathop} we need a null object (we choose
+% a zero kern for minimum waste of main mem) in order to guard
+% against the case where \arg{3} is a single letter; \tex/ will seize
+% it and center it on the math axis if there is nothing else inside
+% the \cs{mathop} atom.
+% \begin{macrocode}
+\DeclareRobustCommand{\qopname}[3]{%
+ \mathop{#1\kern\z@\operator@font#3}%
+ \csname n#2limits@\endcsname}
+% \end{macrocode}
+%
+% \begin{macro}{\DeclareMathOperator}
+% The command \cn{DeclareMathOperator} defines the first argument to
+% be an operator name whose text is the second argument. The star
+% form means that the operator name should take limits (like \cn{max}
+% or \cn{lim}).
+% \begin{macrocode}
+\newcommand{\DeclareMathOperator}{%
+ \@ifstar{\@declmathop m}{\@declmathop o}}
+% \end{macrocode}
+% \end{macro}
+%
+% In the basic set of operator names (below) we did not use
+% \cn{DeclareRobustCommand} because of the hash table cost. But we
+% use it here to minimize the chances of trouble, since we are
+% producing a user-defined command.
+% \begin{macrocode}
+\long\def\@declmathop#1#2#3{%
+ \@ifdefinable{#2}{%
+ \DeclareRobustCommand{#2}{\qopname\newmcodes@#1{#3}}}}
+%
+\@onlypreamble\DeclareMathOperator
+\@onlypreamble\@declmathop
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\arccos{\qopname\relax o{arccos}}
+\def\arcsin{\qopname\relax o{arcsin}}
+\def\arctan{\qopname\relax o{arctan}}
+\def\arg{\qopname\relax o{arg}}
+\def\cos{\qopname\relax o{cos}}
+\def\cosh{\qopname\relax o{cosh}}
+\def\cot{\qopname\relax o{cot}}
+\def\coth{\qopname\relax o{coth}}
+\def\csc{\qopname\relax o{csc}}
+\def\deg{\qopname\relax o{deg}}
+\def\det{\qopname\relax m{det}}
+\def\dim{\qopname\relax o{dim}}
+\def\exp{\qopname\relax o{exp}}
+\def\gcd{\qopname\relax m{gcd}}
+\def\hom{\qopname\relax o{hom}}
+\def\inf{\qopname\relax m{inf}}
+\def\injlim{\qopname\relax m{inj\,lim}}
+\def\ker{\qopname\relax o{ker}}
+\def\lg{\qopname\relax o{lg}}
+\def\lim{\qopname\relax m{lim}}
+\def\liminf{\qopname\relax m{lim\,inf}}
+\def\limsup{\qopname\relax m{lim\,sup}}
+\def\ln{\qopname\relax o{ln}}
+\def\log{\qopname\relax o{log}}
+\def\max{\qopname\relax m{max}}
+\def\min{\qopname\relax m{min}}
+\def\Pr{\qopname\relax m{Pr}}
+\def\projlim{\qopname\relax m{proj\,lim}}
+\def\sec{\qopname\relax o{sec}}
+\def\sin{\qopname\relax o{sin}}
+\def\sinh{\qopname\relax o{sinh}}
+\def\sup{\qopname\relax m{sup}}
+\def\tan{\qopname\relax o{tan}}
+\def\tanh{\qopname\relax o{tanh}}
+% \end{macrocode}
+%
+% \begin{macro}{\operator@font}
+% \begin{macro}{\operatorfont}
+% This command is provided to allow the document styles to decide in
+% which way math operators like `max' or `log' are typeset. The
+% default is to set them in \meta{math group} zero of the current
+% math version. The original name was \cs{operator@font}, retained
+% for compatibility; the second name was added to make it
+% more accessible so that users can call this font for use in special
+% constructs that are not ordinary operator names but conceptually
+% related.
+% \begin{macrocode}
+\def\operator@font{\mathgroup\symoperators}
+\def\operatorfont{\operator@font}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% For backwards compatibility we keep this old command name for the
+% time being:
+% \begin{macrocode}
+\def\operatornamewithlimits{\operatorname*}
+% \end{macrocode}
+%
+% These macros use \cs{mathpalette}s so that they will change size
+% in script and scriptscript styles, though it's hard to imagine they
+% will ever be used there (the arrows, particularly, look bad in
+% subscript sizes). Notice that the use of \cs{ex@} means that the
+% vertical spacing may not be optimal in script and scriptscript
+% sizes. Unfortunately \tex/ provides no easy way to do math mode
+% vertical spacing that varies with current math style like mu units.
+% \begin{macrocode}
+\def\varlim@#1#2{%
+ \vtop{\m@th\ialign{##\cr
+ \hfil$#1\operator@font lim$\hfil\cr
+ \noalign{\nointerlineskip\kern1.5\ex@}#2\cr
+ \noalign{\nointerlineskip\kern-\ex@}\cr}}%
+}
+\def\varinjlim{%
+ \mathop{\mathpalette\varlim@{\rightarrowfill@\textstyle}}\nmlimits@
+}
+\def\varprojlim{%
+ \mathop{\mathpalette\varlim@{\leftarrowfill@\textstyle}}\nmlimits@
+}
+\def\varliminf{\mathop{\mathpalette\varliminf@{}}\nmlimits@}
+\def\varliminf@#1{\@@underline{\vrule\@depth.2\ex@\@width\z@
+ \hbox{$#1\m@th\operator@font lim$}}}
+\def\varlimsup{\mathop{\mathpalette\varlimsup@{}}\nmlimits@}
+\def\varlimsup@#1{\@@overline{\hbox{$#1\m@th\operator@font lim$}}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\nmlimits@\displaylimits
+\DeclareOption{namelimits}{\let\nmlimits@\displaylimits}
+\DeclareOption{nonamelimits}{\let\nmlimits@\nolimits}
+\ProcessOptions\relax
+% \end{macrocode}
+%
+% If we don't load the \pkg{amsgen} package then the use of \cs{ex@}
+% in \cs{varlim@} will lead to trouble.
+% \begin{macrocode}
+\RequirePackage{amsgen}\relax
+% \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.2a}{1995/02/20}{Fixed operatorname
+% (shouldn't have same limits behavior as operatorname*)}
+% \CheckSum{300}
+% \Finale
diff --git a/Master/texmf-dist/source/latex/amslatex/amsrefs.dtx b/Master/texmf-dist/source/latex/amslatex/amsrefs.dtx
new file mode 100644
index 00000000000..e8d81ed6336
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/amsrefs.dtx
@@ -0,0 +1,8030 @@
+%%% ====================================================================
+%%% @LaTeX-doc-source-file{
+%%% filename = "amsrefs.dtx",
+%%% version = "2.0",
+%%% date = "2004/06/30",
+%%% time = "11:24:39 EDT",
+%%% author = "Michael J Downes and David M. Jones",
+%%% address = "American Mathematical Society,
+%%% Publications Technical Group,
+%%% PO Box 6248,
+%%% Providence, RI 02940,
+%%% USA",
+%%% email = "tech-support@ams.org",
+%%% URL = "http://www.ams.org/",
+%%% abstract = "A LaTeX package that permits bibliography style
+%%% to be controlled completely from the LaTeX side
+%%% instead of being determined chiefly by the BibTeX
+%%% style file.",
+%%% checksum = "09127 8030 25325 242081",
+%%% docstring = "The checksum field, produced by Robert Solovay's
+%%% checksum utility, gives CRC-16 checksum, lines,
+%%% words, and characters.",
+%%% }
+%%% ====================================================================
+%%%
+% \iffalse
+%<*driver>
+\NeedsTeXFormat{LaTeX2e}
+\documentclass[draft,oneside]{amsdtx}
+
+\setcounter{secnumdepth}{3}
+\setcounter{tocdepth}{3}
+
+\DoNotIndex{\bib,\BibSpec,\@apply,\citesel,\cite@cj,\cite}
+\DoNotIndex{\IfOption,\add@toks@,\@emptytoks,\@temptokenb}
+
+\makeatletter
+\DeclareRobustCommand{\fld}{\category@index{field}}
+\DeclareRobustCommand{\btype}{\category@index{entry type}}
+\DeclareRobustCommand{\attr}{\category@index{attribute}}
+\makeatother
+
+%\OnlyDescription
+
+\usepackage{amsrefs}
+\usepackage{multicol}
+
+\providecommand{\lat}[1]{\protect\LaTeX{}}
+
+\DeclareTextSymbol{\lbracechar}{OT1}{123}
+\DeclareTextSymbolDefault{\lbracechar}{OT1}
+\DeclareTextSymbol{\rbracechar}{OT1}{125}
+\DeclareTextSymbolDefault{\rbracechar}{OT1}
+
+\newcommand{\rdag}{{\normalfont\dag}}
+
+\providecommand{\embrace}[1]{%
+ \begingroup \ntt\lbracechar#1\rbracechar\endgroup}
+
+% One mandatory argument: cnm; two: cnmm; one optional and one
+% mandatory: cnom; throwing in a star: cnsom; and so on.
+\providecommand{\cnbreak}{\penalty999\hskip0pt\relax}
+\providecommand{\cnm}[2]{\cn{#1}\cnbreak\embrace{#2}}
+\providecommand{\cnmm}[3]{\cn{#1}\cnbreak\embrace{#2}\cnbreak\embrace{#3}}
+\providecommand{\cnom}[1]{\cn{#1}\cnbreak\ommitude}
+\providecommand{\ommitude}[2][]{{\ntt[#1]}\cnbreak\embrace{#2}}
+\providecommand{\cnmsm}[4]{%
+ \cn{#1}\cnbreak\embrace{#2}\cnbreak *\embrace{#4}}
+
+\newcommand{\rpack}[1]{\pkg{amsrefs} package}
+
+\newcommand{\MacroArgs}{%
+ \par
+ \medskip \noindent\emph{Arguments}: \par}
+
+\newcommand{\macroarg}[2]{
+ \texttt{\arg{#1} <- }\emph{#2}\unkern\texttt{.}\par}
+
+\newenvironment{bug}{%
+ \quote
+ \emph{Known bug:}}
+ {\endquote}
+
+% non-stupid hline: support for adding some space below
+\newcommand{\nshline}{\hline\omit\\}
+
+\newcommand{\SeveralOptions}[1]{%
+ \vbox{\def\\{\unskip,\egroup\hbox\bgroup\ignorespaces}%
+ \hbox{\strut#1}}}
+
+% Make this a self-contained document without separate .bbl file.
+\newcommand{\PrintBibliography}{%
+ \begin{bibsection}\begin{biblist}\raggedright
+ \bib{Jones2004}{article}{
+ author={Jones, David M.},
+ title={User's Guide to the \pkg{amsrefs} Package},
+ note={distributed with the \pkg{amsrefs} code}
+ }
+ \bib{SOS99}{book}{
+ author={Swanson, Ellen},
+ author={O'Sean, Arlene},
+ author={Schleyer, Antoinette},
+ title={Mathematics into Type},
+ edition={updated},
+ year={1999},
+ publisher={American Mathematical Society},
+ }
+ \end{biblist}\end{bibsection}
+}
+
+\makeatletter
+
+\def\nametest#1{%
+ \par
+ \begingroup
+ \let\EmptyNameWarning\relax
+ \vdef\@tempa{#1}%
+ {\tt author=\embrace\@tempa}:
+ \name@split#1,,,\@nil
+ G=\@showname{given}
+ S=\@showname{surname}
+ J=\@showname{jr}%
+ \endgroup
+}
+
+\def\@showname#1{%
+ {\ntt\lbracechar}%
+ {\tt\@xp\macrotext\csname bib'#1\endcsname}%
+ {\ntt\rbracechar}
+}
+
+\def\initialtest#1{%
+ \par
+ \begingroup
+ \vdef\@tempa{#1}%
+ {\tt author=\embrace\@tempa}:
+ \name@split#1,,,\@nil
+ I={\ntt\lbracechar}\csname bib'initials\endcsname{\ntt\rbracechar}%
+ \endgroup
+}
+
+\makeatother
+
+\CodelineIndex
+
+\begin{document}
+\title{The \pkg{amsrefs} package}
+\author{Michael Downes and David M. Jones\\American Mathematical Society}
+\date{Version \fileversion, \filedate}
+\hDocInput{amsrefs.dtx}
+\PrintIndex
+\end{document}
+%</driver>
+% \fi
+%
+% \MakeShortVerb{\|}
+%
+% \maketitle
+%
+% \tableofcontents
+%
+% \section{Introduction}
+%
+% The \rpack/ is a \lat/ package for bibliographies that provides an
+% archival data format similar to the format of \bibtex/ database
+% files, but adapted to make direct processing by \lat/ easier. The
+% package can be used either in conjunction with \bibtex/ or as a
+% replacement for \bibtex/.
+%
+% This document is written for anyone who wants to implement a new
+% bibliography style for \pkg{amsrefs} or who is just curious about
+% how the package is implemented.
+% The reader should be familiar with the contents of the ``User's
+% Guide to the \pkg{amsrefs} Package''~\cite{Jones2004}
+% (\fn{amsrdoc.tex}).
+%
+% For the publisher or implementor, the chief advantages of the
+% \rpack/ are as follows:
+% \begin{description}
+%
+% \item[Preservation of structure]
+%
+% The internal structural information of the bibliography entries is not
+% lost when they are imported from the database file into the \lat/
+% document. This takes on its greatest significance when archiving
+% documents in \lat/ form or transmitting them to another user (such as a
+% publisher).
+%
+% \item[Deferred formatting]
+%
+% This means that the style of the bibliography can be readily changed
+% without reimporting everything from the original database(s).
+%
+% \item[Setup requires only \lat/ knowledge]
+%
+% All bibliography setup can be done in \lat/; learning another
+% programming language (such as the one used in \bibtex/ \fn{bst}
+% files) is unnecessary.
+%
+% \end{description}
+%
+% \section{Package options}
+%
+% In addition to the options documented in the user's guide, there
+% are a few additional options that were omitted either because
+% they are obsolete or deprecated options included only for
+% backwards compatability or because they are still considered
+% experimental and not yet ready for widespread use.
+%
+% \begin{description}
+%
+% \item[?]
+%
+% Informational option. This causes \pkg{amsrefs} to
+% display a pointer to the User's Guide on the terminal an in the
+% log file. (In previous versions, it displayed much more
+% material, including a summary of package options.)
+%
+% \item[traditional-quotes, logical-quotes]
+%
+% With the \textit{traditional quotes} option
+% (default), quotation marks produced by \cn{bibquotes}
+% (\secref{misc-cmds}) fall outside of other punctuation, ``like
+% this,'' whereas with the \textit{logical quotes} option the order
+% is reversed, ``like this''.
+%
+% \item[beta, jpa]
+%
+% Obsolete; these applied only to the beta version of the
+% \pkg{amsrefs} package.
+%
+% \end{description}
+%
+% \section{More about the \cn{bib} command}\label{bib-command}
+%
+% \subsection{Field names for the \cn{bib} command}
+%
+% In addition to the fields discussed in the user's guide, the
+% following fields are used internally:
+% \begin{description}
+%
+% \item[fulljournal]
+%
+% Used internally by \cn{DefineJournal}.
+%
+% \item[name]
+%
+% Used internally by the \btype{name} bibliography type and
+% \cn{DefineName}.
+%
+% \item[transition]
+%
+% A dummy field used inside \cs{BibSpec}s when we want to force an
+% action unconditionally.
+%
+% \end{description}
+%
+% The following fields are included for backwards compatibility:
+% \begin{description}
+%
+% \item[institution, school]
+%
+% These are provided as aliases for \fld{organization} for
+% compatibility with \BibTeX.
+%
+% \item[place]
+%
+% A synonym for \fld{address}. In earlier versions of
+% \pkg{amsrefs}, \fld{place} was preferred and \fld{address} was
+% considered as an alias for \fld{place}. However, this seemed
+% like a gratuitous incompatibility with \BibTeX\ to me, so I have
+% reinstated \fld{address} as the primary field and \fld{place} is
+% now an undocumented alias.
+%
+% \end{description}
+%
+% The following fields are reserved for future use:
+% \begin{description}
+%
+% \item[doi] Digital Object Identifier
+%
+% \item[setup]
+%
+% This is a special field that can be used to give arbitrary
+% commands to be executed at the beginning of the current \cn{bib}
+% entry, after all the fields have been read. The idea is that one
+% can alter the formatting of an individual entry through this
+% field, to handle special cases.
+%
+% This is fully implemented, but I've been unable to think of any
+% good examples of its use; so, I've decided to suppress it until
+% such an example comes to light.
+%
+% \item[url] Universal Resource Locator.
+%
+% \end{description}
+%
+% \subsection{Bibliography entry types}
+%
+% The following additional entry types (or, really, pseudo-entry
+% types) are used internally by \pkg{amsrefs}:
+% \begin{description}
+%
+% \item[collection.article]
+%
+% \item[proceedings.article]
+%
+% \item[partial]
+%
+% \item[conference]
+%
+% \item[innerbook]
+%
+% \item[name]
+%
+% \item[nameLE]
+%
+% \item[nameBE]
+%
+% \item[nameinverted]
+%
+% \item[publisher]
+%
+% \end{description}
+%
+% The following are currently undocumented aliases for various of
+% the standard types:
+% \begin{description}
+%
+% \item[miscellaneous]
+%
+% \item[periodical]
+%
+% \end{description}
+%
+% \section{Customizing the bibliography style}\label{other-styles}
+%
+% If you use the \rpack/ as is, the bibliography style you get is the
+% kind of style customarily seen in AMS publications. The recommended
+% way to get a different bibliography style is to write a \lat/
+% package which loads the \rpack/ with \cn{RequirePackage} and
+% then makes the desired changes by using suitable \cn{BibSpec}
+% commands as explained below. Thus, the general form of the custom
+% package will be
+% \begin{verbatim}
+% \ProvidesPackage{xyzbib}[2002/11/06 v1.28]
+%
+% \RequirePackage{amsrefs}\relax
+%
+% \BibSpec{article}{
+% ...
+% }
+%
+% \BibSpec{book}{
+% ...
+% }
+%\end{verbatim}
+%
+% The interior formatting within entries is specified by \cn{BibSpec}
+% commands, one for each entry type. To illustrate, let's look at an
+% example style specification for entries of type \btype{article}:
+% \begin{verbatim}
+% \BibSpec{article}{%
+% +{}{\PrintAuthors} {author}
+% +{,}{ \textit} {title}
+% +{,}{ } {journal}
+% +{}{ \textbf} {volume}
+% +{}{ \parenthesize} {date}
+% +{,}{ } {pages}
+% +{,}{ } {note}
+% +{.}{} {transition}
+% +{}{ } {review}
+% }
+%\end{verbatim}
+%
+% It should be pretty obvious that each line specifies the formatting
+% for a particular field. After reading the data for a particular
+% \cn{bib} command, \lat/ steps through the style specification and
+% for each
+% field listed, prints the field with the given formatting \emph{if
+% and only if the field has a nonempty value}. The \verb'+' character
+% at the beginning of each field specification must be followed by three
+% arguments: the punctuation to be added if the field is nonempty;
+% space and/or other material to be added after the punctuation; and
+% the field name. It is permissible for the second part to end with a
+% command that takes an argument, such as \cn{textbf}, in which case
+% it will receive the field's value as its argument. By defining a
+% suitable command and using it here you can place material after the
+% field contents as well as before; \cn{parenthesize} is an example
+% of this.
+%
+% The reason that the punctuation and the following space are specified
+% separately is that between them there is a crucial boundary for line
+% breaks. If you put a \cn{linebreak} command at the end of a field value,
+% the break point will actually be carried onward to a suitable point after
+% the next bit of punctuation (whose actual value may vary depending on
+% which of the following fields is the first to turn up with a nonempty
+% value).
+%
+% The meaning of the \cn{parenthesize} command, supplied by
+% \pkg{amsrefs}, should be obvious. The meaning of the \cn{PrintAuthors}
+% command is a different story. But I don't think it is all that hard to
+% understand. If we have two or more author names which were given
+% separately,
+% and we need to combine them into a conventional name list using commas
+% and the word \qq{and}, then it would be nice if we had a command which
+% could take a list of names and Do The Right Thing. And that is just
+% what \cn{PrintAuthors} is.
+%
+% The \pkg{rkeyval} package allows keys to be defined as additive: if the
+% key occurs more than once, each successive value will be concatenated to
+% the previous value, along with a prefix. The setup done by
+% \pkg{amsrefs} for the \fld{author} field is
+% \begin{verbatim}
+% \DefineAdditiveKey{bib}{author}{\name}
+%\end{verbatim}
+% This means that if two names are given, as in
+% \begin{verbatim}
+% author={Bertram, A.},
+% author={Wentworth, R.},
+%\end{verbatim}
+% then the final value of the \fld{author} field seen when \lat/
+% processes the style specification will be
+% \begin{verbatim}
+% \name{Bertram, A.}\name{Wentworth, R.}
+%\end{verbatim}
+%
+% The \fld{transition} field in our \cn{BibSpec} example is a dummy
+% field to be
+% used when punctuation or other material must be added at a certain point
+% in the bibliography without regard to the emptiness or non-emptiness of
+% the fields after it. The \fld{transition} field always tests as non-empty
+% but has no printed content. So when you use it you always get the
+% indicated punctuation and space at the indicated point in the list of
+% fields. If it were the last thing in this \cn{BibSpec} example, it could
+% serve just to put in the final period that is always wanted. But in AMS
+% bibliographies, if a \emph{Mathematical Reviews} reference is given, it is
+% conventionally printed \emph{after} the final period. Using the
+% \fld{transition} field as shown here ensures that the final period will
+% be always printed, even when the \fld{review} field is empty.
+%
+% \section{Miscellaneous commands provided by the \pkg{amsrefs}
+% package}\label{misc-cmds}
+%
+% Most of the following commands are helper commands for use in
+% \cn{BibSpec} statements. The others are intended for use in bibliography
+% data.
+% \begin{description}
+%
+% \item[\cn{parenthesize}]\SpecialUsageIndex{\parenthesize}
+% This command adds parentheses around its
+% argument. It is useful in \cn{BibSpec} statements because there is no
+% special provision for adding material after the field value.
+%
+% \item[\cn{bibquotes}]\SpecialUsageIndex{\bibquotes}
+% This command is much like \cn{parenthesize} but
+% it adds quotes around its argument and it has one other important
+% difference: there are special arrangements to print the closing quote
+% \emph{after} a following comma or similar punctuation (unless the
+% \pkg{amsrefs} package is invoked with the \opt{logical-quotes} option,
+% in which case \cn{bibquotes} puts the closing quote immediately after
+% the quoted material).
+%
+% \item[\cn{voltext}]\SpecialUsageIndex{\voltext}
+% This is used to format volume numbers. By default, it precedes
+% the volume number by ``vol.''
+%
+% \item[\cn{issuetext}]\SpecialUsageIndex{\issuetext}
+% This is used to format issue numbers. By default, it precedes
+% the volume number by ``no.''
+%
+% \item[\cn{editiontext}]\SpecialUsageIndex{\editiontext}
+% This command produces ``ed.''\ following an
+% edition number. See \cn{PrintEdition} for more information.
+%
+% \item[\cn{DashPages}]\SpecialUsageIndex{\DashPages}
+% This command is similar in spirit to
+% \cn{voltext} but more complicated in its implementation. It takes
+% one argument which is expected to contain one or more page numbers
+% or a range of page numbers. The argument is printed with a prefix
+% of \qq{p.} if it seems to be a single page number, otherwise with a
+% prefix of \qq{pp.}.
+%
+% \item[\cn{tsup}, \cn{tsub}, \cn{tprime}]\SpecialUsageIndex{\tsup}
+% \SpecialUsageIndex{\tsub}\SpecialUsageIndex{\prime}
+% These are for text subscripts
+% and superscripts, with \cn{tprime} producing a superscript prime
+% symbol. Unlike the standard \cn{textsuperscript} and
+% \cn{textsubscript} functions provided by \lat/, these do not use
+% math mode at all.\footnote{There is one drawback: If you don't
+% want to get the prime symbol for \cn{tprime} from the \fnt{cmsy}
+% font, you will need to redefine \cn{tprime} in some suitable
+% way.}
+%
+% \item[\cn{nopunct}]\SpecialUsageIndex{\nopunct}
+% This command causes following punctuation to be omitted if it is
+% added with the internal function \cs{@addpunct}.
+%
+% \item[\cn{PrintPrimary}]\SpecialUsageIndex{\PrintPrimary}
+% This is a relatively complicated function that determines the
+% ``primary'' contributors for an entry and formats them, or
+% replaces them by \cn{sameauthors} if appropriate. It should be
+% used when an entry type might have editors or translators instead
+% of authors. It prefers authors over editors and editors over
+% translators and generates a warning if there are no primary
+% contributors.
+%
+% \item[\cn{PrintAuthors}]\SpecialUsageIndex{\PrintAuthors}
+% This is used to format the list of authors as the primary
+% contributors for an entry type.
+%
+% \item[\cn{PrintEditorsA}]\SpecialUsageIndex{\PrintEditorsA}
+% This is similar to \cn{PrintAuthors} but adds |(ed.)| or |(eds.)|
+% following the editors.
+%
+% \item[\cn{PrintEditorsB}]\SpecialUsageIndex{\PrintEditorsB}
+% This is similar to \cn{PrintEditorsA} but puts parentheses around
+% the entire list of editors. It's used by, for example, the
+% \btype{article} type to print the editors of a
+% \btype{proceedings} or \btype{collection}.
+%
+% \item[\cn{PrintEditorsC}]\SpecialUsageIndex{\PrintEditorsC}
+% Similar to \cn{PrintEditorsA} but precedes the editors by
+% |Edited by|. It's used when the editors should be treated as
+% subsidiary contributors, rather than the primary contributor.
+%
+% \item[\cn{PrintTranslatorsA}]\SpecialUsageIndex{\PrintTranslatorsA}
+% This is similar to \cn{PrintEditorsA} but adds |(trans.)|
+% following the translators.
+%
+% \item[\cn{PrintTranslatorsB}]\SpecialUsageIndex{\PrintTranslatorsB}
+% This is similar to \cn{PrintEditorsB}. It's not currently used,
+% but is provided for symmetry.
+%
+% \item[\cn{PrintTranslatorsC}]\SpecialUsageIndex{\PrintTranslatorsC}
+% Similar to \cn{PrintEditorsC} but precedes the translators by
+% |Translated by|.
+%
+% \item[\cn{sameauthors}]\SpecialUsageIndex{\sameauthors}
+% This is a function of one argument. If you use
+% the default set of \cn{BibSpec}s from the \pkg{amsrefs},
+% \cn{sameauthors} is applied to the author name for a given \cn{bib}
+% command if it matches exactly the author name of the preceding
+% \cn{bib} command. Change the definition of \cn{sameauthors} if you
+% don't want to get a bysame dash.
+%
+% \item[\cn{bysame}]\SpecialUsageIndex{\bysame}
+% This is a horizontal rule of length 3~em. The default
+% definition of \cn{sameauthors} prints \cn{bysame} instead of the
+% author names.
+%
+% \item[\cn{Plural}, \cn{SingularPlural}]\SpecialUsageIndex{\Plural}
+% \SpecialUsageIndex{\SingularPlural}
+% These are helper functions
+% that allow you to conditionally
+% print singular or plural forms such as \verb'(ed.)' or \verb'(eds.)'
+% depending on the number of names in the current name list.
+% The definition of \cn{PrintEditorsA} reads, in part,
+% \begin{verbatim}
+% ... (ed\Plural{s}.) ...
+%\end{verbatim}
+%
+% \item[\cn{PrintReviews}]\SpecialUsageIndex{\PrintReviews}
+% This is similar to \cn{AuthorList} but is used for
+% printing (possibly multiple) MR numbers given in the \fld{review}
+% field.
+%
+% \item[\cn{BibField}]\SpecialUsageIndex{\BibField}
+% This is for more complicated programming tasks such
+% as may be necessary for some \cn{BibSpec}s. It takes one
+% argument, a field name, and yields the contents of that field for
+% the current \cn{bib} entry.
+%
+% \item[\cn{IfEmptyBibField}]\SpecialUsageIndex{\IfEmptyBibField}
+% If one writes
+% \begin{verbatim}
+% \IfEmptyBibField{isbn}{A}{B}
+%\end{verbatim}
+% then the commands in A will be executed if the \fld{isbn} field is empty,
+% otherwise the commands in B.
+%
+% \item[\cn{PrintEdition}]\SpecialUsageIndex{\PrintEdition}
+% If a bibliography entry has
+% \begin{verbatim}
+% edition={2}
+%\end{verbatim}
+% and the \cn{BibSpec} used \cn{PrintEdition} to handle this field, then the
+% edition information will be printed as \qq{2nd ed.}\mdash that is, the
+% number is converted to cardinal form and \qq{ed.} is added (taken from
+% \cn{editiontext}).
+%
+% \item[\cn{CardinalNumeric}]\SpecialUsageIndex{\CardinalNumeric}
+% This provides the conversion to cardinal
+% number form used by \cn{PrintEdition}.
+%
+% \item[\cn{PrintDate}, \cn{PrintYear}]\SpecialUsageIndex{\PrintDate}
+% \SpecialUsageIndex{\PrintYear}
+% These functions convert a date in
+% canonical form (ISO 8601) to the form required by the current
+% bibliography style. You can get your preferred date form by
+% redefining these functions or by changing your \cn{BibSpec} statements
+% to use another function of your own devising. The original definition
+% of \cn{PrintDate} adds parentheses (as for the year of a journal article
+% in normal AMS style), whereas the \cn{PrintYear} function simply
+% prints the year without any additional material (as for a book's year
+% of publication in normal AMS style).
+%
+% \item[\cn{mdash}, \cn{ndash}]\SpecialUsageIndex{\mdash}
+% \SpecialUsageIndex{\ndash}
+% These are short forms for \cn{textemdash}
+% and \cn{textendash}, recommended instead of the more usual \verb'---'
+% and \verb'--' notation. From the \pkg{textcmds} package.
+%
+% \item[et cetera \dots] [mjd,2002-01-03] See the \fn{.dtx} files for
+% further possibilities that I have not managed to get properly
+% documented yet!
+% \end{description}
+%
+% \StopEventually{\PrintBibliography}
+% \iffalse
+% \clearpage
+% \typeout{@@@ That was the last page of the OnlyDescription}
+% \fi
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \section{Implementation}
+%
+% \subsection{Overview}
+%
+% It will be a while yet before we get to any actual code. First we
+% need to understand what the code needs to accomplish in order to
+% provide the user interface described above in a way that is as
+% compatible as possible with existing \lat/ mechanisms.
+%
+% \subsubsection{Normal \lat/ processing of cites}
+%
+% \paragraph{First \lat/ pass}
+%
+% Various commands are written to the \fn{.aux} file that are
+% mostly used by \bibtex/.
+% \begin{enumerate}
+% \item A \cnm{cite}{moo} command writes one line to the \fn{.aux} file:
+% \cnm{citation}{moo}. This indicates to \bibtex/ that it should
+% include `moo' in the list of cited items to be searched for.
+% The \cn{cite} command also checks to see if \cs{b@moo} contains
+% the corresponding citation label, but since this is the first
+% pass, the label won't be known yet, so \lat/ emits an `Undefined
+% citation' warning and prints a placeholder (i.e., \textbf{???})
+% instead of the citation label.
+%
+% \item A \cnm{bibliographystyle}{har} command writes one line to the
+% \fn{.aux} file: \cnm{bibstyle}{har}. This indicates to \bibtex/ that it
+% should use \fn{har.bst} to determine the style for sorting and
+% formatting the bibliography items.
+%
+% \item A \cnm{bibliography}{hij,klm,...} command writes one line to the
+% \fn{.aux} file: \cnm{bibdata}{hij,klm,...}. This indicates to \bibtex/
+% that it should look in \fn{hij.bib}, \fn{klm.bib}, \dots\ for
+% bibliographic data. The \cn{bibliography} also tries to input
+% the \fn{.bbl} file, but on the first pass it won't exist
+% yet.
+%
+% \end{enumerate}
+%
+% On the first pass all \cn{cite}'s normally are reported as
+% undefined because the \fn{.bbl} file has not yet been created.
+%
+% \paragraph{\bibtex/ pass}
+%
+% For a document named \fn{xyz.tex}, the command \verb'bibtex xyz' is
+% used to invoke \bibtex/. It looks in \fn{xyz.aux} to find the
+% citation information written there by \lat/. For each \cn{citation} line,
+% \bibtex/ searches for a corresponding entry in the specified
+% \fn{.bib} files and formats it. The entire list is then sorted in
+% whatever way dictated by the bibliography style, and written out to
+% the file \fn{xyz.bbl}. This normally produces entries that look
+% something like:
+% \begin{verbatim}
+% \bibitem{BGL} P. Busch, M. Grabowski and P. J. Lahti:
+% {\it Operational Quantum Physics.}
+% Springer Verlag, New York (1995).
+%\end{verbatim}
+%
+% \paragraph{Second \lat/ pass}
+%
+% Now the \fn{.bbl} file exists and contains some \cn{bibitem}
+% commands. At \cnm{begin}{document}, \lat/ reads the \fn{.aux} file,
+% hoping to find some \cn{bibcite} commands, but it will not find
+% them until the next time around. \cn{citation}, \cn{bibstyle}, and
+% \cn{bibdata} commands in the \fn{.aux} file are simply ignored by \lat/.
+% Then \lat/ proceeds to typeset the body of the document.
+% \begin{enumerate}
+% \item Instances of \cn{cite} still print question marks.
+%
+% \item The \cn{bibliography} command causes \lat/ to input \fn{xyz.bbl}
+% and typeset its contents.
+%
+% \item A \cnm{bibitem}{moo} command writes one line to the
+% \fn{.aux} file: \cnmm{bibcite}{moo}{9}, where 9 is the current item
+% number.
+%
+% \item A \cnom{bibitem}[Moody]{moo} command writes one line to the
+% \fn{.aux} file: \cnmm{bibcite}{moo}{Moody}, using the supplied label
+% instead of a number.
+%
+% \end{enumerate}
+%
+% \paragraph{Third \lat/ pass}
+%
+% Now the \fn{.aux} file contains some \cn{bibcite} commands. Once again,
+% \lat/ reads the \fn{.aux} file when it reaches \cnm{begin}{document}.
+% \begin{enumerate}
+%
+% \item A \cnmm{bibcite}{moo}{Moody} causes \lat/ to define \cs{b@moo}
+% with `Moody' as the replacement text.
+%
+% \item If two \cn{bibcite} commands have the same citation key, \lat/
+% gives a warning message. This happens at \cnm{begin}{document},
+% during the reading of the \fn{.aux} file.
+%
+% \item Instances of \cn{cite} in the body of the document will print
+% the appropriate labels obtained from the \fn{.aux} file.
+%
+% \item If there are any \cn{cite} commands for which the \fn{.aux} file did
+% not have a \cn{bibcite} command, \lat/ will give an `Undefined
+% citation' warning. This often happens if the \fn{.aux} file is incomplete
+% due to a \TeX{} error on the preceding pass.
+% \end{enumerate}
+%
+% \subsection{How cites are processed by \pkg{amsrefs}}
+%
+% In order to support its additional features (e.g., author-year
+% citations and the \opt{backrefs} option), the \rpack/ stores additional
+% information for each cite in the macro \cs{b@whatever}. Instead of
+% simply using the defined or undefined status of this macro to
+% trigger the standard warnings, we add some boolean flags to allow
+% us to discriminate more finely what the current situation is.
+% \begin{itemize}
+% \item Each time an item is cited in the body of the document, a
+% \texttt{backref} entry is added to the info of that item. The
+% \texttt{backref} info
+% is the current page and section location. Section location is a bit
+% hard to get right without better support from the document class.
+% So we provide a hook to allow it to work better when the support is
+% there.
+%
+% \item When a cite occurs, if the info is undefined then a warning is
+% issued and the info structure is created. A \cs{citation} command
+% and a \cs{citedest} command (providing backref info) are written to
+% the \fn{.aux} file. Because the backref info includes page number, it has
+% to be a non-immediate write.
+%
+% An undefined info structure would normally happen only on a first
+% pass when no \fn{.aux} file exists, or when a new cite is added.
+% I.e., when the corresponding \cs{citation} command is not yet
+% present in the \fn{.aux} file.
+%
+% \item When a citation command occurs in the \fn{.aux} file, it initializes
+% the info structure if necessary, setting the ``bib-info-present''
+% flag to 0.
+%
+% \item When a \cs{citedest} command occurs in the \fn{.aux} file, it
+% initializes the info structure if necessary---but this shouldn't
+% happen: if the corresponding \cs{citation} command did not already
+% get processed, then something is wrong. So normally, the
+% \cs{citedest} command merely needs to add its backref info to the
+% existing info structure.
+%
+% \item When a \cs{bibcite} command occurs in the \fn{.aux} file, it will
+% normally find that \cs{b@whatever} is already defined, if the
+% bibliography occurs after all the \cn{cite} commands. What it must
+% do is fill in the appropriate blank slots in the info structure
+% set up by a previous \cs{citation} command.
+%
+% \item The \fn{.aux} file is actually processed two times, once at the
+% beginning of the document and once at the end. In the latter case,
+% \cs{bibcite} should give a warning if the backref-list is empty,
+% since that means there were no \cn{cite} commands for the given
+% key.
+%
+% \item When processing the bibliography: The \cn{bib} command needs to
+% check if it is using a key that is already used by another \cn{bib}
+% command.
+% \end{itemize}
+%
+% We therefore have
+% \begin{verbatim}
+% \b@xyz -> \citesel 00{label}{year}{backref-list}
+%\end{verbatim}
+% where the first~0 is replaced by~1 if there has already been another
+% citation for the same key earlier in the document (some citation
+% styles use abbreviated forms for all instances after the first),
+% and the second~0 is replaced by~1 if the same key was already
+% used by an earlier \cn{bib} command.
+%
+% Because the backref-list often includes page number information, it
+% cannot be built on the fly as we go along; instead we have to write
+% the information to the \fn{.aux} file and read it in at the beginning of
+% the next run.
+%
+% If there was no \cs{bibcite} in the \fn{.aux} file for a given key, then
+% the info is
+% \begin{verbatim}
+% \b@xyz -> \citesel 00{}{}{backref-list}
+%\end{verbatim}
+% If there was neither \cs{citation} nor \cs{bibcite} in the \fn{.aux} file
+% for a given key, then the \cn{cite} command should find that
+% \ncn{b@xyz} is undefined.
+%
+% If the author-year option is in effect, the \qq{label} contains
+% the author last names instead of a label:
+% \begin{verbatim}
+% \b@xyz -> \citesel 00{\name{Smith}\name{Jones}}{...}{...}
+%\end{verbatim}
+% Full name information is included in the data because some citation
+% styles give full names at the first citation and abbreviated forms
+% for subsequent instances.
+%
+% \subsection{Data structures}
+%
+% The result of scanning the key/value pairs of a \cn{bib} command is
+% an assignment statement for \cs{rsk@toks}. (Cf.\@ the \pkg{rkeyval}
+% package.) For example, consider the entry
+% \begin{verbatim}
+% \bib{miller83}{article}{
+% author={Miller, G.},
+% title={Eine Bemerkung zur Darstellung von Polynomen \"{u}ber
+% Verb\"{a}nden}*{language={german}},
+% journal={J. Math. Sent.},
+% volume={10},
+% year={1983},
+% pages={26\ndash 30},
+% }
+%\end{verbatim}
+% The scanned result is to assign
+% \begin{verbatim}
+% \global\rsk@toks{%
+% \set:bib'author{Miller, G.}{}%
+% \set:bib'title{Eine Bemerkung zur Darstellung von Polynomen
+% \"{u}ber Verb\"{a}nden}{language={german}}%
+% \set:bib'journal{J. Math. Sent.}{}%
+% \set:bib'volume{10}{}%
+% \set:bib'year{1983}{}%
+% \set:bib'pages{26\ndash 30}{}%
+% }
+%\end{verbatim}
+% The code in the last arg of \cn{RestrictedSetKeys} then invokes
+% \cs{bib@exec} to do something with the value of \cs{rsk@toks}.
+% \begin{verbatim}
+% \bib@exec{miller83}{\the\rsk@toks}{\setbib@article}{}
+%\end{verbatim}
+%
+% \subsection{Preliminaries}
+%
+% \begin{macrocode}
+%<*pkg>
+% \end{macrocode}
+%
+% Standard declaration of package name and date.
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+% \end{macrocode}
+%
+% \begin{macro}{\amsrefs@warning@nl}
+% \begin{macrocode}
+\def\amsrefs@warning@nl{\PackageWarningNoLine{amsrefs}}
+% \end{macrocode}
+% \end{macro}
+%
+% Backward handling for beta version.
+% \begin{macrocode}
+\@ifpackagewith{amsrefs}{beta}{%
+ \amsrefs@warning@nl{The beta option is deprecated^^J%
+ and will be removed in a future release of amsrefs}
+ \expandafter\edef\csname opt@amsrbeta.sty\endcsname
+ {\@ptionlist{amsrefs.sty}}%
+ \def\@currname{amsrbeta}%
+ \expandafter\let\csname amsrbeta.sty-h@@k\endcsname\@empty
+ \def\@tempa{\input{amsrbeta.sty}\endinput}%
+}{%
+ \let\@tempa\@empty
+}
+\@tempa
+% \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
+ \@apply\@urlfix{\do\+\do\=\do\:\do\-\do\.\do\,\do\;}%
+ \@apply\@urlbreak{\do\&\do\/\do\?}%
+ }%
+ \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}
+\@ifundefined{NormalCatcodes}{\RequirePackage{pcatcode}\relax}{}
+\PushCatcodes\NormalCatcodes
+\ProvidesPackage{amsrefs}[2004/06/07 v1.71]
+% \end{macrocode}
+%
+% \begin{macrocode}
+%% WARNING WARNING WARNING: Catcode of apostrophe ' is letter
+%% throughout this file.
+\catcode`\'=11 % letter
+% \end{macrocode}
+%
+% \subsection{Utilities}
+%
+% Some of these useful functions are also found in AMS
+% document classes.
+%
+% \begin{macro}{\after@deleting@token}
+% Similar in concept to \cs{afterassignment}, except it deletes the
+% next token in the stream before putting its argument
+% back into the input. Useful for skipping past tokens during
+% parsing.
+% \begin{macrocode}
+\def\after@deleting@token#1{%
+ \afterassignment#1%
+ \let\@let@token= % Don't delete this space!
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@ifempty}
+% \begin{macro}{\@ifnotempty}
+% Some frequently used tests for empty arguments. Note that an
+% argument consisting entirely of spaces (e.g.,
+% \verb*|\@ifempty{ }|) counts as empty.
+% \begin{macrocode}
+\long\def\@ifempty#1{\@xifempty#1@@..\@nil}
+
+\long\def\@xifempty#1#2@#3#4#5\@nil{%
+ \ifx#3#4\@xp\@firstoftwo\else\@xp\@secondoftwo\fi
+}
+
+\long\def\@ifnotempty#1{\@ifempty{#1}{}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\macrotext}
+% \begin{macrocode}
+\def\macrotext{\expandafter\strip@prefix\meaning}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\vdef}
+% ``Verbatim'' def.
+% \begin{macrocode}
+\def\vdef#1#2{%
+ \def#1{#2}%
+ \edef#1{\macrotext#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\auto@protect}
+% Sometimes it's convenient to render a given control sequence
+% unexpandable for a time. \cs{auto@protect} provides a way to do
+% that.\footnote{There really should be a special name for macros
+% that, like \cs{auto@protect}, take a control sequence as an
+% argument and redefine that control sequence in order to achieve
+% some special effect. Pending happier inspiration, I'm
+% going to call them ``wrapper'' macros.\index{wrapper macros,
+% definition}}
+%
+% An earlier version of this code read simply |\let#1\relax| but
+% that had the disadvantage of making all \cs{auto@protect}ed
+% macros compare equal via \cs{ifx}. This version allows macros to
+% keep their identities under comparisons.
+% \begin{macrocode}
+\def\auto@protect#1{\def#1{\@nx#1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\g@undef}
+% Globally undefine a control sequence.
+% \begin{macrocode}
+\def\g@undef#1{\global\let#1\relax}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@concat}
+% Concatenate onto the end of a token list. Expands everything.
+% \begin{macrocode}
+\def\@concat#1#2{\edef#1{#1#2}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\add@toks@}
+% This saves a few tokens of main memory and a lot of typing.
+% \begin{macrocode}
+\def\add@toks@{\addto@hook\toks@}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@lappend}
+% Append an element to a \cs{do}-delimited list. As long as the
+% element to be appended (|#2|) is a single token, nothing is
+% expanded. If it contains multiple tokens, all tokens after the
+% first will be expanded.
+% \begin{macrocode}
+\def\@lappend#1#2{%
+ \begingroup
+ \def\do{\@nx\do\@nx}%
+ \edef\@tempa{\def\@nx#1{#1\do#2}}%
+ \@xp\endgroup
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@apply}
+% Apply a macro to each element of a \cs{do}-delimited list.
+% \begin{macrocode}
+\def\@apply#1#2{%
+ \let\do#1%
+ #2%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\get@numberof}
+% This is a generic macro for counting the number of elements in a
+% \lat/-style list.
+% The first argument is a \cs{count} register that will receive the
+% final count; the second argument is the control sequence that
+% separates elements of the list, and the third argument is the
+% list itself. So, for example,
+% \begin{verbatim}
+% \get@numberof\@tempcnta\do\dospecials
+%\end{verbatim}
+% would count the number of special characters in \cs{dospecials}
+% and store the number in \cs{@tempcnta}.
+% \begin{macrocode}
+\def\get@numberof#1#2#3{%
+ \begingroup
+ \def#2{\advance\@tempcnta\@ne \@gobble}%
+ \@tempcnta\z@
+ #3\relax
+ \edef\@tempb{#1=\the\@tempcnta\relax}%
+ \@xp\endgroup
+ \@tempb
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\safe@set}
+% This is a quick and dirty way of extracting an integer prefix
+% from a string and assigning it to a counter. If the string does
+% not begin with an integer, the counter receives the value~0. The
+% suffix after the integer prefix is discarded. (But bad things
+% will happen if the string contains the token \cs{@nil}.)
+% \begin{macrocode}
+\def\safe@set#1#2{%
+ \afterassignment\@nilgobble
+ #1=0#2\relax\@nil
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@chomp}
+% Vaguely reminiscent of Perl's \texttt{chomp} function, which removes
+% a substring from the end of a variable, but ours works with
+% tokens (more-or-less) and takes the substring to be removed as
+% its second argument. Note the use of \cs{@empty} to anchor the
+% chomped substring to the end of the string. Note also that the
+% second argument will be fully expanded during the chomping.
+% \begin{macrocode}
+\def\@chomp#1#2{%
+ \begingroup
+ \toks@\@emptytoks
+ \def\@chomper##1##2#2\@empty##3\@nil{%
+ \ifx\@let@token\bgroup
+ \toks@{{##1}##2}%
+ \else
+ \toks@{##1##2}%
+ \fi
+ }%
+ \@xp\chomp@ #1\@empty#2\@empty\@nil
+ \edef\@tempa{\def\@nx#1\@xp{\the\toks@}}%
+ \@xp\endgroup
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\chomp@}
+% Before passing control to \cs{@chomper}, we peek ahead at the
+% next token in the stream. That way, if the next token is an open
+% brace, we know we need to surround \cs{@chomper}'s first argument
+% with braces. Unfortunately, this might still remove braces from
+% the second argument, but I think that's ok for our purposes.
+% \begin{macrocode}
+\def\chomp@{%
+ \futurelet\@let@token
+ \@chomper
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\amsrefs@warning}
+% \begin{macrocode}
+\def\amsrefs@warning{\PackageWarning{amsrefs}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\amsrefs@error}
+% \begin{macrocode}
+\def\amsrefs@error{\PackageError{amsrefs}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MessageBreakNS}
+% This suppresses the leading space in \cs{on@line} in error and
+% warning messages.
+% \begin{macrocode}
+\def\MessageBreakNS{\MessageBreak\romannumeral`\^^@}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@addpunct}
+% The \cs{@addpunct} function is defined by AMS document classes and
+% the \pkg{amsgen} package. But if we find it undefined we had better
+% define it.
+% \begin{macrocode}
+\@ifundefined{@addpunct}{%
+ \def\@addpunct#1{%
+ \relax\ifhmode
+ \ifnum\spacefactor>\@m \else#1\fi
+ \fi
+ }
+ \def\frenchspacing{%
+ \sfcode`\.1006
+ \sfcode`\?1005
+ \sfcode`\!1004
+ \sfcode`\:1003
+ \sfcode`\;1002
+ \sfcode`\,1001\relax
+ }
+}{}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\nopunct}
+% Omit any following punctuation that would normally be inserted by
+% \cs{@addpunct}.
+% \begin{macrocode}
+\providecommand{\nopunct}{\spacefactor \@nopunctsfcode}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@nopunctsfcode}
+% \begin{macrocode}
+\def\@nopunctsfcode{1007 }
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Declaring package options}
+%
+% We call the \pkg{ifoption} package to facilitate some option tests.
+% \begin{macrocode}
+\RequirePackage{ifoption}[2000/02/15]
+% \end{macrocode}
+%
+% The \opt{sorted} option is a no-op and is no longer documented.
+% I'm only leaving it here for backwards compatibility.
+% \begin{macrocode}
+\DeclareExclusiveOptions{sorted,citation-order}
+% \end{macrocode}
+% The \opt{alphabetic} option corresponds to the standard \bst{alpha}
+% biblio style with labels like Knu66 (three letters from name plus
+% two digits of year). Maybe should provide an alias LllYY for this
+% option. Numeric is the default since it is commoner in AMS
+% publications.
+% \begin{macrocode}
+\DeclareExclusiveOptions{alphabetic,shortalphabetic,author-year,numeric}
+% \end{macrocode}
+%
+% \begin{option}{y2k}
+% \begin{macrocode}
+\DeclareBooleanOption{y2k}
+% \end{macrocode}
+% \end{option}
+%
+% \begin{option}{nobysame}
+% \begin{macrocode}
+\DeclareBooleanOption{nobysame}
+% \end{macrocode}
+% \end{option}
+%
+% The standard \bst{abbrv} bibliography style uses abbreviations for
+% month names and journal names, and first names of people are
+% abbreviated to their initials. Since the second test bibliography
+% that I tested with had unabbreviated month names but abbreviated
+% journal names, perhaps it is a good idea to let these choices be
+% specified separately.
+% \begin{macrocode}
+\DeclareBooleanOption{short-journals}
+% \end{macrocode}
+% \begin{macrocode}
+\DeclareBooleanOption{short-publishers}
+% \end{macrocode}
+% The \opt{short-journals} and \opt{short-publishers} options only
+% affect journal and publisher names that are defined with
+% \cn{DefineJournal} and \cn{DefinePublisher} commands.
+% \begin{macrocode}
+\DeclareBooleanOption{short-months}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareBooleanOption{initials}
+% \end{macrocode}
+% Nevertheless, it's to be expected that the preceding four options
+% would typically be used together, so we provide a short-hand for
+% requesting them all.
+% \begin{macrocode}
+\DeclareOption{abbrev}{%
+ \@pass@ptions
+ \@currext
+ {initials,short-months,short-journals,short-publishers}%
+ \@currname
+}
+% \end{macrocode}
+%
+% In the bibliography, if a title or something is enclosed in quotes,
+% should the closing quotes go inside the punctuation (logical
+% position) rather than outside (traditional)? These options give you
+% a choice.
+% \begin{macrocode}
+\DeclareExclusiveOptions{traditional-quotes,logical-quotes}
+% \end{macrocode}
+%
+% A sequence of cites will be sorted and ranges of length three or
+% greater will be compressed if these options so indicate. Note
+% that the \opt{non-sorted-cites} option automatically disables
+% compression. This is probably a feature.
+% \begin{macrocode}
+\DeclareExclusiveOptions{sorted-cites,non-sorted-cites}
+\DeclareExclusiveOptions{non-compressed-cites,compressed-cites}
+% \end{macrocode}
+%
+% In the bibliography, print page numbers showing where each
+% entry was cited.
+% \begin{macrocode}
+\DeclareBooleanOption{backrefs}
+% \end{macrocode}
+%
+% Option for giving information about the available options:
+% \begin{macrocode}
+\DeclareBooleanOption{?}
+% \end{macrocode}
+%
+% This option means to forgo loading of the \pkg{textcmds} and
+% \pkg{mathscinet} packages.
+% \begin{macrocode}
+\DeclareBooleanOption{lite}
+% \end{macrocode}
+%
+% This option can be used by later releases as a sign that fall-back
+% adaptations need to be done.
+% \begin{macrocode}
+\DeclareBooleanOption{beta}
+% \end{macrocode}
+%
+% This one is obsolete now.
+% \begin{macrocode}
+\DeclareBooleanOption{jpa}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareBooleanOption{bibtex-style}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\ExecuteOptions{numeric,traditional-quotes,sorted-cites,compressed-cites}
+
+\ProcessOptions\relax
+
+\ProcessExclusiveOptions
+% \end{macrocode}
+%
+% \begin{macrocode}
+\IfOption{backrefs}{%
+ \IfFileExists{hyperref.sty}{%
+ \RequirePackage{hyperref}[1999/07/08]
+ }{}%
+ \IfFileExists{backref.sty}{%
+ \RequirePackage{backref}[1999/05/30]
+ }{}%
+}{}
+% \end{macrocode}
+%
+% \subsubsection{The \opt{?} option}
+%
+% Note that in the following auxiliary package list, \pkg{getwidth}
+% is not (yet) included.
+% \begin{macrocode}
+\IfOption{?}{%
+ \typeout{^^J%
+ Documentation for the amsrefs package is found in amsrdoc.dvi^^J%
+ (or .pdf or .tex).
+ ^^J%
+ }%
+}{}%
+% \end{macrocode}
+%
+% \subsection{Loading auxiliary packages}
+% Now, if these other packages make use of the \pkg{pcatcode} package
+% like they should, then we don't need to make any fuss here about
+% the special catcode of \texttt{'}. Just load the packages.
+% \begin{macrocode}
+\RequirePackage{rkeyval}[2001/12/22]
+% \end{macrocode}
+%
+% \subsubsection{The \opt{lite} option}
+%
+% In my opinion, this is misguided, since \pkg{amsrefs} shouldn't
+% be loading these packages to begin with. But it's too late to
+% change it now.
+%
+% \begin{macrocode}
+\IfOption{lite}{% True? Then don't load the next two packages.
+}{% False? OK, let's load them:
+ \RequirePackage{textcmds}[2001/12/14]
+ \RequirePackage{mathscinet}[2002/01/01]
+}
+% \end{macrocode}
+%
+% \subsection{Key-value setup}
+%
+% \begin{macro}{\BibField}
+% This provides easy access to individual fields for user-defined
+% formatting functions.
+% \begin{macrocode}
+\newcommand{\BibField}[1]{\csname bib'#1\endcsname}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\IfEmptyBibField}
+% A convenient partial application of \cn{rkvIfEmpty}.
+% \begin{macrocode}
+\newcommand{\IfEmptyBibField}{\rkvIfEmpty{bib}}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Standard field names (the \texttt{bib} group)}
+%
+% And here are the predefined key names. You could always add some
+% more if you needed them. Only worry is about compatibility if you
+% want to share your data with other people.
+%
+% \begin{macro}{\fld@elt}
+% \begin{macro}{\name}
+% We want the list macros used above to be unexpandable except when
+% special processing is done. (It's not clear to me there's any
+% real benefit to using these instead of just using \cn{do}.---dmj)
+% \begin{macrocode}
+\let\fld@elt=?
+\let\name=?
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% First the fields that could be repeated more than once in a single
+% entry. Maybe publisher should be allowed to repeat also, for
+% co-published works. But then need to worry about the address
+% handling.
+% \begin{macrocode}
+\DefineAdditiveKey{bib}{author}{\name}
+\DefineAdditiveKey{bib}{editor}{\name}
+\DefineAdditiveKey{bib}{translator}{\name}
+\DefineAdditiveKey{bib}{contribution}{\fld@elt}
+\DefineAdditiveKey{bib}{isbn}{\fld@elt}
+\DefineAdditiveKey{bib}{issn}{\fld@elt}
+\DefineAdditiveKey{bib}{review}{\fld@elt}
+\DefineAdditiveKey{bib}{partial}{\fld@elt}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DefineSimpleKey{bib}{address}
+\DefineSimpleKey{bib}{book}
+\DefineSimpleKey{bib}{booktitle}
+\DefineSimpleKey{bib}{conference}
+%\DefineSimpleKey{bib}{contributor}
+\DefineSimpleKey{bib}{copula}
+\DefineSimpleKey{bib}{date}
+\DefineSimpleKey{bib}{doi}
+\DefineSimpleKey{bib}{edition}
+\DefineSimpleKey{bib}{eprint}
+\DefineSimpleKey{bib}{fulljournal}
+\DefineSimpleKey{bib}{hyphenation}
+\DefineSimpleKey{bib}{institution}
+\DefineSimpleKey{bib}{journal}
+\DefineSimpleKey{bib}{label}
+\DefineSimpleKey{bib}{language}
+\DefineSimpleKey{bib}{name}
+\DefineSimpleKey{bib}{note}
+\DefineSimpleKey{bib}{number}
+\DefineSimpleKey{bib}{organization}
+\DefineSimpleKey{bib}{pages}
+\DefineSimpleKey{bib}{part}
+\DefineSimpleKey{bib}{place}
+\DefineSimpleKey{bib}{publisher}
+\DefineSimpleKey{bib}{reprint}
+\DefineSimpleKey{bib}{school}
+\DefineSimpleKey{bib}{series}
+\DefineSimpleKey{bib}{setup}
+\DefineSimpleKey{bib}{status}
+\DefineSimpleKey{bib}{subtitle}
+\DefineSimpleKey{bib}{title}
+\DefineSimpleKey{bib}{translation}
+\DefineSimpleKey{bib}{type}
+\DefineSimpleKey{bib}{url}
+\DefineSimpleKey{bib}{volume}
+\DefineSimpleKey{bib}{xref}
+\DefineSimpleKey{bib}{year}
+% \end{macrocode}
+% The \fld{transition} key is used when we want to insert punctuation
+% or other material at a given point in the sequence
+% unconditionally. The key appears to have a non-empty value to
+% \cn{IfEmptyBibField}, but its value (expansion) is empty.
+% \begin{macrocode}
+\DefineDummyKey{bib}{transition}
+% \end{macrocode}
+%
+% \subsubsection{Auxiliary properties (the \texttt{prop} group)}
+%
+% \begin{macrocode}
+\DefineSimpleKey{prop}{inverted}
+\DefineSimpleKey{prop}{language}
+% \end{macrocode}
+%
+% \subsection{Bibliography type specifications}
+%
+% \begin{macro}{\BibSpec}
+% Accumulate specification material in \cs{toks@}, then define
+% \cs{setbib@TYPE} from it.
+% \begin{macrocode}
+\newcommand{\BibSpec}[2]{%
+ \toks@\@emptytoks
+ \@ifnotempty{#2}{%
+% \end{macrocode}
+% The \cs{@ifnextchar} removes an optional |+| at the beginning of
+% a specification. From then on, each time \cs{bibspec@scan} is
+% invoked, it expects to find four arguments. The four
+% \cs{@empty}s appended to the specification (|#2|) below ensure
+% that this is so.
+% \begin{macrocode}
+ \@ifnextchar{+}{\@xp\bibspec@scan\@gobble}{\bibspec@scan}%
+ #2\@empty\@empty\@empty\@empty
+ }%
+ \@xp\edef\csname setbib@#1\endcsname{\the\toks@}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bibspec@scan}
+% The \cs{bibspec@scan} function scans one field specification
+% from the second arg of \cn{BibSpec}. Each field specification has
+% the form
+% \begin{verbatim}
+% +{punctuation}{prelim material}{field name}
+%\end{verbatim}
+% Note however that because the initial |+| is stripped off by
+% \cs{BibSpec} (see above), the actual order that \cs{bibspec@scan}
+% reads the field specification is
+% \begin{verbatim}
+% #1={punctuation} #2={prelim material} #3={field name} #4=+
+%\end{verbatim}
+% where the fourth argument is actually expected to be either the
+% |+| from the following specification, or one of the special
+% \cs{@empty} tokens inserted by \cs{BibSpec}. If it is neither of
+% these special values, it means we have a malformed specification;
+% so, we issue an error and then try to pick up where we left off.
+% \begin{macrocode}
+\def\bibspec@scan#1#2#3#4{%
+ \add@toks@{\bib@append{#1}{#2}}%
+ \edef\@tempa{%
+ \toks@{\the\toks@ \@xp\@nx\csname bib'#3\endcsname}%
+ }%
+ \@tempa
+ \ifx\@empty#4%
+ \@xp\@gobble % end the recursion
+ \else
+ \ifx +#4\else\bibspec@scan@error\fi
+ \fi
+ \bibspec@scan
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bibspec@scan@error}
+% \begin{macrocode}
+\def\bibspec@scan@error{\amsrefs@error{Bad BibSpec: Expected '+'}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bib@append}
+% The function \cs{bib@append} prints the value of a field, together
+% with associated punctuation and font changes, unless the value is
+% empty. Arg 1 is punctuation (that may need to be swapped with a
+% preceding line break), arg 2 gives the space to be added after the
+% punctuation, and possibly a function to be applied to the contents
+% of arg 3, which is
+% a macro containing the field
+% value. So if we have \cn{moo} and \cn{bib'pages}, from
+% \verb'pages={21\ndash 44}', then we want to arrange to call
+% \begin{verbatim}
+% \moo{21\ndash 44}
+%\end{verbatim}
+% We don't want to simply call \cs{moo}\cs{bib'bar} because that makes
+% it rather difficult for \cs{moo} to look at the contents of
+% \cs{bib@bar}.
+% \begin{macrocode}
+\def\bib@append#1#2#3{%
+ \ifx\@empty#3%
+ \else
+% \end{macrocode}
+% \begin{bug}
+% Need better error message here.
+% \end{bug}
+% \begin{macrocode}
+ \ifx\relax#3%
+ \errmessage{#3=\relax}%
+ \else
+ \begingroup
+ \series@index\m@ne
+ \def\current@bibfield{#3}%
+ \@ifempty{#1}{%
+ \@temptokena{\ifnum\lastkern=\@ne\ignorespaces\fi #2}%
+ }{%
+ \@temptokena{\SwapBreak{#1}#2}%
+ }%
+ \toks@\@xp{#3}%
+ \edef\@tempa{\the\@temptokena{\the\toks@}}%
+ \rkvIfAdditive#3{}{%
+ \get@current@properties
+ \select@auxlanguage
+ }%
+ \@tempa
+ \endgroup
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\select@auxlanguage}
+% \begin{macrocode}
+\def\select@auxlanguage{%
+ \ifx\prop'language\@empty
+ \else
+ \@xp\selectlanguage\@xp{\prop'language}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\erase@field}
+% There are some fields that can appear in more than one place in a
+% reference, depending on context. For example, if a book has an
+% editor but no author, the editor appears at the beginning of the
+% entry, but if the book has both an editor and an author, the
+% editor appears at the end of the entry. A simple way to handle
+% this is to ``erase'' the \fld{editor} field after printing it,
+% which is what \cs{erase@field} is for.
+%
+% The obvious definition of \cs{erase@field} is
+% \begin{verbatim}
+% \def\erase@field#1{\global\let#1\@empty}
+%\end{verbatim}
+% but that doesn't work because the top-level value of
+% \pkg{rkeyval} fields isn't \cs{@empty}; instead, it contains a
+% setter function used by \cs{RestrictedSetKeys} when processing a
+% key-value list (see \cs{rkv@DSAK}, \cs{rsk@set@a} and
+% \cs{rsk@set@b}).
+%
+% On the other hand, rewriting the field locally won't work
+% either, since \cs{erase@field} will typically be executed inside
+% the group established by \cs{bib@append}. Instead, we want to
+% rewrite the value right after \cs{bib@append}'s group ends. One
+% way to do this would be to keep a list of fields to be erased and
+% have \cs{bib@append} iterate over the list after its
+% \ncn{endgroup}.
+%
+% However, as long as the call to \cs{erase@field}
+% is never nested within any deeper groups, it's simpler just to
+% use \cs{aftergroup}, which is what we'll do (``Sufficient unto
+% the day is the evil thereof'' and all that).
+% \begin{macrocode}
+\def\erase@field#1{%
+ \aftergroup\let\aftergroup#1\aftergroup\@empty
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\get@current@properties}
+% This retrieves the auxiliary properties for the current field
+% value, as defined by \cs{current@bibfield} and
+% \cs{series@index}.
+% \begin{macrocode}
+\def\get@current@properties{%
+ \begingroup
+ \@xp\get@nth@property\@xp\@tempa\current@bibfield\series@index
+ \edef\@tempa{%
+ \@nx\RestrictedSetKeys{}{prop}{%
+ \def\@nx\@tempa{\@nx\prop@reset \@nx\the\@nx\rsk@toks}%
+ }{\@tempa}%
+ }%
+ \@tempa
+ \@xp\endgroup
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\BibSpecAlias}
+% This is a \cs{def} rather than a \cs{let} because using \cs{let}
+% would make \cn{BibSpecAlias} statements order-sensitive in a way
+% that seems frequently to be a stumbling block to unwary package
+% writers. But then we should probably do at least the simplest
+% kind of infinite loop check.
+% \begin{macrocode}
+\newcommand{\BibSpecAlias}[2]{%
+ \@xp\def\@xp\@tempa\@xp{\csname setbib@#1\@xp\endcsname}%
+ \@xp\ifx\csname setbib@#2\endcsname\@tempa
+ \amsrefs@error{%
+ Mirror alias #1->#2 not allowed (infinite loop)}\@ehc
+ \else
+ \@xp\def\csname setbib@#1\@xp\endcsname
+ \@xp{\csname setbib@#2\endcsname}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{The standard bibliography types}
+%
+% \begin{macrocode}
+\BibSpec{article}{%
+ +{} {\PrintAuthors} {author}
+ +{,} { \textit} {title}
+ +{.} { } {part}
+ +{:} { \textit} {subtitle}
+ +{,} { \PrintContributions} {contribution}
+ +{.} { \PrintPartials} {partial}
+ +{,} { } {journal}
+ +{} { \textbf} {volume}
+% \end{macrocode}
+% The date form is tricky depending on presence or absence of DOI.
+% \begin{macrocode}
+ +{} { \PrintDatePV} {date}
+ +{,} { \issuetext} {number}
+ +{,} { \eprintpages} {pages}
+ +{,} { } {status}
+ +{,} { \PrintDOI} {doi}
+ +{,} { available at \eprint} {eprint}
+ +{} { \parenthesize} {language}
+ +{} { \PrintTranslation} {translation}
+ +{;} { \PrintReprint} {reprint}
+ +{.} { } {note}
+ +{.} {} {transition}
+ +{} {\SentenceSpace \PrintReviews} {review}
+}
+
+\BibSpec{partial}{%
+ +{} {} {part}
+ +{:} { \textit} {subtitle}
+ +{,} { \PrintContributions} {contribution}
+ +{,} { } {journal}
+ +{} { \textbf} {volume}
+ +{} { \PrintDatePV} {date}
+ +{,} { \issuetext} {number}
+ +{,} { \eprintpages} {pages}
+}
+
+\BibSpec{contribution}{%
+ +{} {} {type}
+ +{} { by \PrintNameList} {author}
+}
+
+\BibSpec{book}{%
+ +{} {\PrintPrimary} {transition}
+ +{,} { \textit} {title}
+ +{.} { } {part}
+ +{:} { \textit} {subtitle}
+ +{,} { \PrintEdition} {edition}
+ +{} { \PrintEditorsB} {editor}
+ +{,} { \PrintTranslatorsC} {translator}
+ +{,} { \PrintContributions} {contribution}
+ +{,} { } {series}
+ +{,} { \voltext} {volume}
+ +{,} { } {publisher}
+ +{,} { } {organization}
+ +{,} { } {address}
+ +{,} { \PrintDateB} {date}
+ +{,} { } {status}
+ +{} { \parenthesize} {language}
+ +{} { \PrintTranslation} {translation}
+ +{;} { \PrintReprint} {reprint}
+ +{.} { } {note}
+ +{.} {} {transition}
+ +{} {\SentenceSpace \PrintReviews} {review}
+}
+
+\BibSpec{collection.article}{%
+ +{} {\PrintAuthors} {author}
+ +{,} { \textit} {title}
+ +{.} { } {part}
+ +{:} { \textit} {subtitle}
+ +{,} { \PrintContributions} {contribution}
+ +{,} { \PrintConference} {conference}
+ +{} {\PrintBook} {book}
+ +{,} { } {booktitle}
+ +{,} { \PrintDateB} {date}
+ +{,} { pp.~} {pages}
+ +{,} { } {status}
+ +{,} { \PrintDOI} {doi}
+ +{,} { available at \eprint} {eprint}
+ +{} { \parenthesize} {language}
+ +{} { \PrintTranslation} {translation}
+ +{;} { \PrintReprint} {reprint}
+ +{.} { } {note}
+ +{.} {} {transition}
+ +{} {\SentenceSpace \PrintReviews} {review}
+}
+
+\BibSpec{conference}{%
+ +{} {} {title}
+ +{} {\PrintConferenceDetails} {transition}
+}
+
+\BibSpec{innerbook}{%
+ +{,} { } {title}
+ +{.} { } {part}
+ +{:} { } {subtitle}
+ +{,} { \PrintEdition} {edition}
+ +{} { \PrintEditorsB} {editor}
+ +{,} { \PrintTranslatorsC} {translator}
+ +{,} { \PrintContributions} {contribution}
+ +{,} { } {series}
+ +{,} { \voltext} {volume}
+ +{,} { } {publisher}
+ +{,} { } {organization}
+ +{,} { } {address}
+ +{,} { \PrintDateB} {date}
+ +{.} { } {note}
+}
+
+\BibSpec{report}{%
+ +{} {\PrintPrimary} {transition}
+ +{,} { \textit} {title}
+ +{.} { } {part}
+ +{:} { \textit} {subtitle}
+ +{,} { \PrintEdition} {edition}
+ +{,} { \PrintContributions} {contribution}
+ +{,} { Technical Report } {number}
+ +{,} { } {series}
+ +{,} { } {organization}
+ +{,} { } {address}
+ +{,} { \PrintDateB} {date}
+ +{,} { \eprint} {eprint}
+ +{,} { } {status}
+ +{} { \parenthesize} {language}
+ +{} { \PrintTranslation} {translation}
+ +{;} { \PrintReprint} {reprint}
+ +{.} { } {note}
+ +{.} {} {transition}
+ +{} {\SentenceSpace \PrintReviews} {review}
+}
+
+\BibSpec{thesis}{%
+ +{} {\PrintAuthors} {author}
+ +{,} { \textit} {title}
+ +{:} { \textit} {subtitle}
+ +{,} { \PrintThesisType} {type}
+ +{,} { } {organization}
+ +{,} { } {address}
+ +{,} { \PrintDateB} {date}
+ +{,} { \eprint} {eprint}
+ +{,} { } {status}
+ +{} { \parenthesize} {language}
+ +{} { \PrintTranslation} {translation}
+ +{;} { \PrintReprint} {reprint}
+ +{.} { } {note}
+ +{.} {} {transition}
+ +{} {\SentenceSpace \PrintReviews} {review}
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\BibSpecAlias{periodical}{book}
+\BibSpecAlias{collection}{book}
+\BibSpecAlias{proceedings}{book}
+\BibSpecAlias{manual}{book}
+\BibSpecAlias{miscellaneous}{book}
+\BibSpecAlias{misc}{miscellaneous}
+\BibSpecAlias{unpublished}{book}
+\BibSpecAlias{proceedings.article}{collection.article}
+\BibSpecAlias{techreport}{report}
+% \end{macrocode}
+%
+% \begin{macro}{\setbib@incollection}
+% \begin{macrocode}
+\edef\setbib@incollection{%
+ \@xp\@nx\csname setbib@collection.article\endcsname
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\setbib@inproceedings}
+% \begin{macrocode}
+\edef\setbib@inproceedings{%
+ \@xp\@nx\csname setbib@collection.article\endcsname
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Some more entry types for implementing abbreviations.
+% \begin{macrocode}
+\BibSpec{name}{%
+ +{} {\PrintAuthors} {name}
+}
+
+\BibSpec{publisher}{%
+ +{,} { } {publisher}
+ +{,} { } {address}
+}
+% \end{macrocode}
+%
+% \subsection{The \env{biblist} environment}
+%
+% The \env{biblist} environment can be used with a section or chapter
+% heading.
+%
+% Use a standard \lat/ counter for numbering bibliography items.
+% \begin{macrocode}
+\newcounter{bib}
+% \end{macrocode}
+%
+% \begin{environment}{biblist}
+% \begin{macrocode}
+\newenvironment{biblist}{%
+ \setcounter{bib}\z@
+ \@biblist
+}{%
+ \@endbiblist
+}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{environment}{biblist*}
+% \begin{macrocode}
+\newenvironment{biblist*}{%
+ \@biblist
+}{%
+ \@endbiblist
+}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{macro}{\@biblist}
+% \begin{macrocode}
+\newcommand\@biblist[1][]{%
+ \stepcounter{bib@env}
+ \normalfont
+ \footnotesize
+ \labelsep .5em\relax
+ \list{\BibLabel}{%
+ \restore@labelwidth
+ \@maxlabelwidth\z@
+ \@nmbrlisttrue
+ \def\@listctr{bib}%
+ \let\makelabel\bib@mklab
+ #1\relax
+ }%
+ \sloppy
+% \end{macrocode}
+% Discourage page breaks within bibliography entries and disable them
+% completely for entries that are less than four lines long.
+% \begin{macrocode}
+ \interlinepenalty\@m
+ \clubpenalty\@M
+ \widowpenalty\clubpenalty
+ \frenchspacing
+ \ResetCapSFCodes
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@endbiblist}
+% Change error for empty list (no items) to warning, to allow authors
+% to leave their bibliography temporarily empty during writing:
+% \begin{macrocode}
+\def\@endbiblist{%
+ \save@labelwidth
+ \def\@noitemerr{\@latex@warning{Empty bibliography list}}%
+ \endlist
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@maxlabelwidth}
+% \begin{macrocode}
+\newdimen\@maxlabelwidth
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bib@mklab}
+% \begin{macrocode}
+\def\bib@mklab#1{%
+ \settowidth\@tempdima{#1}%
+ \ifdim \@tempdima > \@maxlabelwidth
+ \global\@maxlabelwidth\@tempdima
+ \fi
+ #1\hfil
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\newcounter{bib@env}
+% \end{macrocode}
+%
+% \begin{macro}{\save@labelwidth}
+% \begin{macrocode}
+\def\save@labelwidth{%
+ \if@filesw
+ \immediate\write\@auxout{%
+ \string\newlabel{[bibenv:\the\c@bib@env]}{\the\@maxlabelwidth}%
+ }%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\restore@labelwidth}
+% \begin{macrocode}
+\def\restore@labelwidth{%
+ \@xp\ifx \csname r@[bibenv:\the\c@bib@env]\endcsname \relax
+ \resetbiblist{00}%
+ \else
+ \@xp\labelwidth\csname r@[bibenv:\the\c@bib@env]\endcsname
+ \leftmargin\labelwidth
+ \advance\leftmargin\labelsep
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ResetCapSFCodes}
+% Presumably this is here because there has been a problem in the
+% past with packages that change the \cs{catcode}s of capital
+% letters.
+% \begin{macrocode}
+\providecommand{\ResetCapSFCodes}{%
+ \count@=`\A
+ \def\@tempa{%
+ \sfcode\count@=\@m
+ \advance\count@\@ne
+ \ifnum\count@>`\Z\relax \expandafter\@gobble \fi
+ \@tempa
+ }%
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\CurrentBib}
+% In case this is undefined sometimes.
+% \begin{macrocode}
+\def\CurrentBib{??}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\BibLabel}
+% \begin{macrocode}
+\newcommand{\BibLabel}{%
+ [\hyper@anchorstart{cite.\CurrentBib}\relax\thebib\hyper@anchorend]%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\resetbiblist}
+% \begin{macrocode}
+\newcommand{\resetbiblist}[1]{%
+ \settowidth\labelwidth{\def\thebib{#1}\BibLabel}%
+ \leftmargin\labelwidth
+ \ifdim\labelwidth=\z@
+ \leftmargin=1em
+ \itemindent=-\leftmargin
+ \else
+ \advance\leftmargin\labelsep
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Processing bibliography entries}
+%
+% There are several things one might want to do when a \cn{bib} entry
+% is encountered:
+% \begin{enumerate}
+%
+% \item Format and print it. This corresponds to the direct entry
+% of bibliography items as described in section~2.1 of the users's
+% guide.
+%
+% \item Copy it into a \fn{.bbl} file. This corresponds to the use
+% of \cn{bibselect} and an external \fn{.ltb} database as described
+% in section~2.2 of the user's guide.
+%
+% \item Store the full information in memory. This is done by
+% \cn{bib*}.
+%
+% \end{enumerate}
+%
+% \begin{macro}{\bib}
+% Here is where the rubber hits the road.
+% \begin{macrocode}
+\newcommand{\bib}{%
+ \begingroup
+ \@ifstar{%
+ \@tempswatrue
+ \let\@bibdef\star@bibdef
+ \BibItem
+ }{%
+ \@tempswafalse
+ \BibItem
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\BibItem}
+% \MacroArgs
+% \macroarg{1}{citekey}
+% \macroarg{2}{bibtype}
+% \begin{macrocode}
+\newcommand{\BibItem}[2]{%
+ \def\@tempa{#1}%
+ \edef\@tempb{%
+ \@nx\@bibdef\@xp\@nx\csname setbib@#2\endcsname{#2}%
+ {\macrotext\@tempa}%
+ }%
+ \@tempb
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@bibdef}
+% \cs{@bibdef} is a pointer to the procedure that should be handed
+% the entry's key-value pairs. It has one of four values:
+% \begin{enumerate}
+%
+% \item \cs{star@bibdef}
+%
+% \item \cs{normal@bibdef}
+%
+% \item \cs{copy@bibdef}
+%
+% \item \cs{selective@bibdef}
+%
+% \end{enumerate}
+% \MacroArgs
+% \macroarg{1}{\cs{setbib@}bibtype}
+% \macroarg{2}{bibtype}
+% \macroarg{3}{citekey}
+% \begin{macrocode}
+\AtBeginDocument{\let\@bibdef\normal@bibdef}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bib@exec}
+% And \cs{bib@exec} is a pointer to the procedure that
+% \cs{normal@bibdef} will invoke to process the key-value pairs
+% after they've been parsed. It has one
+% of these values:
+% \begin{enumerate}
+%
+% \item \cs{bib@store}
+%
+% \item \cs{bib@print}
+%
+% \end{enumerate}
+% \MacroArgs
+% \macroarg{1}{citekey}
+% \macroarg{2}{\cs{the}\cs{rsk@toks}}
+% \macroarg{3}{\cs{setbib@}bibtype}
+% \begin{macrocode}
+\AtBeginDocument{\let\bib@exec\bib@print}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{\cs{@bibdef} Implementations}
+%
+% \begin{macro}{\normal@bibdef}
+% \MacroArgs
+% \macroarg{1}{\cs{setbib@}bibtype}
+% \macroarg{2}{bibtype}
+% \macroarg{3}{citekey}
+% \begin{macrocode}
+\def\normal@bibdef#1#2#3{%
+% \end{macrocode}
+% \cs{CurrentBibType} is used by \pkg{export-bibtex}, but there
+% might be a better way to handle it. (dmj)
+% \begin{macrocode}
+ \def\CurrentBibType{#2}%
+ \ifx\relax#1%
+ \amsrefs@error{Undefined entry type: #2}\@ehc
+ \let#1\setbib@misc
+ \fi
+ \RestrictedSetKeys{}{bib}%
+ {\bib@exec{#3}{\the\rsk@toks}{#1}\endgroup}%
+}
+
+\let\@bibdef\normal@bibdef
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\star@bibdef}
+% \MacroArgs
+% \macroarg{1}{\cs{setbib@}bibtype}
+% \macroarg{2}{bibtype}
+% \macroarg{3}{citekey}
+% \begin{macrocode}
+\def\star@bibdef{%
+ \let\bib@exec\bib@store
+ \normal@bibdef
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\copy@bibdef}
+% This is a variation that copies everything into the \fn{.bbl}
+% file. Used by \cn{bibselect*} and \cn{bib*} inside \fn{.ltb}
+% files.
+% \begin{macrocode}
+\def\copy@bibdef{%
+ \if@tempswa
+ \@xp\defer@bibdef
+ \else
+ \@xp\copy@bibdef@a
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\copy@bibdef@a}
+% \begin{macrocode}
+\def\copy@bibdef@a#1#2#3#4{%
+ \@open@bbl@file
+ \process@xrefs{#4}%
+ \bbl@write{%
+ \string\bib\if@tempswa*\fi{#3}{#2}\string{\iffalse}\fi
+ }%
+% \end{macrocode}
+% Since we're supplying our own definition of \cs{rsk@set}, we
+% don't actually need the group argument, so we leave it out to
+% save a few tokens.
+% \begin{macrocode}
+ \RestrictedSetKeys{\global\let\rsk@set\bbl@copy}\@empty
+ {\bbl@write{\iffalse{\fi\string}^^J}%
+ \endgroup}{#4}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\catcode`\:=11
+
+\def\modify@xref@fields{%
+ \let\set:bib'author\output@xref@a
+ \let\set:bib'editor\output@xref@a
+ \let\set:bib'translator\output@xref@a
+ \let\set:bib'journal\output@xref@a
+ \let\set:bib'publisher\output@xref@a
+ \def\set:bib'xref##1##2{\output@xref@{##1}\@empty}%
+}
+
+\catcode`\:=12
+
+\def\process@xrefs#1{%
+ \begingroup
+ \RestrictedSetKeys{\modify@xref@fields}{bib}{\the\rsk@toks}{#1}%
+ \endgroup
+}
+
+\def\output@xref@a#1#2{%
+ \def\@tempa{#1}%
+ \lowercase{\def\@tempb{#1}}%
+ \ifx\@tempa\@tempb
+ \output@xref@{#1}%
+ \fi
+}
+
+\def\output@xref@#1{%
+ \@ifnotempty{#1}{%
+ \@ifundefined{bi@#1}{}{%
+ \begingroup
+ \let\star@bibdef\copy@bibdef@a
+ \csname bi@#1\endcsname
+ \endgroup
+ }%
+ \@xp\g@undef\csname bi@#1\endcsname
+ }%
+}
+% \end{macrocode}
+%
+% \begin{macro}{\bbl@copy}
+% \begin{macrocode}
+\def\bbl@copy#1\endcsname#2{%
+ \begingroup
+ \def\@tempa{#1}%
+ \toks@{{#2}}%
+ \star@{\bbl@copy@a}{}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bbl@copy@a}
+% \begin{macrocode}
+\def\bbl@copy@a#1{%
+ \@ifnotempty{#1}{%
+ \add@toks@{*{#1}}%
+ }%
+ \bbl@write{ \space\@tempa=\the\toks@,}%
+ \endgroup
+ \rsk@resume
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\selective@bibdef}
+% This is a variation that ignores anything not having a known
+% citation key. Used by \cn{bibselect}.
+%
+% \MacroArgs
+% \macroarg{1}{\cs{setbib@}bibtype}
+% \macroarg{2}{bibtype}
+% \macroarg{3}{citekey}
+% \begin{macrocode}
+\def\selective@bibdef#1#2#3{%
+ \@xp\selbibdef@a\csname b@#3\endcsname{#1}{#2}{#3}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\selbibdef@a}
+% \begin{macrocode}
+\def\selbibdef@a#1{%
+ \def\@tempa{\endgroup\@gobblefour}%
+ \ifx\relax#1\else \@xp\selbibdef@b#1\@nil \fi
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\selbibdef@b}
+% \begin{macrocode}
+\def\selbibdef@b#1#2#3\@nil{%
+ \ifx 1#2\let\@tempa\copy@bibdef\fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\defer@bibdef}
+% This is a variation that ignores anything not having a known
+% citation key. Used by \cn{bibselect}.
+%
+% \MacroArgs
+% \macroarg{1}{\cs{setbib@}bibtype}
+% \macroarg{2}{bibtype}
+% \macroarg{3}{citekey}
+% \macroarg{4}{key-val pairs}
+% \begin{macrocode}
+\def\defer@bibdef#1#2#3#4{%
+ \@xp\gdef\csname bi@#3\endcsname{%
+ \bib*{#3}{#2}{#4}%
+ }%
+ \@xp\addto@defer@list \csname bi@#3\endcsname
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bibdefer@list}
+% \begin{macrocode}
+\let\bibdefer@list\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\addto@defer@list}
+% \begin{macrocode}
+\def\addto@defer@list#1{%
+ \begingroup
+ \def\do{\@nx\do\@nx}%
+ \xdef\bibdefer@list{\bibdefer@list\do#1}%
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{\cs{bib@exec} Implementations}
+%
+% \begin{macro}{\bib@store}
+% This is the easy one. It just stores the entire set of key-value
+% pairs in \cs{bi@}\emph{citekey}.
+% \begin{macrocode}
+\def\bib@store#1{%
+ \afterassignment\@gobble
+ \@xp\xdef\csname bi@#1\endcsname
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\numeric@refs}
+% \begin{macrocode}
+\def\numeric@refs{00}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bib@print}
+% \MacroArgs
+% \macroarg{1}{citekey}
+% \macroarg{2}{\cs{the}\cs{rsk@toks}}
+% \macroarg{3}{\cs{setbib@}bibtype}
+% \begin{macrocode}
+\def\bib@print#1#2#3{%
+ \bib@start{#1}%
+ \let\setbib@@#3%
+ #2\relax % execute definitions locally
+ \bib@resolve@xrefs
+ \bib@field@patches
+ \bib@selectlanguage
+ \generate@label
+ \bib'setup
+ \bib@cite{#1}%
+ \kern\@ne sp
+ \ifx\setbib@@\setbib@article
+ \ifx\bib'booktitle\@empty
+ \ifx\bib'book\@empty
+ \ifx\bib'conference\@empty
+ \else
+ \let\setbib@@\setbib@incollection
+ \fi
+ \else
+ \let\setbib@@\setbib@incollection
+ \fi
+ \else
+ \let\setbib@@\setbib@incollection
+ \fi
+ \fi
+ \setbib@@
+ \bib@end
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bib@print@inner}
+% Note that the order of the arguments is reversed with respect to
+% \cs{bib@print}. Maybe that isn't such a great idea.
+% \MacroArgs
+% \macroarg{1}{\cs{setbib@}bibtype}
+% \macroarg{2}{\cs{the}\cs{rsk@toks}}
+% \begin{macrocode}
+\def\bib@print@inner#1#2{%
+ \begingroup
+ #2\relax % execute definitions locally
+ \bib@field@patches
+ \bib'setup
+ #1%
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\current@citekey}
+% \begin{macrocode}
+\let\current@citekey\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\prev@citekey}
+% \begin{macrocode}
+\let\prev@citekey\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bib@start}
+% There used to be more to it.
+% \begin{macrocode}
+\def\bib@start#1{%
+ \begingroup
+ \def\current@citekey{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bib@end}
+% Instead of being handled by \cs{bib@end}, ending punctuation is
+% normally handled via the \fld{transition} field (q.v.)
+% \begin{macrocode}
+\def\bib@end{%
+ \relax
+ \@xp\PrintBackRefs\@xp{\CurrentBib}%
+ \par
+ \save@primary
+ \global\let\prev@citekey\current@citekey
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Resolving cross-references}
+%
+% \begin{macro}{\bib@resolve@xrefs}
+% \begin{macrocode}
+\def\bib@resolve@xrefs{%
+ \xref@check@c\bib'xref
+ \xref@check@a\bib'author
+ \xref@check@a\bib'editor
+ \xref@check@a\bib'translator
+ \xref@check@b\bib'journal
+ \xref@check@b\bib'publisher
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\xref@check@a}
+% Resolve a contributor (typically a \cn{DefineName}) alias.
+% Requires rebuilding the list.
+% \begin{macrocode}
+\def\xref@check@a#1{%
+ \ifx\@empty#1\relax
+ \else
+ \begingroup
+ \toks@\@emptytoks
+ \@temptokenb\@emptytoks
+ \series@index\z@
+ \def\name{\xref@check@aa#1}%
+ #1\relax
+ \edef\@tempa{%
+ \def\@nx#1{\the\toks@}%
+ \the\@temptokenb
+ }%
+ \@xp\endgroup
+ \@tempa
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\xref@check@aa}
+% \begin{macrocode}
+\def\xref@check@aa#1#2{%
+ \advance\series@index\@ne
+ \def\@tempa{#2}%
+ \lowercase{\def\@tempb{#2}}%
+ \ifx\@tempa\@tempb
+ \ifx\@tempa\@empty
+ \add@toks@{\name{}}%
+ \else
+ \@ifundefined{bi@#2}{%
+ \BibAbbrevWarning{#2}%
+ \add@toks@{\name{#2}}%
+ }{%
+ \xref@check@ab#1{#2}%
+ }%
+ \fi
+ \else
+ \add@toks@{\name{#2}}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\xref@check@ab}
+% \begin{macrocode}
+\def\xref@check@ab#1#2{%
+ \csname bi@#2\endcsname
+ \ifx\@empty\bib'name
+ \@temptokena{#2}%
+ \else
+ \@temptokena\@xp{\bib'name}%
+ \get@property\@tempa\bib'name
+ \edef\@tempa{%
+ \@nx\addto@hook\@temptokenb{%
+ \@nx\reset@nth@property\@nx#1\the\series@index{\@tempa}%
+ }%
+ }%
+ \@tempa
+ \fi
+ \edef\@tempa{\@nx\add@toks@{\@nx\name{\the\@temptokena}}}%
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\xref@check@b}
+% Resolve a \fld{journal} or \fld{publisher} alias (typically a
+% \cn{DefinePublisher} or \cn{DefineJournal} alias).
+% \begin{macrocode}
+\def\xref@check@b#1{%
+ \ifx\@empty#1%
+ \else
+ \toks@\@xp{#1}%
+ \edef\@tempb{\lowercase{\def\@nx\@tempa{\the\toks@}}}%
+ \@tempb
+ \ifx\@tempa#1\relax % all lowercase
+ \@ifundefined{bi@#1}{%
+ \BibAbbrevWarning{#1}%
+ }{%
+% \end{macrocode}
+% We pass control to \cs{xref@check@c} here to handle inheritance
+% of multiple fields properly. This means some of the checking
+% we've just done gets done again, but I can live with that.
+% \begin{macrocode}
+ \let#1\@empty
+ \xref@check@c\@tempa
+ }%
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\xref@check@c}
+% Resolve an \fld{xref} field.
+% \begin{macrocode}
+\def\xref@check@c#1{%
+ \ifx#1\@empty
+ \else
+ \begingroup
+ \let\DSK@def\xref@add@toks
+ \let\DSK@append\xref@append
+ \toks@\@emptytoks
+ \let\bib@reset\@empty
+% \end{macrocode}
+% The \cs{@for} here is just a fancy way of expanding \arg{1}. (Or
+% is it?)
+% \begin{macrocode}
+ \@for\xref@ID:=#1\do{%
+ \@ifundefined{bi@\xref@ID}{%
+ \XRefWarning{\xref@ID}%
+ }{%
+ \csname bi@\xref@ID\endcsname
+ }%
+ }%
+ \edef\@tempa{\endgroup\the\toks@}%
+ \@tempa
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\xref@add@toks}
+% If any title occurs in an \fld{xref}ed item, assume that it is a book
+% title. This might not always be the best assumption? Let's see how
+% it goes though. [mjd,2001-12-11]
+%
+% \MacroArgs
+% \macroarg{1}{\cs{bib'}field}
+% \macroarg{2}{value}
+% \begin{macrocode}
+\def\xref@add@toks#1#2#3{%
+ \ifx#1\@empty
+ \edef\@tempa{%
+ \@nx\add@toks@{\@xp\@nx\csname\rkv@setter#1\endcsname{#2}{#3}}%
+ }%
+ \@tempa
+ \else
+ \in@\bib'title{#1}%
+ \ifin@
+ \ifx\bib'booktitle\@empty
+ \edef\@tempa{%
+ \@nx\add@toks@{%
+ \@xp\@nx\csname set:bib'booktitle\endcsname
+ }%
+ }%
+ \@tempa
+ \add@toks@{{#2}{#3}}%
+ \fi
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\def\xref@append#1#2#3#4{%
+ \edef\@tempa{%
+ \@nx\add@toks@{\@xp\@nx\csname\rkv@setter#2\endcsname{#3}{#4}}%
+ }%
+ \@tempa
+}
+% \end{macrocode}
+%
+% \begin{macro}{\BibAbbrevWarning}
+% \begin{macrocode}
+\def\BibAbbrevWarning#1{\amsrefs@warning{Abbreviation '#1' undefined}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\XrefWarning}
+% \begin{macrocode}
+\def\XRefWarning#1{\amsrefs@warning{Xref '#1' undefined}}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Bib field preprocessing}
+%
+% \begin{macro}{\current@primary}
+% \begin{macrocode}
+\let\current@primary\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\previous@primary}
+% \begin{macrocode}
+\let\previous@primary\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\save@primary}
+% \begin{macrocode}
+\IfOption{nobysame}{%
+ \let\save@primary\@empty
+}{%
+ \def\save@primary{%
+ \global\let\previous@primary\current@primary
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bib@field@patches}
+% \begin{macrocode}
+\def\bib@field@patches{%
+ \ifx\bib'author\@empty
+ \ifx\bib'editor\@empty
+ \let\current@primary\bib'translator
+ \let\print@primary\PrintTranslatorsA
+ \else
+ \let\current@primary\bib'editor
+ \let\print@primary\PrintEditorsA
+ \fi
+ \else
+ \let\current@primary\bib'author
+ \let\print@primary\PrintAuthors
+ \fi
+ \ifx\bib'address\@empty
+ \let\bib'address\bib'place
+ \fi
+ \ifx\bib'organization\@empty
+ \ifx\bib'institution\@empty
+ \let\bib'organization\bib'school
+ \else
+ \let\bib'organization\bib'institution
+ \fi
+ \fi
+ \ifx\bib'date\@empty
+ \ifx\bib'year\@empty
+ \let\bib@year\bib'status
+ \else
+ \bib@parsedate\bib'year
+ \fi
+ \else
+ \bib@parsedate\bib'date
+ \fi
+% \end{macrocode}
+% Example~21 on page~74 of \emph{Mathematics into
+% Type}~\cite{SOS99} seems to indicate that when the year serves as
+% the volume number, the date should be suppressed. If so, this is
+% where that is done.
+% \begin{macrocode}
+ \def\@tempa{year}%
+ \ifx\bib'volume\@tempa
+ \let\bib'volume\bib@year
+ \let\bib'date\@empty
+ \fi
+% \end{macrocode}
+% \cs{bib'language} is used for producing the printed rendition of
+% the language. \cs{bib@language} needs to be in the form required by
+% \cn{selectlanguage}.
+% \begin{macrocode}
+ \bib@language@fixup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Date setup}
+%
+% \begin{macro}{\bib@year}
+% \begin{macrocode}
+\let\bib@year\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bib@month}
+% \begin{macrocode}
+\let\bib@month\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bib@day}
+% \begin{macrocode}
+\let\bib@day\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bib@parsedate}
+% Parse an ISO 8601 date into its year, month and day components,
+% but without actually verifying that any of the components are
+% numeric. Hmmm.
+% \begin{macrocode}
+\def\bib@parsedate#1{%
+ \@xp\bib@parsedate@a#1---\@nil
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bib@parsedate@a}
+% \begin{macrocode}
+\def\bib@parsedate@a#1-#2-#3-#4\@nil{%
+ \def\bib@year{#1}%
+ \def\bib@month{#2}%
+ \def\bib@day{#3}%
+% \end{macrocode}
+% The rest of this macro tries to rewrite \cs{bib'date} into a
+% normalized form. I'm not sure if this is a good idea.
+% \begin{macrocode}
+ \ifx\@empty\bib@day
+ \ifx\@empty\bib@month
+ \let\bib'date\bib@year
+ \else
+ \def\bib'date{#1-#2}%
+ \fi
+ \else
+ \def\bib'date{#1-#2-#3}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Language setup}
+%
+% \begin{macro}{\bib@language@fixup}
+% \begin{macrocode}
+\def\bib@language@fixup{%
+ \ifx\bib'hyphenation\@empty
+ \ifx\bib'language\@empty
+ \let\bib@language\biblanguagedefault
+ \else
+ \let\bib@language\bib'language
+ \fi
+ \else
+ \let\bib@language\bib'hyphenation
+ \fi
+ \def\@tempa##1 ##2\@nil{\lowercase{\def\bib@language{##1}}}%
+% \end{macrocode}
+% The mysterious \cs{@firstofone} here is to preserve the space
+% before the \cs{@nil}.
+% \begin{macrocode}
+ \@firstofone{\@xp\@tempa\bib@language} \@nil
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bib@selectlanguage}
+% For \cn{bib} purposes we are interested mainly in testing whether
+% the hyphenation patterns are the same. So we use an
+% if-same-patterns test (by which \pkg{babel}'s `english' and
+% `american' compare as equal) rather than an if-same-language test.
+% Also, the way that the \cn{selectlanguage} command checks to see
+% whether a language has been properly defined for babel use is to
+% see if \cs{dateLANGUAGE} is defined. And if we tried to select an
+% undefined language, the result would be a \lat/ error.
+% \begin{macrocode}
+\def\bib@selectlanguage{%
+ \@ifsame@patterns{\languagename}{\bib@language}{}{%
+ \@ifundefined{date\bib@language}{}{%
+ \@xp\selectlanguage\@xp{\bib@language}%
+ }%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@ifsame@patterns}
+% \begin{macrocode}
+\def\@ifsame@patterns#1#2{%
+ \@xp\@ifsamepat\csname l@#1\@xp\endcsname\csname l@#2\endcsname
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@ifsamepat}
+% \begin{macrocode}
+\def\@ifsamepat#1#2{%
+ \ifnum \ifx\relax#1\m@ne\else#1\fi = \ifx\relax#2\m@ne\else#2\fi
+ \@xp\@firstoftwo
+ \else
+ \@xp\@secondoftwo
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\languagename}
+% \begin{macro}{\biblanguageEnglish}
+% \begin{macro}{\biblanguagedefault}
+% \begin{macro}{\bib@language}
+% \begin{macrocode}
+\providecommand{\languagename}{english}
+\def\biblanguageEnglish{english}
+\let\biblanguagedefault\biblanguageEnglish
+\let\bib@language\@empty
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \subsubsection{Citation label setup}
+%
+% \begin{macro}{\generate@label}
+% \begin{macrocode}
+\let\generate@label\relax
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@label}
+% \begin{macrocode}
+\def\cite@label{\@currentlabel}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\alpha@label}
+% \begin{macrocode}
+\let\alpha@label\relax
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bib@cite}
+% When \cs{bib@cite} is called, author name and year are available
+% in \cs{bib@author} and \cs{bib@year}.
+% \MacroArgs
+% \macroarg{1}{citekey}
+% \begin{macrocode}
+\def\bib@cite#1{%
+ \def\CurrentBib{#1}%
+ \alpha@label % modify \thebib if necessary
+ \item\leavevmode
+ \SK@\SK@@label{#1}%
+ \@xp\bib@cite@a\csname b@#1\endcsname
+ \bibcite@write{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\def\bib@cite@a#1{%
+ \ifx\relax#1%
+ \begingroup
+ \auto@protect\etaltext
+ \protected@edef\@tempa{%
+ \gdef\@nx#1{%
+ \@nx\citesel 01{\cite@label}{\bib@label@year}{}%
+ }%
+ }%
+ \@xp\endgroup
+ \@tempa
+ \else
+ \@xp\bib@cite@check\@xp#1#1\@empty\@empty\@empty\@empty\@empty
+ \fi
+}
+% \end{macrocode}
+%
+% \begin{macro}{\bib@cite@check}
+% For the citation key we want to check if it is already defined. But
+% there is a slight problem. There is already one control
+% sequence in use for each bibliography entry, to store the label or
+% the author/year information needed by \cn{cite}. If we introduce
+% another control sequence to check whether a particular cite is
+% multiply defined, then we double the number of control sequences
+% used. For a large bibliography in a book this is fairly serious.
+% This is addressed by using a \cs{citesel} function.
+%
+% \MacroArgs
+% \macroarg{1}{\cs{b@}citekey}
+% \macroarg{2}{\cs{citesel}}
+% \macroarg{3}{cited?}
+% \macroarg{4}{used?}
+% \macroarg{5}{label}
+% \macroarg{6}{year}
+% \macroarg{7}{backrefs}
+% \begin{macrocode}
+\def\bib@cite@check#1#2#3#4#5#6#7{%
+ \ifx 1#4\relax
+ \DuplicateBibKeyWarning
+ \else
+% \end{macrocode}
+% This has gotten \emph{way} out of hand.
+% \begin{macrocode}
+ \begingroup
+ \auto@protect\etaltext
+ \@apply\auto@protect\amsrefs@textsymbols
+ \@apply\auto@protect\amsrefs@textaccents
+ \@tempswafalse
+ \in@\CitePrintUndefined{#5}%
+ \ifin@
+ \let\@tempa\@empty
+ \else
+ \def\@tempa{#5}%
+ \fi
+ \ifx\@tempa\@empty
+ \else
+ \@xp\ifx\@xp\@currentlabel\cite@label
+ \edef\@tempb{\cite@label}%
+ \else
+ \let\@tempb\cite@label
+ \fi
+ \ifx\@tempa\@tempb
+ \def\@tempa{#6}%
+ \ifx\@tempa\bib@label@year
+ \else
+ \@tempswatrue
+ \fi
+ \else
+ \@tempswatrue
+ \fi
+ \fi
+ \if@tempswa
+ \@ifempty{#6}{%
+ \def\@tempa{#5}%
+ \let\@tempb\cite@label
+ }{%
+ \def\@tempa{#5, #6}%
+ \def\@tempb{\cite@label, \bib@label@year}%
+ }%
+ \amsrefs@warning{Citation label for \extr@cite#1 is
+ changing from `\@tempa ' to `\@tempb '}%
+ \fi
+ \protected@edef\@tempa{%
+ \gdef\@nx#1{%
+ \@nx\citesel #31{\cite@label}{\bib@label@year}{#7}%
+ }%
+ }%
+ \@xp\endgroup
+ \@tempa
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bib@label@year}
+% \begin{macrocode}
+\let\bib@label@year\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DuplicateBibKeyWarning}
+% \begin{macrocode}
+\def\DuplicateBibKeyWarning{%
+ \amsrefs@warning{%
+ Duplicate \protect\bib\space key
+ `\CurrentBib ' detected\MessageBreakNS}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bibcite@write}
+% \begin{macrocode}
+\def\bibcite@write#1{%
+ \if@filesw
+ \let\citesel\citesel@write
+ \csname b@#1\endcsname
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citesel@write}
+% \begin{macrocode}
+\def\citesel@write#1#2#3#4#5{%
+ \begingroup
+ \toks@{{#3}{#4}}%
+ \immediate\write\@auxout{\string\bibcite{\CurrentBib}{\the\toks@}}%
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Because duplicate bibs are caught immediately, we don't need
+% \cs{bibcite} to run \cs{@testdef}.
+% \begin{macrocode}
+\AtEndDocument{\let\bibcite\@gobbletwo}
+% \end{macrocode}
+%
+% \subsubsection{Printing the bibliography}
+%
+% \begin{macro}{\bibname}
+% \begin{macrocode}
+\providecommand{\bibname}{Bibliography}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\refname}
+% \begin{macrocode}
+\providecommand{\refname}{References}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{environment}{bibchapter}
+% We need to take a little extra trouble here to pre-expand the
+% \cn{bibname}.
+% \begin{macrocode}
+\newenvironment{bibchapter}[1][\bibname]{%
+ \begingroup
+ \protected@edef\@{\endgroup\protect\chapter*{#1}}%
+ \@
+}{\par}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{environment}{bibsection}
+% And here to pre-expand the \cn{refname}.
+% \begin{macrocode}
+\newenvironment{bibsection}[1][\refname]{%
+ \begingroup
+ \protected@edef\@{\endgroup\protect\section*{#1}}%
+ \@
+}{\par}
+% \end{macrocode}
+% \end{environment}
+%
+% \begin{environment}{bibdiv}
+% Here we try to guess whether this is a book-like document or an
+% article-like document.
+% \begin{macrocode}
+\@ifundefined{chapter}{%
+ \newenvironment{bibdiv}{\bibsection}{\endbibsection}
+}{%
+ \newenvironment{bibdiv}{\bibchapter}{\endbibchapter}
+}
+% \end{macrocode}
+% \end{environment}
+%
+% This is what the standard \cls{book} class has for the bibliography
+% title:
+% \begin{verbatim}
+% \newenvironment{thebibliography}[1]
+% {\chapter*{\bibname
+% \@mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}}%
+% \list{\@biblabel{\@arabic\c@enumiv}}%
+%\end{verbatim}
+%
+% \begin{environment}{thebibliography}
+% \begin{macrocode}
+\renewenvironment{thebibliography}[1]{%
+ \bibdiv
+ \biblist[\resetbiblist{#1}]%
+}{%
+ \endbiblist
+ \endbibdiv
+}
+% \end{macrocode}
+% \end{environment}
+%
+% \subsection{Name, journal and publisher abbreviations}
+%
+% The commands \cn{DefineName}, \cn{DefinePublisher}, and
+% \cn{DefineJournal} are provided to make abbreviations a little
+% easier.
+%
+% \begin{macro}{\DefineName}
+% \begin{macrocode}
+\newcommand{\DefineName}[2]{%
+ \bib*{#1}{name}{name={#2}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DefineJournal}
+% \begin{macrocode}
+\newcommand{\DefineJournal}[4]{%
+ \bib*{#1}{periodical}{
+ issn={#2},
+ journal={#4}
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DefinePublisher}
+% Note that an explicit \fld{address} field in a \cn{bib} entry will
+% override the \fld{address} supplied as part of a
+% \cn{DefinePublisher}.
+% \begin{macrocode}
+\newcommand{\DefinePublisher}[4]{%
+ \bib*{#1}{publisher}{%
+ publisher={#3},
+ address={#4}
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Processing \fn{.ltb} files}
+%
+% If you have a file that contains \pkg{amsrefs}-style
+% \cn{bib} entries, you can use it as a database and extract items
+% from it for use in another document. In typical relatively simple
+% scenarios, the extraction can be done by \lat/ itself on the first
+% pass, so that citations in the text will be successfully resolved
+% on the second pass (possibly even the first, depending on what kind
+% of bibliography sorting is used).
+%
+% \begin{macro}{\bibselect}
+% \begin{macrocode}
+\newcommand{\bibselect}{%
+ \@ifstar{%
+ \let\@bibdef\copy@bibdef
+ \BibSelect
+ }{%
+ \let\@bibdef\selective@bibdef
+ \BibSelect
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\BibSelect}
+% \begin{macrocode}
+\newcommand{\BibSelect}[2][\bblname]{%
+ \if@filesw
+ \typeout{Trying to create bbl file `#1.bbl' ...}%
+ \def\bibselect@msg{%
+ \typeout{ ... rats. Unable to create bbl file.}%
+ }%
+ \let\@open@bbl@file\OpenBBLFile
+ \@for\@tempa:=#2\do{\ReadBibData{\@tempa}}%
+ \fi
+ \@close@bbl@file
+ \@apply\g@undef\bibdefer@list
+ \global\let\bibdefer@list\@empty
+% \end{macrocode}
+% Now read the \fn{.bbl} file we just created.
+% \begin{macrocode}
+ \let\@bibdef\normal@bibdef
+ \@input@{#1.bbl}%
+ \let\BibSelect\MultipleBibSelectWarning
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MultipleBibSelectWarning}
+% \begin{macrocode}
+\newcommand\MultipleBibSelectWarning[2][]{%
+ \amsrefs@warning{%
+ Multiple \string\bibselect 's found (only one
+ \string\bibselect\space per biblist environment is allowed)%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bblname}
+% \begin{macrocode}
+\def\bblname{\jobname}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bib@dbfile}
+% \begin{macrocode}
+\newread\bib@dbfile
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ReadBibData}
+% \begin{macrocode}
+\newcommand{\ReadBibData}[1]{%
+ \IfFileExists{#1.ltb}{%
+ \openin\bib@dbfile=\@filef@und \relax
+ }{%
+ \IfFileExists{#1.ltx}{%
+ \openin\bib@dbfile=\@filef@und \relax
+ }{%
+ \IfFileExists{#1.tex}{%
+ \openin\bib@dbfile=\@filef@und \relax
+ }{%
+ \begingroup
+ \NoBibDBFile{#1}%
+ \let\ReadBibData@a\endgroup
+ }%
+ }%
+ }%
+ \ReadBibData@a
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NoBibDBFile}
+% \begin{macrocode}
+\def\NoBibDBFile#1{%
+ \amsrefs@warning{No data file #1.ltb (.ltx, .tex) found}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ReadBibData@a}
+% \begin{macrocode}
+\def\ReadBibData@a{%
+ \ProvidesFile{\@filef@und}\relax
+ \begingroup
+ \let\star@bibdef\defer@bibdef
+ \ReadBibLoop
+ \endgroup
+ \closein\bib@dbfile
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ReadBibLoop}
+% \begin{macrocode}
+\def\ReadBibLoop{%
+ \ifeof\bib@dbfile
+ \@xp\@gobble
+ \else
+ \read\bib@dbfile to\CurLine
+% \end{macrocode}
+% The \cs{@empty} is in case \cs{CurLine} is empty.
+% \begin{macrocode}
+ \@xp\ReadBibLoop@a\CurLine\@empty\@nil
+ \fi
+ \ReadBibLoop
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ReadBibLoop@e}
+% This traps top-level \cn{bib} commands. Note that:
+% \begin{itemize}
+%
+% \item
+% If \cs{CurLine} doesn't contain a complete \cn{bib} entry, the
+% code chokes.
+%
+% \item
+% I \cn{bib} is not the very first non-space token in a line, it
+% will not be recognized.
+%
+% \end{itemize}
+%
+% \begin{macrocode}
+\long\def\ReadBibLoop@a#1#2\@nil{%
+ \ifx\bib#1%
+ \CurLine % just exec it
+ \else
+% \end{macrocode}
+% We're not done yet. The line may contain something like
+% \cn{DefineName}, so we need to expand the first macro in the line
+% and see if it starts with \cn{bib}. But first we check to make
+% sure that the token we're about to expand isn't \cn{endinput}.
+% \begin{macrocode}
+ \ifx\endinput#1%
+ \let\ReadBibLoop\@empty
+ \else
+% \end{macrocode}
+% And this \cs{@empty} is for the admittedly unlikely case that
+% \cs{CurLine} isn't empty, but its expansion is.
+% \begin{macrocode}
+ \@xp\ReadBibLoop@b#1#2\@empty\@nil
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ReadBibLoop@b}
+% \begin{macrocode}
+\long\def\ReadBibLoop@b#1#2\@nil{%
+ \ifx\bib#1%
+ \CurLine % just exec it
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\let\bbl@out=\relax
+\let\bbl@write\@gobble
+\let\@open@bbl@file\relax
+\let\@close@bbl@file\relax
+% \end{macrocode}
+%
+% \begin{macro}{\OpenBBLFile}
+% \begin{macrocode}
+\def\OpenBBLFile{%
+ \if@filesw
+ % Just use the next unused output stream
+ \count@\count17
+ \advance\count@\@ne
+ \ifnum\count@<\sixt@@n
+ \global\chardef\bbl@out=\count@
+ \immediate\openout\bbl@out=\bblname.bbl\relax
+ \global\let\@close@bbl@file\CloseBBLFile
+ \gdef\bbl@write{\immediate\write\bbl@out}%
+ \else
+ \ch@ck\count@\sixt@@n\write
+ \fi
+ \fi
+ \global\let\@open@bbl@file\relax
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\CloseBBLFile}
+% \begin{macrocode}
+\def\CloseBBLFile{%
+ \immediate\closeout\bbl@out\relax
+ \global\let\@close@bbl@file\relax
+ \global\let\bbl@write\@gobble
+ \global\let\bbl@out\relax
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Citation processing}
+%
+% \subsubsection{The \cs{citesel} structure}
+%
+% The information used by \cn{cite} for key \texttt{moo} is stored in
+% \cs{b@moo} in the form
+% \begin{verbatim}
+% \citesel{status1}{status2}{label}{year}{backref-info}
+%\end{verbatim}%
+%
+% The first status flag is~1 if this key has already been cited
+% earlier in the same document; 0~otherwise. This is used in some
+% bibliography schemes to print a full list of author names for the first
+% citation and an abbreviated author list for subsequent citations.
+%
+% The second status flag is~1 if this key has already been used by a
+% define-cite command (such as \cn{bib}); 0~otherwise. This makes it
+% possible to issue a warning message as soon as the conflict is seen,
+% on the first \lat/ run, instead of on a subsequent run during the
+% processing of the \fn{.aux} file.
+%
+% When an author/year citation scheme is in use, args 3 and~4 hold
+% respectively author names and year. Otherwise arg~3 simply holds
+% a cite label and arg~4 is empty.
+%
+% And finally, arg~5 holds a list of backref pointers indicating the
+% locations in the document where this entry has been cited.
+%
+% \begin{macro}{\citesel@update}
+% \begin{macrocode}
+\def\citesel@update#1#2#3#4#5#6{%
+ \gdef#6{\citesel 1#2{#3}{#4}{#5}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citesel@number}
+% \begin{macrocode}
+\def\citesel@number#1#2#3#4#5{#3}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citesel@year}
+% \begin{macrocode}
+\def\citesel@year#1#2#3#4#5{#4}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citesel}
+% \begin{macrocode}
+\let\citesel\citesel@number
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{The basic \cn{cite} command}
+%
+% Here is the difference between the various optional forms of
+% \cn{cite}:
+% \begin{verbatim}
+% \cite{xyz} -> \cite@a\citesel{xyz}{}
+% -> \cite@bc\b@xyz\citesel{}
+%
+% \cite{xyz}*{blub} -> \cite@a\citesel{xyz}{blub}
+% -> \cite@bc\b@xyz\citesel{blub}
+%
+% \cite[blub]{xyz} -> \cite@a\citesel{xyz}{blub}
+% -> \cite@bc\b@xyz\citesel{blub}
+%\end{verbatim}
+%
+% Canceling the old \lat/ definition of \verb*'\cite ' prevents
+% certain problems that could arise with the \pkg{showkeys} package.
+% \begin{macrocode}
+\expandafter\let\csname cite \endcsname\relax
+% \end{macrocode}
+%
+% \begin{macro}{\cite}
+% Need to handle the standard [...] option for compatibility's sake.
+% \begin{macrocode}
+\renewcommand{\cite}[2][]{%
+ \if\cite@single#2,\@gobble \else\MultipleCiteKeyWarning{#2}{#1}\fi
+ \@ifempty{#1}{%
+ \cites@o{#2}%
+ }{%
+ \ObsoleteCiteOptionWarning
+ \cites@a{*{#1}}{#2}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MultipleCiteKeyWarning}
+% \begin{macrocode}
+\def\MultipleCiteKeyWarning#1#2{%
+ \amsrefs@warning{%
+ Use of \string\cites\space is recommended instead of %
+ \string\cite\space\MessageBreak
+ for multiple cites '#1'}%
+ \@ifnotempty{#2}{%
+ \amsrefs@warning{Star option requires \string\citelist\space here}%
+ }%
+ \global\let\MultipleCiteKeyWarning\@gobbletwo
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ObsoleteCiteOptionWarning}
+% \begin{macrocode}
+\def\ObsoleteCiteOptionWarning{%
+ \amsrefs@warning{%
+ The form \string\cite{...}*{...} is recommended\MessageBreak
+ instead of \string\cite[...]{...}}%
+ \global\let\ObsoleteCiteOptionWarning\@empty
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@single}
+% \begin{macrocode}
+\edef\cite@single#1,#2{\iffalse{\fi\iffalse{\fi\string}#2.\string}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cites@o}
+% \begin{macrocode}
+\def\cites@o#1{\star@{\cites@oo{#1}}{}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cites@oo}
+% \begin{macrocode}
+\def\cites@oo#1#2{\@ifempty{#2}{\cites@a{}{#1}}{\cites@a{*{#2}}{#1}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cites@a}
+% \begin{macrocode}
+\def\cites@a#1#2{%
+ \begingroup
+ \toks@{\endgroup \cites@b{#1}}%
+ \vdef\@tempa{#2}%
+ \edef\@tempa{%
+ \the\toks@ \@firstofone{\@xp\zap@space\@tempa} \@empty
+ }%
+ \@tempa,\@empty
+ \edef\@tempa{\endgroup\@nx\citelist{\the\toks@}}%
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cites@b}
+% \begin{macrocode}
+\def\cites@b#1#2,#3{%
+ \begingroup
+ \toks@{\InnerCite{#2}#1}%
+ \ifx\@empty#3\@xp\@gobble\fi
+ \cites@c#3%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cites@c}
+% \begin{macrocode}
+\def\cites@c#1,#2{%
+ \add@toks@{\InnerCite{#1}}%
+ \ifx\@empty#2\@xp\@gobble\fi
+ \cites@c#2%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citeleft}
+% \begin{macro}{\citeright}
+% \begin{macro}{\citemid}
+% \begin{macro}{\citepunct}
+% These variables are named to follow the precedent set by
+% Arseneau's \pkg{cite} package. \cs{citemid} is used to separate a
+% citation label from additional information such as \qq{Theorem
+% 4.9}. \cs{citepunct} is used to separate multiple cites, unless
+% one of the cites has additional associated information, in which
+% case \cs{CiteAltPunct} is used.
+% \begin{macrocode}
+\def\citeleft{[}
+\def\citeright{]}
+% \end{macrocode}
+% \begin{macrocode}
+\def\citemid{,\penalty9999 \space}
+\def\citepunct{,\penalty9999 \hskip.13em plus.1em minus.05em\relax}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\citeAltPunct}
+% When a citation list contains one or more citations with optional
+% arguments, we replace \cs{citemid} by \cs{CiteAltPunct}.
+% \begin{macrocode}
+\def\citeAltPunct{;\ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citeform}
+% This is used for formatting the citation label. It can be used,
+% for example, to bolden the labels (as in \cls{amsbook} and
+% \cls{amsproc}) or to do more elaborate things such as convert the
+% numbers to roman numerals. By default, it's just a no-op.
+%
+% Note that currently there is no corresponding macro for changing
+% the formatting of \cn{cite}'s optional argument. This is
+% probably a bug.
+% \begin{macrocode}
+\providecommand{\citeform}{\@firstofone}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citelist}
+% The \cs{@citelist} indirection turns out to be helpful in
+% implementing the \cs{ocites} command for the \opt{author-year}
+% option.
+% \begin{macrocode}
+\DeclareRobustCommand{\citelist}{\@citelist}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@citelist}
+% \begin{macrocode}
+\def\@citelist#1{%
+ \leavevmode
+ \begingroup
+ \@citestyle
+ \citeleft\nopunct % suppress first \citepunct
+ \cite@begingroup
+ \in@*{#1}%
+ \ifin@
+ \let\citepunct\citeAltPunct
+ \fi
+ \let\cite@endgroup\@empty
+ \cites@init
+ \def\citeleft{\@addpunct{\citepunct}}%
+ \let\citeright\ignorespaces
+ \def\cite{\InnerCite}%
+ \process@citelist{#1}%
+ \endgroup
+ \citeright
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@citestyle}
+% Reset the font to an upright, medium font (e.g. \fnt{cmr}), per
+% AMS style. Also set $\cs{mathsurround} = 0\,\mathrm{pt}$ just in
+% case there are subscripts in the cite numbers (from
+% \cn{etalchar}, for example).
+% \begin{macrocode}
+\providecommand{\@citestyle}{\m@th\upshape\mdseries}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@begingroup}
+% Grouping that encloses an entire cite block (a single cite or a
+% list of cites).
+% \begin{macrocode}
+\def\cite@begingroup{\begingroup\let\cite@begingroup\relax}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@endgroup}
+% \begin{macrocode}
+\let\cite@endgroup\endgroup
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cites@init}
+% This needs to be called at the beginning of a list of cites to
+% reset a few things.
+% \begin{macrocode}
+\def\cites@init{%
+ \gdef\prev@names{???}%
+ \let\cites@init\@empty
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\InnerCite}
+% \begin{macrocode}
+\newcommand{\InnerCite}[1]{\star@{\cite@a\citesel{#1}}{}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@a}
+% The job of \cs{cite@a} is to convert the cite key to all catcode-12
+% characters and remove any spaces it might contain before passing
+% it on to \cs{cite@b}.
+%
+% \MacroArgs
+% \macroarg{1}{\cs{CITESEL}}
+% \macroarg{2}{citekey}
+% \begin{macrocode}
+\def\cite@a#1#2{%
+ \BackCite{#2}%
+ \cite@begingroup
+ \cites@init
+ \let\citesel#1\relax
+ \ifx\citesel\citesel@author
+ \let\citeleft\@empty
+ \let\citeright\@empty
+ \fi
+ \begingroup
+ \toks@{\endgroup \cite@b}%
+ \vdef\@tempa{#2}%
+ \edef\@tempa{%
+ \the\toks@{\@firstofone{\@xp\zap@space\@tempa} \@empty}%
+ }%
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@b}
+% \MacroArgs
+% \macroarg{1}{citekey}
+% \macroarg{2}{star-optional-arg}
+% \begin{macrocode}
+\def\cite@b#1#2{%
+ \@xp\cite@bc\csname b@#1\@xp\endcsname {#1}{#2}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@bc}
+% If it's uninitialized, plug in an empty cite structure.
+% \cs{cite@bc} should be executed only once for a given instance of a
+% cite key. All further processing should go through \cs{cite@cj}.
+% \begin{macrocode}
+\def\cite@bc#1#2{%
+ \ifx#1\@@undefined \global\let#1\relax \fi
+ \ifx#1\relax \global\let#1\empty@cite \fi
+ \@xp\cite@nobib@test#1{}{}{}{}\@nil#1%
+ \cite@cj#1%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\empty@cite}
+% \begin{macrocode}
+\def\empty@cite{\citesel 00{}{}{}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@nobib@test}
+% If arg 4 is empty, it means there wasn't any \cn{bib} command that
+% defined a valid label.
+%
+% \MacroArgs
+% \macroarg{1}{\cs{citesel}}
+% \macroarg{2}{cited?}
+% \macroarg{3}{used?}
+% \macroarg{4}{label}
+% \macroarg{5}{backrefs}
+% \macroarg{6}{\cs{b@}citekey}
+% \begin{macrocode}
+\def\cite@nobib@test#1#2#3#4#5\@nil#6{%
+ \@ifempty{#4}{%
+ \G@refundefinedtrue
+ \UndefinedCiteWarning#6%
+ \xdef#6{\@nx\citesel #2#3{%
+ \@nx\CitePrintUndefined{\extr@cite#6}}{}{}}%
+ }{}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\UndefinedCiteWarning}
+% This is a copy of the standard warning from \cs{@citex}.
+% \begin{macrocode}
+\def\UndefinedCiteWarning#1{%
+ \@latex@warning{%
+ Citation `\extr@cite#1' on page \thepage\space undefined}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\CitePrintUndefined}
+% \begin{macrocode}
+\DeclareRobustCommand{\CitePrintUndefined}[1]{%
+ \begingroup\fontshape{n}\fontseries\mddefault \ttfamily ?#1\endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\CPU@normal}
+% This has to be a \cs{let}, not a \cs{def}.
+% \begin{macrocode}
+\let\CPU@normal\CitePrintUndefined
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@cj}
+% \MacroArgs
+% \macroarg{1}{\cs{b@}citekey}
+% \macroarg{2}{star-optional-arg}
+% \begin{macrocode}
+\def\cite@cj#1#2{%
+ \leavevmode
+ \begingroup
+ \cite@cb#1% write info to aux file
+ \ar@SK@cite#1%
+ \@citeleft
+ \ar@hyperlink{#1}%
+ \@ifnotempty{#2}{\citemid{#2}}%
+ \citeright
+ \endgroup
+ \ignorespaces % ignore spaces inside \citelist
+ \cite@endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@citeleft}
+% The following definition provides some indirection that helps to
+% deal with author-year object cites.
+% \begin{macrocode}
+\def\@citeleft{\citeleft}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@cb}
+% \begin{macrocode}
+\def\cite@cb#1{%
+ \if@filesw
+ \immediate\write\@auxout{\string\citation{\extr@cite#1}}%
+ \fi
+% \end{macrocode}
+% Define \cs{citesel} to make \cs{b@whatever} update itself.
+% \begin{macrocode}
+ \begingroup
+ \let\citesel\citesel@update
+ #1#1%
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\extr@cite}
+% Extract \emph{citekey} from \cs{b@}\emph{citekey}.
+% \begin{macrocode}
+\def\extr@cite{\@xp\@gobblethree\string}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Fancier \cn{cite} commands}
+%
+% \begin{macro}{\cites}
+% A list of simple cites. Make it robust in case used inside a figure
+% caption. (But then also, by the way, listoffigures should provide
+% special handling.)
+% \begin{macrocode}
+\DeclareRobustCommand{\cites}{\cites@a{}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citen}
+% This is just to keep the showkeys package from clobbering the wrong
+% part of our definition of \cn{cite}:
+% \begin{macrocode}
+\providecommand{\citen}{\ocite}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ycite}
+% \cn{cite} gets redefined inside of \cn{citelist}, so we need to
+% \cs{def} \cn{ycite} here instead of just \cs{let}ting everything
+% to \cn{cite}.
+% \begin{macrocode}
+\def\ycite{\cite}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ycites}
+% \begin{macrocode}
+\let\ycites\cites
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ocite}
+% \begin{macrocode}
+\let\ocite\ycite
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ocites}
+% \begin{macrocode}
+\let\ocites\cites
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fullcite}
+% \begin{macrocode}
+\let\fullcite\cite
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fullocite}
+% \begin{macrocode}
+\let\fullocite\ocite
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citeauthor}
+% \begin{macrocode}
+\let\citeauthor\ycite
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citeauthory}
+% \begin{macrocode}
+\let\citeauthory\ycite
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{The \cn{nocite} command}
+%
+% \begin{macro}{\nocite}
+% \begin{macrocode}
+\renewcommand{\nocite}[1]{\othercites{#1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\othercites}
+% \begin{macrocode}
+\newcommand{\othercites}[1]{%
+ \cite@begingroup
+ \let\cite@endgroup\@empty
+ \def\citelist{\othercitelist}%
+ \cites{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\othercitelist}
+% \begin{macrocode}
+\newcommand{\othercitelist}[1]{%
+ \cite@begingroup
+ \let\cite@endgroup\@empty
+ \cites@init
+ \let\citeleft\relax
+ \let\citeright\ignorespaces
+ \def\InnerCite{\OtherCite}%
+ \def\cite@cj ##1##2{%
+ \begingroup
+ \@xp\citesel##1%
+ \cite@cb ##1%
+ \endgroup
+% \end{macrocode}
+% If we detect |\nocite{*}|, we globally alias
+% \cs{selective@bibdef} to \cs{copy@bibdef} so that all succeeding
+% \cn{bibselect} commands act like \cn{bibselect*}.
+% \begin{macrocode}
+ \@xp\ifx\csname b@*\endcsname ##1%
+ \global\let\selective@bibdef\copy@bibdef
+ \fi
+ \ignorespaces
+ \cite@endgroup
+ }%
+ #1\relax
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\OtherCite}
+% \begin{macrocode}
+\def\OtherCite#1{\cite@a\citesel@other{#1}{}{}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citesel@other}
+% \begin{macrocode}
+\def\citesel@other#1#2#3#4#5#6{}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\b@*}
+% This provides a dummy definition to keep things like |\nocite{*}|
+% from generating an error message.
+% \begin{macrocode}
+\@namedef{b@*}{\citesel 11{*}{*}{*}}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Citation sorting}
+%
+% \begin{macro}{\process@citelist@sorted}
+% \begin{macrocode}
+\def\process@citelist@sorted#1{%
+ \ifx\citesel\citesel@number
+ \cite@sorted@s #1\cite@sorted@e
+ \else
+ \NonNumericCiteWarning
+ \process@citelist@unsorted{#1}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NonNumericCiteWarning}
+% \begin{macrocode}
+\def\NonNumericCiteWarning{%
+ \amsrefs@warning{%
+ Unable to confirm that cite keys are numeric: not sorting%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\process@citelist@unsorted}
+% \begin{macrocode}
+\def\process@citelist@unsorted#1{%
+ \ignorespaces#1\relax
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\process@citelist}
+% By default, citation lists will be sorted.
+% \begin{macrocode}
+\let\process@citelist\process@citelist@sorted
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\CPU@sort}
+% By defining this as \TeX's maxint, undefined cites migrate to the
+% end of a sorted list.
+% \begin{macrocode}
+\def\CPU@sort#1{2147483647}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@sorted@s}
+% Here's where we prepare to sort the citations and (optionally)
+% compress ranges.
+% \begin{macrocode}
+\def\cite@sorted@s{%
+ \begingroup
+ \let\CitePrintUndefined\CPU@sort
+ \let\cite@cjs\cite@cj
+ \let\cite@cj\cite@compress
+ \begingroup
+ \toks@\@emptytoks
+ \let\cite@cj\cite@sort
+ \ignorespaces
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@sorted@e}
+% \begin{macrocode}
+\def\cite@sorted@e{%
+ \@xp\endgroup
+ \the\toks@
+ \cite@dash
+ \prev@cite
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@sort}
+% This is essentially an insertion sort. I think.
+%
+% \MacroArgs
+% \macroarg{1}{\cs{b@}citekey}
+% \macroarg{2}{optional arg}
+% \begin{macrocode}
+\def\cite@sort#1#2{%
+ \safe@set\@tempcnta#1% highest number so far
+ \toks@{\cite@cj#1{#2}}%
+ \@temptokena\toks@
+ \let\cite@cj\cite@sort@a
+ \ignorespaces
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@sort@a}
+% \begin{macrocode}
+\def\cite@sort@a#1#2{%
+ \safe@set\@tempcntb#1%
+ \ifnum\@tempcntb > \@tempcnta
+ \add@toks@{\cite@cj#1{#2}}%
+ \@tempcnta\@tempcntb
+ \else
+ \let\cite@cj\cite@sort@b
+ \toks@\@emptytoks
+ \def\@tempb{\add@toks@{\cite@cj#1{#2}}}%
+ \the\@temptokena
+ \@tempb
+ \let\cite@cj\cite@sort@a
+ \fi
+ \@temptokena\toks@
+ \ignorespaces
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@sort@b}
+% \begin{macrocode}
+\def\cite@sort@b#1#2{%
+ \safe@set\count@#1%
+ \ifnum\@tempcntb < \count@
+ \@tempb
+ \let\@tempb\@empty
+ \fi
+ \add@toks@{\cite@cj#1{#2}}%
+ \ignorespaces
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Range compression}
+%
+% When the time comes to apply compression, we have at our disposal a
+% list of internal cite calls that looks like this:
+% \begin{verbatim}
+% \cite@cj\b@aaa{opta}\cite@cj\b@bbb{optb}...\cite@cj\b@zzz{optz}
+%\end{verbatim}
+% where
+% \[ \ncn{b@aaa} < \ncn{b@bbb} < \cdots < \ncn{b@zzz} \]
+% and the \texttt{opt} arguments are possibly null.
+% To print the citations while collapsing sequences of 3 or more
+% contiguous numbers into ranges of the form $n$--$m$, we bind
+% \cs{cite@cj} to a suitably clever function and then execute the
+% list. In the absence of optional arguments, here's the algorithm:
+%
+% \begin{enumerate}
+% \item[Begin.]
+% Enter state~0. This is done by \cs{cite@sorted@s}.
+% \item[State 0.]
+%^^A This is the initial state.
+% The current citation is the beginning
+% of a range (possibly a singleton range). Print it. Then, set
+% $\mathit{prevnum} := \mathit{number}$ and enter state~1.
+%
+% \item[State 1.]
+% The current citation might be the second element of a range.
+% \begin{enumerate}
+% \item[Case a)]
+% $\mathit{number} = \mathit{prevnum} + 1$. Then the current
+% item is definitely the second element of a range. It might be
+% the last element of the range, but we won't know until we examine
+% the following citation. So, save the current citation in
+% \cs{prev@cite}, set $\mathit{prevnum} := \mathit{number}$, and go
+% to state~2.
+%
+% \item[Case b)]
+% $\mathit{number} \ne \mathit{prevnum} + 1$. The current citation
+% is the beginning of a new range. Print it, set
+% $\mathit{prevnum} := \mathit{number}$ and remain in state~1.
+% (This is essentially identical to stage~0.)
+%
+% \end{enumerate}
+%
+% \item[State 2.]\leavevmode
+% The current citation might be the third (or later) element of a
+% range.
+% \begin{enumerate}
+% \item[Case a)]
+% $\mathit{number} = \mathit{prevnum} + 1$. The current element is
+% definitely part of a range. It might be the last
+% element of the range, but again we won't know until we examine
+% the following citation. Save the current citation
+% in \cs{prev@cite} and set $\mathit{prevnum} := \mathit{number}$.
+% Remain in state~2.
+%
+% \item[Case b)]
+% $\mathit{number} \ne \mathit{prevnum} + 1$. The previous
+% citation was the end of a range and the current citation is the
+% beginning of a new range. Print a dash followed by
+% \cs{prev@cite}, then set $\mathit{prevnum} := \mathit{number}$
+% and enter state~1.
+%
+% \end{enumerate}
+%
+% \item[End.] If \cs{prev@cite} is not empty, print it, preceded by a
+% dash if we were in the middle of a range. (This is done by
+% \cs{cite@sorted@e}.)
+%
+% \end{enumerate}
+%
+% The presence of optional arguments complicates things
+% somewhat, since a citation with an optional argument should never
+% participate in range compression. In other words, when we come
+% across an optional argument, we should finish off the preceding
+% range, print the current citation, and then return to the initial
+% state. More precisely, here are the actions taken in each state
+% when there is an optional argument:
+%
+% \begin{enumerate}
+%
+% \item[State 0.]
+% Print the current citation and remain in state~0.
+%
+% \item[State 1.]
+% Print the current citation and return to state~0.
+%
+% \item[State 2.]
+% Print a dash followed by \cs{prev@cite}. Then print the current
+% citation and return to state~0.
+%
+% \end{enumerate}
+%
+% \begin{macro}{\prev@cite}
+% \begin{macrocode}
+\let\prev@cite\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\prev@cite@cb}
+% There's one further complication: Even though we're suppressing
+% some of the citation numbers, we need to make sure that each
+% citation is recorded in the \fn{.aux} file. So, in case~2a,
+% before we overwrite \cs{prev@cite}, we first invoke
+% \cs{prev@cite@cb} to record the previous citation (if any).
+% \begin{macrocode}
+\def\prev@cite@cb{%
+ \ifx\@prev@cite\@empty
+ \else
+ \begingroup
+ \def\cite@print##1##2{%
+ \cite@cb##1%
+ }%
+ \prev@cite
+ \endgroup
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@print}
+% \begin{macrocode}
+\def\cite@print#1#2{%
+ \begingroup
+ \let\CitePrintUndefined\CPU@normal
+ \cite@cjs#1{#2}%
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@dash}
+% Ok, I lied. There was more than one further complication.
+% Suppose that when we hit the end of the list, we're in state~2.
+% We need to know whether to output a dash or a comma. (For
+% example, both the sequences $[2, 3]$ and $[1, 2, 3]$ will end in
+% state~2 with $\mathit{prevcite} = 3$, but in the former case we
+% want a comma before the~3 and in the latter case we want a dash.)
+% So, rather than printing the dash explicitly, we use
+% \cs{cite@dash} to keep track of whether a dash is needed.
+% \begin{macrocode}
+\let\cite@dash\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\print@one@dash}
+% \begin{macrocode}
+\def\print@one@dash{%
+ \textendash \nopunct
+ \let\cite@dash\@empty
+}
+% \end{macrocode}
+% \end{macro}
+%
+% State 0, 1 and~2 each correspond to a different binding for
+% \cs{cite@cj}. Here they are. The role of $\mathit{prevnum}$ is
+% played by \cs{@tempcnta}, with \cs{@tempcntb} assisting as
+% $\mathit{number}$ at times.
+%
+% \begin{macro}{\cite@compress}
+% State~0:
+% \begin{macrocode}
+\def\cite@compress#1#2{%
+ \cite@print#1{#2}%
+ \@ifempty{#2}{%
+ \safe@set\@tempcnta#1%
+ \let\cite@cj\cite@compress@a
+ }{}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@compress@a}
+% State~1:
+% \begin{macrocode}
+\def\cite@compress@a#1#2{%
+ \@ifempty{#2}{%
+ \advance\@tempcnta\@ne
+ \safe@set\@tempcntb#1%
+ \ifnum\@tempcnta=\@tempcntb
+ \def\prev@cite{\cite@print#1{}}%
+ \let\cite@cj\cite@compress@b
+ \else
+ \cite@print#1{}%
+ \@tempcnta\@tempcntb
+ \fi
+ }{%
+ \cite@print#1{#2}%
+ \let\cite@cj\cite@compress
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@compress@b}
+% State~2:
+% \begin{macrocode}
+\def\cite@compress@b#1#2{%
+ \@ifempty{#2}{%
+ \advance\@tempcnta\@ne
+ \safe@set\@tempcntb#1%
+ \ifnum\@tempcnta=\@tempcntb
+ \let\cite@dash\print@one@dash
+ \prev@cite@cb
+ \def\prev@cite{\cite@print#1{}}%
+ \else
+ \cite@dash
+ \prev@cite
+ \let\prev@cite\@empty
+ \cite@print#1{}%
+ \@tempcnta\@tempcntb
+ \let\cite@cj\cite@compress@a
+ \fi
+ }{%
+ \cite@dash
+ \prev@cite
+ \let\prev@cite\@empty
+ \cite@print#1{#2}%
+ \let\cite@cj\cite@compress
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Munging the \fn{.aux} file}
+%
+% \begin{macro}{\bibcite}
+% When processing the \fn{.aux} file at begin-document, this is what
+% \cs{bibcite} will do:
+% \begin{macrocode}
+\def\bibcite#1{\@xp\bibcite@a\csname b@#1\endcsname}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bibcite@a}
+% \MacroArgs
+% \macroarg{1}{\cs{b@}citekey}
+% \macroarg{2}{\embrace{\emph{label}}\embrace{} or \embrace{\emph{author}}\embrace{\emph{year}}}
+% \begin{macrocode}
+\def\bibcite@a#1#2{%
+% \end{macrocode}
+% Most of the time arg 1 will already be defined, by an earlier
+% \cs{citedest} command in the \fn{.aux} file. Then we just need to change
+% the number.
+% \begin{macrocode}
+ \ifx\relax#1%
+ \gdef#1{\citesel 00#2{}}%
+ \else
+ \begingroup
+ \@xp\bibcite@b\@xp#1#1{#2}%
+ \endgroup
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bibcite@b}
+%
+% \MacroArgs
+% \macroarg{1}{\cs{b@}citekey}
+% \macroarg{2}{\cs{citesel}}
+% \macroarg{3}{cited?}
+% \macroarg{4}{used?}
+% \macroarg{5}{label}
+% \macroarg{6}{year}
+% \macroarg{7}{backrefs}
+% \macroarg{8}{\embrace{\emph{newlabel}}\embrace{\emph{newyear}}}
+% \begin{macrocode}
+\def\bibcite@b#1#2#3#4#5#6#7#8{\gdef#1{\citesel#3#4#8{#7}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citedest}
+% The \cs{citedest} command goes into the \fn{.aux} file to provide
+% back-reference support.
+% \begin{macrocode}
+\newcommand{\citedest}[1]{\@xp\cite@dest\csname b@#1\endcsname}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@dest}
+% \begin{macrocode}
+\def\cite@dest#1{%
+ \ifx\relax#1%
+ \gdef#1{\citesel 00{}{}{}}%
+ \fi
+ \@xp\cite@dest@b\@xp#1#1%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cite@dest@b}
+% \MacroArgs
+% \macroarg{1}{\cs{b@}citekey}
+% \macroarg{2}{\cs{citesel}}
+% \macroarg{3}{cited?}
+% \macroarg{4}{used?}
+% \macroarg{5}{label}
+% \macroarg{6}{year}
+% \macroarg{7}{backrefs}
+% \macroarg{8}{\embrace{\emph{more backrefs}}}
+% \begin{macrocode}
+\def\cite@dest@b#1#2#3#4#5#6#7#8{%
+ \@ifempty{#7}{%
+ \def#1{\citesel #3#4{#5}{#6}{{#8}}}%
+ }{%
+ \gdef#1{\citesel #3#4{#5}{#6}{#7,{#8}}}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Back references}
+%
+% \begin{macro}{\ifBR@verbose}
+% \begin{macrocode}
+\@ifundefined{ifBR@verbose}{\let\ifBR@verbose\iffalse \let\fi\fi}{}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\BackCite}
+% \begin{macrocode}
+\let\BackCite\@gobble
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\back@cite}
+% \begin{macrocode}
+\def\back@cite#1{%
+ \ifBR@verbose
+ \PackageInfo{backref}{back cite \string `\extr@cite#1'}%
+ \fi
+ \Hy@backout{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\print@backrefs}
+% In an AMS-style bibliography, the backref info might follow the
+% final period of the reference, or it might follow some
+% \emph{Mathematical Reviews} info, without a period.
+% \begin{macrocode}
+\def\print@backrefs#1{%
+ \space\SentenceSpace$\uparrow$\csname br@#1\endcsname
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintBackRefs}
+% \begin{macrocode}
+\let\PrintBackRefs\@gobble
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{\pkg{hyperref} and \pkg{showkeys} support}
+%
+% \begin{macro}{\ar@hyperlink}
+% \begin{macrocode}
+\def\ar@hyperlink#1{\hyper@@link [cite]{}{cite.\extr@cite#1}{#1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ar@SK@cite}
+% \begin{macrocode}
+\def\ar@SK@cite#1{\@bsphack\@xp\SK@\@xp\SK@@ref\@xp{\extr@cite#1}\@esphack}
+% \end{macrocode}
+% \end{macro}
+%
+% Turn off \pkg{hyperref} and \pkg{showkeys} support if those
+% packages don't appear to be loaded.
+% \begin{macrocode}
+\AtBeginDocument{%
+ \@ifundefined{hyper@@link}{%
+ \let\ar@hyperlink\@firstofone
+ \let\hyper@anchorstart\@gobble
+ \let\hyper@anchorend\relax
+ }{}%
+ \@ifundefined{SK@@label}{%
+ \let\ar@SK@cite\@gobble
+ \let\SK@@label\@gobble
+ \let\SK@\@gobbletwo
+ }{}%
+}
+% \end{macrocode}
+%
+% \subsection{Lexical structure of names}
+%
+% Before we can begin parsing names, we need to give some thought
+% to the lexical structure of names. For the remainder of this
+% document, when we refer to a ``name'' and especially when we
+% speak of a name as a macro argument, we assume that the only
+% tokens contained in the name are
+% \begin{itemize}
+%
+% \item
+% letters and punctuation (i.e., characters with catcode 11 or~12),
+%
+% \item
+% ties (the token |~|$_{13}$),
+%
+% \item
+% accent commands, such as |\"| or |\k|,
+%
+% \item
+% text symbol macros, such as |\i|, |\ae| or |\cprime|,
+%
+% \item
+% grouping characters (braces).
+%
+% \end{itemize}
+%
+% In addition to their normal function of delimiting macro
+% arguments, braces inside names have the following special
+% functions:
+% \begin{enumerate}
+%
+% \item They are used to indicate that multiple characters should
+% be considered a single ``compound'' character when extracting
+% initials. For example, |Yuri| becomes |Y.|, but |{Yu}ri| becomes
+% |Yu.|
+%
+% \label{initial-braces}
+% An important aspect of this use of braces is that it only applies
+% to the first characters of a given name. As we'll see below,
+% this has important implications for our parsing code, which must
+% preserve braces at the beginning of given names, but can be more
+% cavalier with braces in other positions.
+%
+% \item
+% Spaces and commas are ordinarily interpreted as name separators,
+% rather than name components. Similarly, periods and hyphens
+% usually have a special interpretation. All these characters can
+% be stripped of their special meanings by putting them within
+% braces.
+%
+% \end{enumerate}
+%
+% In practice, it might be possible to insert other tokens (such as
+% macros) into names as long as they either (a)~are non-expandable
+% or (b)~expand into a series of tokens of the above enumerated
+% types. However, in such cases it will probably be safer to
+% declare the macro in question as either a text accent or a text
+% symbol.
+%
+% \subsubsection{Text accents}
+%
+% Syntactically, a text accent is a macro that takes a single,
+% undelimited argument, i.e, it has a ``prototype'' of
+% |macro:#1->|. Semantically, the implication is that it takes a
+% letter (the \emph{base}) as an argument and produces a glyph that
+% for certain purposes can be considered equivalent to the
+% base (see the discussion of stem comparison on
+% page~\pageref{stem-comparison}).\footnote{Note that this is meant
+% to be a pragmatic definition for the purposes of this package.
+% No claim is made to greater generality.}
+%
+% \begin{macro}{\amsrefs@textaccents}
+% This will contain a list of accent commands in standard \LaTeX\
+% format (i.e., separated by the token \cs{do}). For example,
+% after registering the \cn{"} and \cn{'} accents, it will contain
+% \begin{verbatim}
+% \do \"\do \'
+%\end{verbatim}
+% \begin{macrocode}
+\let\amsrefs@textaccents\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DeclareNameAccent}
+% \MacroArgs
+% \macroarg{1}{accent}
+% \begin{macrocode}
+\def\DeclareNameAccent{%
+ \@lappend\amsrefs@textaccents
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Here are all the standard \LaTeX\ accents, as well as a few
+% nonstandard accents from the \pkg{mathscinet} package.
+% \begin{macrocode}
+\DeclareNameAccent\"
+\DeclareNameAccent\'
+\DeclareNameAccent\.
+\DeclareNameAccent\=
+\DeclareNameAccent\^
+\DeclareNameAccent\`
+\DeclareNameAccent\~%
+\DeclareNameAccent\b
+\DeclareNameAccent\c
+\DeclareNameAccent\d
+\DeclareNameAccent\H
+\DeclareNameAccent\k
+\DeclareNameAccent\r
+\DeclareNameAccent\t
+\DeclareNameAccent\u
+\DeclareNameAccent\v
+% \end{macrocode}
+% From \pkg{mathscinet}:
+% \begin{macrocode}
+\DeclareNameAccent\utilde
+\DeclareNameAccent\uarc
+\DeclareNameAccent\dudot
+\DeclareNameAccent\lfhook
+\DeclareNameAccent\udot
+\DeclareNameAccent\polhk
+\DeclareNameAccent\soft
+% \end{macrocode}
+% \cn{etalchar} and \cn{etaltext} are sort of accent-like if you
+% look at them in the right light.
+% \begin{macrocode}
+\DeclareNameAccent\etalchar
+%\DeclareNameAccent\etaltext
+% \end{macrocode}
+%
+% \subsubsection{Text symbols}
+%
+% Syntactically, a text symbol is a macro with a empty parameter
+% text, i.e., a prototype of |macro:->|. Semantically, it's a
+% letter-like glyph that should not be considered equivalent
+% to any other glyph or group of glyphs. In addition, it may exist
+% in both upper- and lowercase variants, unlike text accents, where
+% we consider the case to be an attribute of the base letter, not
+% of the accent.\footnote{As with text accents, this is not
+% intended as a fully general definition.}
+%
+% \begin{macro}{\amsrefs@textsymbols}
+% This is analogous to \cs{amsrefs@textaccents} but a little more
+% complicated due to the need to store lowercase equivalents. It
+% consists of a list of double entries of the form
+% \begin{verbatim}
+% \do \symbol \do \lcsymbol
+%\end{verbatim}
+% which means that \cs{symbol} is a text symbol whose corresponding
+% lowercase version is \cs{lcsymbol}. (Note that nothing is
+% implied about whether \cs{symbol} is to be considered as
+% uppercase or lowercase.) For example, in
+% \begin{verbatim}
+% \do \ae \do \ae \do \OE \do \oe
+%\end{verbatim}
+% the first four tokens indicate that \cn{ae} is a text symbol with
+% lowercase equivalent \cn{ae}, while the last four tokens indicate
+% that \cn{OE} is a text symbol with lowercase equivalent \cn{oe}.
+% This scheme is somewhat redundant, but pleasingly simple.
+%
+% This also duplicates some of the information in \cs{@uclclist},
+% but it seems safer to do this than to modify \cs{@uclclist}.
+% \begin{macrocode}
+\let\amsrefs@textsymbols\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DeclareNameSymbol}
+% \MacroArgs
+% \macroarg{1}{symbol}
+% \macroarg{2}{lowercase}
+% \begin{macrocode}
+\def\DeclareNameSymbol#1#2{%
+ \@lappend\amsrefs@textsymbols#1%
+ \@lappend\amsrefs@textsymbols#2%
+ \ifx#1#2\else
+ \@lappend\amsrefs@textsymbols#2%
+ \@lappend\amsrefs@textsymbols#2%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Here are the standard \LaTeX\ and \pkg{mathscinet} text
+% symbols.
+%
+% \label{anomalies}
+% Note that \cn{i} and \cn{j} are anomalous in being syntactically
+% like text symbols, but semantically more like text accents.
+% \begin{macrocode}
+\DeclareNameSymbol\i\i
+\DeclareNameSymbol\j\j
+\DeclareNameSymbol\AE\ae
+\DeclareNameSymbol\OE\oe
+\DeclareNameSymbol\O\o
+\DeclareNameSymbol\DH\dh
+\DeclareNameSymbol\DJ\dj
+\DeclareNameSymbol\L\l
+\DeclareNameSymbol\NG\ng
+\DeclareNameSymbol\SS\ss
+\DeclareNameSymbol\TH\th
+% \end{macrocode}
+% From \pkg{mathscinet}:
+% \begin{macrocode}
+\DeclareNameSymbol\Dbar\dbar
+\DeclareNameSymbol\lasp\lasp
+\DeclareNameSymbol\rasp\rasp
+\DeclareNameSymbol\cprime\cprime
+\DeclareNameSymbol\cdprime\cdprime
+\DeclareNameSymbol\bud\bud
+\DeclareNameSymbol\cydot\cydot
+% \end{macrocode}
+% |~| can be considered a text symbol in much the same way that
+% \cn{etalchar} can be considered an accent.
+% \begin{macrocode}
+\DeclareNameSymbol~~%
+% \end{macrocode}
+%
+% \subsubsection{\cs{edef}-like macros for names}
+% The following macros all behave sort of like \cs{edef}, in the
+% sense that
+% \begin{verbatim}
+% \X@edef\foo{name}
+%\end{verbatim}
+% defines \cs{foo} to be the result of expanding |name| and
+% applying a certain transformation to it.
+%
+% \begin{macro}{\normalize@edef}
+% This converts accents in the name to a normalized form where the
+% accent and its argument are surrounded by braces. E.g., after
+% \begin{verbatim}
+% \normalize@edef\cs{P\'olya}
+%\end{verbatim}
+% \cs{cs} will contain |P{\'o}lya|. (This might result in a
+% redundant layer of braces if the original text contained, say,
+% ``\verb+P{\'o}lya+'', but that's ok.) This lets us extract the
+% first $n$ characters from a name by using \TeX's macro
+% argument-gobbling mechanism without worrying that an accent
+% will be separated from its base letter.
+% As a bonus, it also replaces ties (|~|) by spaces.
+% \begin{macrocode}
+\def\normalize@edef#1#2{%
+ \begingroup
+ \@apply\auto@protect\amsrefs@textsymbols
+ \@apply\wrap@accent\amsrefs@textaccents
+% \end{macrocode}
+% Redefine \cs{@tabacckludge} in case someone wants to use this
+% with the \pkg{inputenc} package.
+% \begin{macrocode}
+ \let\@tabacckludge\use@accent
+ \let~\space
+ \edef\@tempa{\def\@nx#1{#2}}%
+ \@xp\endgroup
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\use@accent}
+% This is identical to \cs{@nameuse} except for the addition of the
+% \cs{string}, which, as per \fn{ltoutenc.dtx}, guards against the
+% eventuality that something like |'| might be active at the point
+% of use. We don't expect to find a \cs{bib} in the middle of a
+% \env{tabbing} environment (do we?)\ so we
+% \begin{macrocode}
+\def\use@accent#1{\csname\string#1\endcsname}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\wrap@accent}
+% Here's a wrapper macro that causes an accent to become
+% auto-wrapping. E.g., after \verb+\wrap@accent\'+, \verb+\'o+
+% will expand to \verb+{\'o}+.
+% \begin{macrocode}
+\def\wrap@accent#1{%
+ \def#1##1{{\@nx#1##1}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\lc@edef}
+% This converts all the characters in a name to all lowercase,
+% using the mapping defined by \cs{amsrefs@textsymbols}. So, after
+% \begin{verbatim}
+% \lc@edef\cs{P\'olya}
+%\end{verbatim}
+% \cs{cs} will contain |p\'olya|. Note that accents are not
+% wrapped and ties are passed through unmolested.
+% \begin{macrocode}
+\def\lc@edef#1#2{%
+ \begingroup
+ \let\@tabacckludge\use@accent %%??
+ \@apply\auto@protect\amsrefs@textaccents
+ \@apply\lc@do\amsrefs@textsymbols
+ \edef\@tempa{\lowercase{\def\@nx#1{#2}}}%
+ \@xp\endgroup
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\lc@do}
+% This is a slighly more complicated wrapper macro than previous
+% ones.
+% The first argument is a text symbol; the second argument is the
+% lowercase variant of the symbol. If they're the same (i.e., the
+% first argument is a lowercase text symbol), we \cs{auto@protect}
+% it. Otherwise we define the first symbol to expand to the
+% second.
+% \begin{macrocode}
+\def\lc@do#1\do#2{%
+ \ifx#1#2%
+ \auto@protect#1%
+ \else
+ \def#1{#2}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\purge@edef}
+% Removes accents and braces from a name and converts ties to
+% spaces, leaving only letters, punctuation and text symbols. For
+% example,
+% \begin{verbatim}
+% \lc@edef\cs{P{\'o}lya}
+%\end{verbatim}
+% will put |Polya| in~\cs{cs}.
+% \begin{macrocode}
+\def\purge@edef#1#2{%
+ \begingroup
+ \@apply\auto@protect\amsrefs@textsymbols
+ \let~\space
+ \@apply\purge@accent\amsrefs@textaccents
+ \let\@tabacckludge\@gobble
+% \end{macrocode}
+% As mentioned above (page~\pageref{anomalies}), \cn{i} and \cn{j}
+% are semantically like text accents; hence, they require special
+% treatment here.
+% \begin{macrocode}
+ \def\i{i}%
+ \def\j{j}%
+ \edef\@tempa{#2}%
+ \toks@\@emptytoks
+ \@xp\purge@edef@ \@tempa \@nil
+ \edef\@tempa{\def\@nx#1{\the\toks@}}%
+ \@xp\endgroup
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\purge@edef@}
+% Peek ahead so \cs{purge@edef@a} will know whether its argument
+% was originally surrounded by braces.
+% \begin{macrocode}
+\def\purge@edef@{%
+ \futurelet\@let@token
+ \purge@edef@a
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\purge@edef@a}
+% Process a single ``chunk'' (i.e., one macro-argument's worth) of
+% the name.
+% \begin{macrocode}
+\def\purge@edef@a#1{%
+% \end{macrocode}
+% If we've run into the \cs{@nil} terminator, we're done.
+% \begin{macrocode}
+ \ifx\@let@token\@nil
+ \let\@tempa\@empty
+ \else
+% \end{macrocode}
+% Otherwise, if the argument was originally surrounded by braces,
+% process it recursively before processing the remainder of the
+% token stream.
+% \begin{macrocode}
+ \ifx\@let@token\bgroup
+ \def\@tempa{%
+ \purge@edef@ #1\@nil
+ \purge@edef@
+ }%
+ \else
+% \end{macrocode}
+% If the argument is a single unbracketed token, just copy it into
+% the output.
+% \begin{macrocode}
+ \add@toks@{#1}%
+ \let\@tempa\purge@edef@
+ \fi
+ \fi
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\purge@accent}
+% This is similar to \cs{wrap@accent} but it removes the accent
+% command (and possibly a layer of braces surrounding the accent's
+% argument).
+% \begin{macrocode}
+\def\purge@accent#1{%
+ \def#1##1{##1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Name parsing}
+%
+% Parsing names is somewhat complicated because parts of the name
+% can (in principle) be empty (G=given, S=surname, J=jr)):
+% \begin{quote}
+% \nametest{Doe, John, Jr.}
+% \nametest{Doe, John}
+% \nametest{Doe, , Jr.}
+% \nametest{Doe}
+% \nametest{, John, Jr.}
+% \nametest{, John}
+% \nametest{, , Jr.}
+% \nametest{}
+% \end{quote}
+% Not all of these forms are legal, of course, but that's no excuse
+% for not parsing them correctly.
+%
+% We also want to be somewhat lenient about the placement of
+% spaces:
+% \begin{quote}
+% \nametest{ Doe,John,Jr.}
+% \end{quote}
+%
+% However, because one must have some standards, we assume there
+% are no spaces in the following positions in the input:
+% \begin{enumerate}
+% \item before periods,
+%
+% \item before commas,
+%
+% \item at the end of the name,
+%
+% \item before or after hyphens.
+% \end{enumerate}
+%
+% Thus, we make no attempt to compensate for the misplaced spaces
+% in examples like these:
+% \begin{quote}
+% \nametest{Doe , J ., Jr. }
+% \nametest{Doe, J. - M.}
+% \end{quote}
+%
+% Also, unless we are generating initials, we don't try to
+% normalize spaces \emph{after} periods:
+% \begin{quote}
+% \nametest{Doe, J.M.}\\ (not G=\embrace{J. M.})
+% \end{quote}
+%
+% Finally, since we allow authors to group together characters that
+% should be treated as a single unit, we need to be careful to
+% preserve the author's markup in cases like these:
+%
+% \begin{quote}
+% \nametest{Doe, {Yu}ri}
+% \nametest{Doe, {Yu}}
+% \end{quote}
+%
+% This is harder than it seems. For example, consider a naive
+% implementation that uses delimited arguments to pull the name
+% apart:
+% \begin{verbatim}
+% \def\parsename#1,#2\@nil{%
+% \def\bib'surname{#1}%
+% \def\bib'given{#2}%
+% }
+%
+% \parsename Doe, {Yu}ri\@nil
+%\end{verbatim}
+% Unfortunately, this results in the space after the comma
+% becoming part of \cs{bib'given}: ``\verb+ {Yu}ri+''.
+%
+% Our next thought would be to modify the definition slightly to
+% trick \TeX\ into gobbling the space:
+% \begin{verbatim}
+% \def\parsename#1,#2#3\@nil{%
+% \def\bib'surname{#1}%
+% \def\bib'given{#2#3}%
+% }
+%\end{verbatim}
+% Now the space is gone, but---surprise!---so are the braces:
+% ``\verb+Yuri+''. In addition, this approach makes it difficult
+% to handle empty name parts correctly.
+%
+% To sidestep these problems, instead of blindly gobbling macro
+% arguments, we use \cs{futurelet} to look ahead at certain
+% strategic moments so we can take the appropriate action (see
+% \cs{get@namepart@d}--|f|). We only really care about preserving
+% braces at the start of names (page~\pageref{initial-braces}),
+% which simplifies things somewhat.\label{brace-preservation}
+%
+% \begin{macro}{\name@split}
+% \cs{name@split} parses a name into its three parts and stores
+% them in \cs{bib'surname}, \cs{bib'given} and \cs{bib'jr}. If the
+% \opt{initials} option is in force, it also extracts the initials
+% from the given name and stores them in \cs{bib'initials}.
+%
+% It expects the name to be parsed to be terminated by \cs{@nil}
+% and to contain at least three commas. Thus the usual way to
+% invoke it is
+% \begin{quote}
+% \cs{name@split} $\langle\mathit{name}\rangle$\verb+,,,\@nil+
+% \end{quote}
+%
+% \cs{name@split} just uses \cs{get@namepart} to peal off the
+% surname and then passes control to \cs{name@split@given}.
+% (Note the spiffy continuation-passing programming style.)
+% \begin{macrocode}
+\def\name@split{%
+ \get@namepart\bib'surname\name@split@given
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\name@split@given}
+% Pretty much the same, \em{mutatis mutandis}\ldots
+% \begin{macrocode}
+\def\name@split@given{%
+ \get@namepart\bib'given\name@split@jr
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\name@split@jr}
+% And again\ldots
+% \begin{macrocode}
+\def\name@split@jr{%
+ \get@namepart\bib'jr\name@split@finish
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\name@split@finish}
+% We have all three parts now. Do some consistency checking,
+% extract the initials from the given name, and then call
+% \cs{@nilgobble} to remove anything (such as extra commas) left on
+% the stack.
+% \begin{macrocode}
+\def\name@split@finish{%
+ \ifx\bib'surname\@empty \EmptyNameWarning \fi
+% \end{macrocode}
+% Theoretically, we could try to check for uninverted names here,
+% but only at the risk of producing spurious warnings when the name
+% really does only have one part (\verb+author={Arvind}+).
+%
+% A possible solution: Now that we have the
+% \attr{inverted} attribute, we could issue a warning if the given
+% name is empty and the family name contains a space. I'm sure
+% someone could find valid input that would still generate a
+% spurious warning, but this would take care of the most common
+% cases. This bears more thinking about.
+% \begin{macrocode}
+%% \ifx\@empty\bib'given
+%% \NameCheck \bib'surname ??\@nil
+%% \else
+ \extract@initials\bib'given
+%% \fi
+ \@nilgobble
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\get@namepart}
+% Now for the fun part. \cs{get@namepart} takes two arguments.
+% The first (the destination) should be a control sequence; the
+% second (the continuation) will normally also be a control
+% sequence, though technically we only require that it be a single
+% token. \cs{get@namepart} scans everything up to the next level-0
+% comma, places it in the destination, and then calls the
+% continuation.
+% \begin{macrocode}
+\def\get@namepart#1#2{%
+% \end{macrocode}
+% Save the destination in \cs{toks@} and the continuation in
+% \cs{@temptokena}. It's unfortunate that this trashes the
+% previous contents of those token lists (as well as the contents
+% of \cs{@tempa} later on), but preliminary attempts to rewrite the
+% code to leave the calling environment unchanged were not
+% encouraging.
+% \begin{macrocode}
+ \toks@{#1}%
+ \@temptokena{#2}%
+ \get@namepart@a
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\get@namepart@a}
+% Now peek ahead at the next token in the stream and call
+% \cs{get@namepart@b} to examine it.
+% \begin{macrocode}
+\def\get@namepart@a{%
+ \futurelet\@let@token
+ \get@namepart@b
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\get@namepart@b}
+% If the next token is a space token, we want to delete it.
+% Otherwise we're ready to read the name.
+% \begin{macrocode}
+\def\get@namepart@b{%
+ \ifx\@let@token\@sptoken
+ \@xp\get@namepart@c
+ \else
+ \@xp\get@namepart@d
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\get@namepart@c}
+% The next token is a space; we delete it and restart
+% \cs{get@namepart@a}, in case there are multiple spaces.
+% \begin{macrocode}
+\def\get@namepart@c{%
+ \after@deleting@token\get@namepart@a
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\get@namepart@d}
+% We're at the beginning of the name part. However, there are
+% still two special cases we have to watch out for. First, the
+% next token might be a comma, meaning that this name part is
+% empty. Second, the next token might be an open brace (\verb+{+),
+% which we have to be sure to copy into the destination. So, we
+% peek ahead again before proceeding.
+% \begin{macrocode}
+\def\get@namepart@d{%
+ \futurelet\@let@token
+ \get@namepart@e
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\get@namepart@e}
+% If the next token is a comma, it means the name part is empty;
+% so, we set the destination to an empty list and then arrange to
+% execute the continuation after deleting the comma. Otherwise we
+% call \cs{get@namepart@f} to read a non-empty name, leaving
+% \cs{@let@token} undisturbed so that \cs{get@namepart@f} knows
+% what's coming up.
+% \begin{macrocode}
+\def\get@namepart@e{%
+ \ifx\@let@token,%
+ \@xp\let\the\toks@\@empty
+ \edef\@tempa{%
+ \@nx\after@deleting@token\the\@temptokena
+ }%
+ \@xp\@tempa
+ \else
+ \@xp\get@namepart@f
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\get@namepart@f}
+% We know whether or not the name begins with a brace, but we don't
+% know if the corresponding group contains the entire name or only
+% part of it. By reading the name as two arguments, we can handle
+% all cases correctly.\footnote{More or less. If the second
+% argument is brace-delimited, the braces will be lost. But as
+% mentioned above (page~\pageref{brace-preservation}), we don't
+% really care.}
+%
+% Note that the arguments are not expanded.
+% \begin{macrocode}
+\def\get@namepart@f#1#2,{%
+ \ifx\@let@token\bgroup
+ \@xp\def\the\toks@{{#1}#2}%
+ \else
+ \@xp\def\the\toks@{#1#2}%
+ \fi
+ \the\@temptokena
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\EmptyNameWarning}
+% Or translator or contributor or\ldots
+% \begin{macrocode}
+\def\EmptyNameWarning{\amsrefs@warning{Empty contributor name}}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Extracting initials}
+%
+% Extracting initials from the author's given name is tricky
+% because of the numerous special cases that need to be
+% handled. Consider the following examples, some of which are
+% admittedly contrived:
+% \begin{quote}
+% \initialtest{Arvind}
+% \initialtest{Bing, R H}
+% \initialtest{Harish, \'Etienne}
+% \initialtest{Harish, \'E.}
+% \initialtest{Harish, \'{E}.}
+% \initialtest{Harish, {\'E}.}
+% \initialtest{Harish, \'E}
+% \initialtest{Harish, \'Etienne-P\^{\i}erre}
+% \initialtest{Jones, David}
+% \initialtest{Jones, David-Michael}
+% \initialtest{Katzenbach, Nicholas {deB}elleville}
+% \initialtest{Katzenbach, Nicholas deB.}
+% \initialtest{Matiyasevich, {Yu}ri}
+% \initialtest{Matiyasevich, {Yu}}
+% \initialtest{Matiyasevich, Yu.}
+% \end{quote}
+% When processing initials, we loosen our strictures on spaces
+% inside the given name by not requiring spaces after periods and
+% tolerating them around hyphens and after the name:
+% \begin{quote}
+% \initialtest{Jones, D.M.}
+% \initialtest{Jones, David - Michael}
+% \initialtest{Jones, David , Jr.}
+% \end{quote}
+% (Strictly speaking, only the support for the first of these
+% examples was a deliberate design decision; the other two are
+% side-effects of the implementation. In any case, toleration of
+% these quirks is in no way an endorsement of them, especially
+% since they may make it more difficult for third-party software to
+% correctly process bibliography entries.)
+%
+%^^A We also make one additional assumption: a hyphen does not occur
+%^^A as the last character in the name.
+%
+% \subsubsection{The algorithm}
+%
+% As a running example, consider the following contrived input:
+% \begin{quote}
+% {\tt \verb+\'E.-P\^{\i}erre J.K. M+}
+% \end{quote}
+% which we want to turn into {\makeatletter``{\'E}.~\ini@hyphen
+% P.~J.~K.~M''}.
+%
+% We precede by stages.
+% \begin{enumerate}
+%
+% \item
+% Normalize the name by surrounding accents and their arguments by
+% braces:
+% \begin{quote}
+% \verb+{\'E}.-P{\^\i }erre J.K. M+
+% \end{quote}
+% We also replace \verb+~+s by spaces at this stage.
+%
+% \item
+% Replace each hyphen (\verb+-+) by ``\verb*+ \ini@hyphen +'':
+% \begin{quote}
+% \verb+{\'E}. \ini@hyphen P{\^\i }erre J.K. M+
+% \end{quote}
+%
+% \item
+% Add a space after each period:
+% \begin{quote}
+% \verb+{\'E}. \ini@hyphen P{\^\i }erre J. K. M+
+% \end{quote}
+%
+% \item
+% Now we have the name as a list of space-separated components.
+% (In our example, the components are ``\verb+{\'E}.+'',
+% ``\verb+\ini@hyphen+'', ``\verb+P{\^\i }erre+'', ``\verb+J.+'',
+% ``\verb+K.+'', and ``\verb+M+''.) We loop through the compoments
+% and replace each one by its ``initialized'' form. There are
+% four cases:\label{initial_cases}
+% \begin{enumerate}
+%
+% \item
+% The component ends in a period. Copy it and add the token
+% \verb+~+. (In our example, these are the
+% components ``\verb+{\'E}.+'', ``\verb+J.+'' and ``\verb+K.+''.)
+%
+% \item
+% The component consists of a single (possibly compound) character
+% without a period. Again, copy it and add
+% \verb+~+. (In our example, this is the component
+% ``\verb+M+''.)
+%
+% \item
+% The component is the token \verb+\ini@hyphen+. Copy it.
+%
+% \item
+% The component consts of two or more (possibly compound)
+% characters without a period (e.g., ``\verb+P{\^\i }erre+'').
+% Copy the first character and add the tokens \verb+.~+.
+% \end{enumerate}
+%
+% \item
+% The token list generated above will end with an unwanted |~|.
+% Delete it.
+%
+% \end{enumerate}
+%
+% The end result is
+% \begin{verbatim}
+% {\'E}.~\ini@hyphen P.~J.~K.~M
+%\end{verbatim}
+% which, when typeset, does indeed produce
+% {\makeatletter''{\'E}.~\ini@hyphen P.~J.~K.~M''}.\footnote{Tying
+% all the characters together is potentially undesirable when, as
+% in the example, there are a large number of pieces in the given
+% name.}
+%
+% \subsubsection{The implementation}
+%
+% \begin{macro}{\extract@initials}
+% This is pretty straightforward.
+% \begin{macrocode}
+\def\extract@initials#1{%
+ \begingroup
+ \auto@protect\ini@hyphen
+ \auto@protect\nobreakspace
+ \let~\relax
+ \@apply\auto@protect\amsrefs@textsymbols
+ \@apply\auto@protect\amsrefs@textaccents
+ \normalize@edef\@tempa{#1}%
+ \ifx\@tempa\@empty
+ \else
+% \end{macrocode}
+% It would be nice if \cs{process@hyphens} and \cs{process@dots}
+% commuted, and they almost do. However, suppose you have the
+% (admittedly contrived) name |Yu.-{Yu}|, which should be turned
+% into ``Yu.-Yu''. If \cs{process@dots} is applied first, the
+% braces around the second ``Yu'' get removed, so the output is
+% ``Yu.-Y.''. (Even worse would be |P.-\'E|, which would produce
+% ``P.-\'.'')
+% \begin{macrocode}
+ \process@hyphens\@tempa
+ \process@dots\@tempa
+ \process@names\@tempa
+ \@chomp\@tempa{~}%
+ \fi
+ \edef\@tempa{\def\@nx\bib'initials{\@tempa}}%
+ \@xp\endgroup
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ini@hyphen}
+% The \cs{unskip} removes the space at the end of a potential (and
+% probable) preceding |~|, but leaves the \cs{nobreak} penalty.
+% \begin{macrocode}
+\def\ini@hyphen{\unskip-\nobreak}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\process@hyphens}
+% This follows the same general pattern as \cs{get@namepart}, but
+% with an extra layer of grouping to avoid unwanted side-effects.
+% Otherwise, it uses the same parsing techniques.
+%
+% One difference is that there is no explicit continuation:
+% instead, we iterate by repeatedly calling
+% \cs{process@one@hyphen@d} until we run into the \cs{@nil}
+% marker.
+% \begin{macrocode}
+\def\process@hyphens#1{%
+ \begingroup
+ \toks@\@emptytoks
+ \@xp\process@one@hyphen #1-\@nil
+ \edef\@tempa{\the\toks@}%
+% \end{macrocode}
+% Because of the |-| we have to stick in as a delimiter above,
+% \cs{process@one@hyphen} will always generate unwanted code at the
+% end of the name. We now delete it. (This also has the necessary
+% side-effect of expanding the \cs{space} macros into space
+% characters.)
+% \begin{macrocode}
+ \@chomp\@tempa{ \ini@hyphen\space}%
+ \edef\@tempa{\def\@nx#1{\@tempa}}%
+ \@xp\endgroup
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\process@one@hyphen}
+% Cf.\ \cs{get@namepart@a}.
+% \begin{macrocode}
+\def\process@one@hyphen{%
+ \futurelet\@let@token
+ \process@one@hyphen@a
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\process@one@hyphen@a}
+% Cf.\ \cs{get@namepart@b} and \cs{extract@initial@a}.
+%
+% The tests for \cs{@nil} and~|-| here are purely to supply better
+% error recovery. Without them, a hyphen at the end of the given
+% name (.e.g, |author={Doe, John-}|) would produce a very
+% mysterious error message. Since it's unlikely the hyphen really
+% belongs there, we delete it, but we also issue a warning to the
+% author. (It will still show up as part of the full given name,
+% though.)
+%
+% We borrow \cs{fsa@n} from \pkg{rkeyval} to keep track of the
+% appropriate next action.
+% \begin{macrocode}
+\def\process@one@hyphen@a{%
+ \ifx\@let@token\@nil
+ \let\fsa@n\@gobble
+ \else
+ \ifx\@let@token -%
+ \TrailingHyphenWarning
+ \let\fsa@n\process@one@hyphen@b
+ \else
+ \ifx\@let@token\@sptoken
+ \let\fsa@n\process@one@hyphen@b
+ \else
+ \let\fsa@n\process@one@hyphen@c
+ \fi
+ \fi
+ \fi
+ \fsa@n
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\process@one@hyphen@b}
+% Cf.\ \cs{get@namepart@c}.
+% \begin{macrocode}
+\def\process@one@hyphen@b{%
+ \after@deleting@token\process@one@hyphen
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\process@one@hyphen@c}
+% Cf.\ \cs{get@namepart@f}.
+% \begin{macrocode}
+\def\process@one@hyphen@c#1#2-{%
+ \ifx\bgroup\@let@token
+ \add@toks@{{#1}#2 \ini@hyphen\space}%
+ \else
+ \add@toks@{#1#2 \ini@hyphen\space}%
+ \fi
+ \futurelet\@let@token
+ \process@one@hyphen@d
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\process@one@hyphen@d}
+% Here we just check for \cs{@nil} and terminate if we detect it.
+% Otherwise, we start over.
+% \begin{macrocode}
+\def\process@one@hyphen@d{%
+ \ifx\@let@token\@nil
+ \@xp\@gobble
+ \else
+ \@xp\process@one@hyphen
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\TrailingHyphenWarning}
+% Or translator or contributor or\ldots
+% \begin{macrocode}
+\def\TrailingHyphenWarning{%
+ \amsrefs@warning{Trailing hyphen deleted from name}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\process@dots}
+% This is almost completely parallel to \cs{process@hyphens}.
+% \begin{macrocode}
+\def\process@dots#1{%
+ \begingroup
+ \toks@\@emptytoks
+ \@xp\process@one@dot #1.\@nil
+ \edef\@tempa{\the\toks@}%
+ \@chomp\@tempa{. }%
+% \end{macrocode}
+% Since it's legitimate for names to end in periods, we might
+% still have an unwanted space at the end of the name, so we delete
+% it too.
+% \begin{macrocode}
+ \@chomp\@tempa{ }%
+ \edef\@tempa{\def\@nx#1{\@tempa}}%
+ \@xp\endgroup
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\process@one@dot}
+% \begin{macrocode}
+\def\process@one@dot{%
+ \futurelet\@let@token
+ \process@one@dot@a
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\process@one@dot@a}
+% This is a bit different from \cs{process@one@hyphen@a} since we
+% expect names sometimes to end in a period---or even two
+% periods---not least because of the |.| we add as a delimiter when
+% invoking \cs{process@one@dot}.
+% \begin{macrocode}
+\def\process@one@dot@a{%
+ \ifx\@let@token .%
+ \def\fsa@n{\after@deleting@token\process@bare@dot}%
+ \else
+ \ifx\@let@token\@sptoken
+ \let\fsa@n\process@one@dot@b
+ \else
+ \let\fsa@n\process@one@dot@c
+ \fi
+ \fi
+ \fsa@n
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\process@bare@dot}
+% \begin{macrocode}
+\def\process@bare@dot{%
+ \add@toks@{. }%
+ \futurelet\@let@token
+ \process@one@dot@d
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\process@one@dot@b}
+% \begin{macrocode}
+\def\process@one@dot@b{%
+ \after@deleting@token\process@one@dot
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\process@one@dot@c}
+% \begin{macrocode}
+\def\process@one@dot@c#1#2.{%
+ \ifx\bgroup\@let@token
+ \add@toks@{{#1}#2. }%
+ \else
+ \add@toks@{#1#2. }%
+ \fi
+ \futurelet\@let@token
+ \process@one@dot@d
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\process@one@dot@d}
+% \begin{macrocode}
+\def\process@one@dot@d{%
+ \ifx\@let@token\@nil
+ \@xp\@gobble
+ \else
+ \@xp\process@one@dot
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\process@names}
+% This is very similar to \cs{process@hyphens} and
+% \cs{process@dots}, but with a couple of twists, as noted below.
+% \begin{macrocode}
+\def\process@names#1{%
+ \begingroup
+ \toks@\@emptytoks
+ \@xp\extract@initial #1 \@nil
+ \edef\@tempa{\def\@nx#1{\the\toks@}}%
+ \@xp\endgroup
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\extract@initial}
+% Scan through the token stream replacing words by their initials
+% until we hit the terminating~|'|$_{11}$
+% \begin{macrocode}
+\def\extract@initial{%
+ \futurelet\@let@token
+ \extract@initial@a
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\extract@initial@a}
+% As with \cs{process@one@hyphen@a}, the test for |'|$_{11}$ here
+% is purely to provide better recovery, this time in case the given
+% name has a trailing space (.e.g, |author={Doe, John }|).
+% But since we're just deleting whitespace, we don't bother issuing
+% a warning.
+% \begin{macrocode}
+\def\extract@initial@a{%
+ \ifx\@let@token\@nil
+ \let\fsa@n\@gobble
+ \else
+ \ifx\@let@token\@sptoken
+ \let\fsa@n\extract@initial@b
+ \else
+ \let\fsa@n\extract@initial@c
+ \fi
+ \fi
+ \fsa@n
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\extract@initial@b}
+% \begin{macrocode}
+\def\extract@initial@b{%
+ \after@deleting@token\extract@initial
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\extract@initial@c}
+% Here, instead of just copying the name, we extract its initials
+% and copy those.
+% \begin{macrocode}
+\def\extract@initial@c#1#2 {%
+ \ifx\@let@token\bgroup
+% \end{macrocode}
+% Note that we double-brace the first argument to avoid having to
+% test \cs{@let@token} again inside \cs{@extract@initial}.
+% \begin{macrocode}
+ \@extract@initial {{#1}}#2\@nil
+ \else
+ \@extract@initial #1#2\@nil
+ \fi
+ \futurelet\@let@token
+ \extract@initial@d
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\extract@initial@d}
+% \begin{macrocode}
+\def\extract@initial@d{%
+ \ifx\@let@token\@nil
+ \@xp\@gobble
+ \else
+ \@xp\extract@initial
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@extract@initial}
+% This handles the four cases mentioned on
+% page~\pageref{initial_cases}.
+% \begin{macrocode}
+\def\@extract@initial#1#2\@nil{%
+ \ifx\ini@hyphen#1%
+ \add@toks@{\ini@hyphen}%
+ \else
+ \in@{.\@nil}{#1#2\@nil}% Look for a period at the end of the name
+ \ifin@
+ \add@toks@{#1#2~}%
+ \else
+ \count@chars\@tempcnta{#1#2}%
+ \ifnum\@tempcnta > \@ne
+ \add@toks@{#1.~}%
+ \else
+ \add@toks@{#1~}%
+ \fi
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\count@chars}
+% This sets its first argument (which is assumed to be a count
+% register) to the number of characters in the second argument.
+% Compound characters are counted as a single character.
+% \begin{macrocode}
+\def\count@chars#1#2{%
+ \begingroup
+ \@tempcnta\z@
+ \@count@chars#2\@nil
+ \edef\@tempb{#1=\the\@tempcnta\relax}%
+ \@xp\endgroup
+ \@tempb
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@count@chars}
+% \begin{macrocode}
+\def\@count@chars#1{%
+ \ifx #1\@nil
+ \else
+ \advance\@tempcnta\@ne
+ \@xp\@count@chars
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Generating alphabetic labels}
+%
+% \subsubsection{The algorithm}
+%
+% Like Gaul, an alphabetic label is divided into three parts.
+% \begin{enumerate}
+%
+% \item The author part. In the simplest case, this is formed by
+% extracting the first character of each word of each last name of
+% each author. Thus, if there were two authors with last names
+% ``Vaughan Williams'' and ``Tallis'', the author part would be
+% ``VWT''.
+%
+% If there are more than four authors, only the first three names
+% are used, and a superscript~``+'' is appended to represent the
+% elided names. Similarly, if an author name is ``others'',
+% it is replaced by a superscript~``+'' and any following author
+% names (of which there shouldn't be any) are ignored.
+%
+% Finally, if there is only one author and the author's last name
+% consists of a single word, the first three characters of that
+% name are used.
+%
+% \item The year part. If the \opt{y2k} option is in force, or if
+% the year is less than~1901, the entire year is used. Otherwise
+% the last two digits of the year are used.\footnote{Years with
+% more than 4 digits are not currently handled correctly.
+% \emph{Caveat lector}.}
+%
+% The combination of author part and year part will be referred to
+% as the \emph{stem}.
+%
+% \item[3.] The suffix. If two or more items have the same stems,
+% a suffix consisting of a lowercase latin letter will be appended
+% to each label to make it unique.
+%
+% \end{enumerate}
+%
+% \label{stem-comparison}
+% This third part is more subtle than it might first appear.
+% First, case is ignored when comparing stems, so that, for
+% example, ``Ahl1999'' and ``AHL1999'' are considered identical.
+% Second, existing practice (in English, at least), is to ignore
+% diacritics so that, for example, ``Ahl1999'' and ``\"Ahl1999''
+% are considered identical.
+%
+% Note that when checking for duplicate stems, we assume that
+% bibliography items appear sorted by label, which means that all
+% items with the same stem will be adjacent. This means we can use
+% the naive algorithm (check to see if the current item has the
+% same stem as the previous item and, if so, append a suffix) to
+% detect clashes. This sorting will be done automatically by
+% \bst{amsxport}, but the document author is responsible for
+% ensuring the appropriate order if \bst{amsxport} is not used.
+% This is why it's an error to mix the \opt{alphabetic} and
+% \opt{citation-order} options.
+%
+% \subsubsection{The implementation}
+%
+% \begin{macrocode}
+\let\previous@stem\@empty
+\let\current@stem\@empty
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\previous@year\@empty
+\let\current@year\@empty
+% \end{macrocode}
+%
+% \begin{macro}{\append@to@stem}
+% \begin{macrocode}
+\def\append@to@stem{\global\@concat\current@stem}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\generate@alphalabel}
+% \begin{macrocode}
+\def\generate@alphalabel{%
+% \end{macrocode}
+% If the user supplied an explicit \fld{label} field, we use it.
+% Otherwise, we generate our own.
+% \begin{macrocode}
+ \ifx\bib'label\@empty
+ \begingroup
+% \end{macrocode}
+% We begin by saving the previous stem and initializing the
+% current stem to the empty string.
+% \begin{macrocode}
+ \global\let\previous@stem\current@stem
+ \global\let\current@stem\@empty
+% \end{macrocode}
+% The list of primary contributors is available to us in
+% \cs{current@primary} in the form
+% \begin{quote}
+% \cnm{name}{$\mathrm{Last}_1, \mathrm{First}_1$}%
+% \cnm{name}{$\mathrm{Last}_2, \mathrm{First}_2$}
+% \ldots
+% \cnm{name}{$\mathrm{Last}_n, \mathrm{First}_n$}
+% \end{quote}
+% We will be executing this list multiple times with various
+% definitions of \cs{name}. So the first thing we want to do is
+% establish a safe environment and normalize the names.
+% \begin{macrocode}
+ \@apply\auto@protect\amsrefs@textsymbols
+ \@apply\auto@protect\amsrefs@textaccents
+ \auto@protect\name
+ \auto@protect\etaltext
+ \normalize@edef\@tempa\current@primary
+% \end{macrocode}
+% Now we count the number of authors in the list and invoke the
+% appropriate macro to calculate the author part of the
+% reference label.
+% \begin{macrocode}
+ \get@numberof\@tempcnta\name\@tempa
+ \calc@author@part
+% \end{macrocode}
+% Next append the year part.
+% \begin{macrocode}
+ \append@label@year
+% \end{macrocode}
+% At this point, the \cs{current@stem} is complete and we're ready
+% to determine what (if any) suffix is needed to disambiguate
+% it from the previous label.
+% \begin{macrocode}
+ \calc@alpha@suffix
+% \end{macrocode}
+% We have all the pieces now. Arrange to end the current group and
+% then define \cs{bib@label} in the enclosing group. (This keeps
+% \cs{bib@label} from being defined outside the group started by
+% \cs{bib@start}. This isn't strictly necessary, but it provides a
+% bit of compartmentalization.)
+% \begin{macrocode}
+ \edef\@tempa{%
+ \def\@nx\bib'label{%
+ \current@stem
+ \alpha@label@suffix
+ }%
+ }%
+ \@xp\endgroup
+ \@tempa
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\calc@author@part}
+% \begin{macrocode}
+\def\calc@author@part{%
+ \ifnum \@tempcnta = 1
+ \@xp\@oneauthorlabel\@xp{\@tempa}%
+ \else
+ \@xp\@multiauthorlabel\@xp{\@tempa}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@firstone}
+% This extracts the first character from a properly prepared author
+% name (i.e., one in which accents are properly wrapped).
+% \begin{macrocode}
+\def\@firstone#1{\@car#1\@empty\@nil}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@firstthree}
+% And this extracts the first three characters.
+% \begin{macrocode}
+\def\@firstthree#1{\@carcube#1\@empty\@empty\@empty\@nil}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@nametoken}
+% \begin{macrocode}
+\let\@nametoken\@firstone
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\hyph@to@space}
+% \begin{macrocode}
+\def\hyph@to@space#1-{#1 \hyph@to@space}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@marknames}
+% Since we have a~' with funny catcode already, let's use it (being
+% able to easily put a space after the |'| makes things easier).
+% \begin{macrocode}
+\def\@marknames#1{%
+ \@ifnotempty{#1}{\surround@names#1 ' }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\surround@names}
+% \begin{macrocode}
+\def\surround@names#1 {%
+ \ifx '#1%
+ \else
+ \@nx\@nametoken{#1}%
+ \@xp\surround@names
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\extract@surnames}
+% \begin{macrocode}
+\def\extract@surnames#1#2{%
+ \get@namepart\@tempb\@nilgobble #2,\@nil
+ \edef\@tempb{\@nx\@marknames{\@xp\hyph@to@space\@tempb\@gobble-}}%
+ \edef#1{\@tempb}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@oneauthorlabel}
+% This is the easy case.
+% \begin{macrocode}
+\newcommand{\@oneauthorlabel}[1]{%
+ \def\name##1{%
+ \extract@surnames\@tempa{##1}%
+ \get@numberof\@tempcnta\@nametoken\@tempa
+ \ifnum \@tempcnta = 1
+ \let\@nametoken\@firstthree
+ \fi
+ \append@to@stem{\@tempa}%
+ }%
+ #1%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@threeauthors}
+% \begin{macrocode}
+\def\@threeauthors\name#1\name#2\name#3#4\@empty{%
+ \name{#1}\name{#2}\name{#3}%
+ \append@to@stem{\etalchar{+}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@multiauthorlabel}
+% \begin{macrocode}
+\newcommand{\@multiauthorlabel}[1]{%
+ \def\name##1{%
+ \ifx\etaltext ##1%
+ \def\@tempa{\@nx\etalchar{+}}%
+ \let\name\@gobble
+ \else
+ \extract@surnames\@tempa{##1}%
+ \fi
+ \append@to@stem{\@tempa}%
+ }%
+ \ifnum \@tempcnta > 4 \@xp \@threeauthors \fi
+ #1\@empty
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\etalchar}
+% \begin{macrocode}
+\newcommand{\etalchar}[1]{$^{#1}$}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\year@short}
+% For alphanumeric labels, we want to extract the last 2 digits of
+% the year. Here's a way to do that, assuming a 4-digit year.
+% \begin{macrocode}
+\def\year@short#1#2#3#4\@nil{#3#4}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\append@label@year}
+% \begin{macrocode}
+\def\append@label@year{%
+ \safe@set\@tempcnta\bib@year
+ \edef\bib@citeyear{\the\@tempcnta}%
+ \append@to@stem{%
+ \ifx\bib@year\@empty
+ \else
+ \@xp\year@short \bib@citeyear \@nil
+ \fi
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\let\alpha@label@suffix\@empty
+
+\newcount\alpha@suffix
+\alpha@suffix\@ne
+\let\@suffix@format\@alph
+% \end{macrocode}
+%
+% \begin{macro}{\calc@alpha@suffix}
+% \begin{macrocode}
+\def\calc@alpha@suffix{%
+ \@tempswafalse
+ \compare@stems\previous@stem\current@stem
+ \ifsame@stems
+% \end{macrocode}
+% Under the \opt{alphabetic} option, \cs{previous@year} and
+% \cs{current@year} will always be the same (namely, both will be
+% empty), but including the test allows this code to work with the
+% \opt{author-year} option as well.
+% \begin{macrocode}
+ \ifx\previous@year\current@year
+ \@tempswatrue
+ \fi
+ \fi
+ \if@tempswa
+ \global\advance\alpha@suffix\@ne
+ \edef\alpha@label@suffix{\@suffix@format\alpha@suffix}%
+ \ifnum\alpha@suffix=\tw@
+ \immediate\write\@auxout{%
+ \string\ModifyBibLabel{\prev@citekey}%
+ }%
+ \fi
+ \else
+ \let\alpha@label@suffix\@empty
+ \global\alpha@suffix\@ne
+ \@xp\ifx \csname b@\current@citekey @suffix\endcsname \relax
+ \else
+ \edef\alpha@label@suffix{\@suffix@format\alpha@suffix}%
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ifsame@stems}
+% \begin{macrocode}
+\newif\ifsame@stems
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\compare@stems}
+% \begin{macrocode}
+\def\compare@stems#1#2{%
+ \begingroup
+ \purge@edef\@tempa{#1}%
+ \purge@edef\@tempb{#2}%
+ \lc@edef\@tempa{\@tempa}%
+ \lc@edef\@tempb{\@tempb}%
+ \ifx\@tempa\@tempb
+ \def\@tempa{\same@stemstrue}%
+ \else
+ \def\@tempa{\same@stemsfalse}%
+ \fi
+ \@xp\endgroup
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ModifyBibLabel}
+% \begin{macrocode}
+\def\ModifyBibLabel#1{%
+ \global\@xp\let\csname b@#1@suffix\endcsname\@empty
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Generating short alphabetic labels}
+%
+% This style for alphabetic labels is somewhat simpler than the
+% regular alphabetic style. The stem consists only of an author
+% part without a year part. The author part is formed in the same
+% way, except that even when there is only a single author with a
+% one-word last name, only the first letter of the name is used,
+% not the first three. Finally, the suffix used to disambiguate
+% identical stems is numeric rather than alphabetic.
+%
+% See section~\ref{opt:shortalphabetic} on
+% page~\pageref{opt:shortalphabetic} for the implementation.
+%
+% \subsection{Formatting series}
+%
+% The \cn{PrintSeries} command prints a list of objects in series
+% form. The essential idea is to produce something like \qq{A, B, and
+% C} when we are given three elements ``A'', ``B'', and ``C'', with
+% suitable variations in the punctuation and other intervening
+% material depending on the number of elements.
+%
+% More precisely, we can envision \cn{PrintSeries} being
+% called as
+% \begin{quote}
+% |\PrintSeries{|$S$|}{|$i_1$|}{|$i_2$|}{|$i_3$|}{|$E$|}{\do{|$T_1$|}| \dots|\do{|$T_n$|}}|
+%\end{quote}
+% where $S$ and~$E$ are material to be interpolated before the
+% start and after the end of the list, respectively,
+% $i_1$, \dots, $i_3$ are material to be interpolated between the
+% elements, and the final argument is a list of indeterminate
+% length where each element consists of a macro and its
+% argument. If there are exactly two elements, $i_1$ is inserted
+% between them; otherwise, $i_2$ is inserted between each pair of
+% items except for the last pair, where $i_3$ is inserted. Thus,
+% \begin{center}
+% \begin{tabular}{ll}
+% $n$ & output \\
+% 1 & $S$ $T_1$ $E$ \\
+% 2 & $S$ $T_1$ $i_1$ $T_2$ $E$ \\
+% 3 & $S$ $T_1$ $i_2$ $T_2$ $i_3$ $T_3$ $E$ \\
+% 4 & $S$ $T_1$ $i_2$ $T_2$ $i_2$ $T_3$ $i_3$ $T_4$ $E$
+%^^A \\$>4$ & $S$ $T_1$ $i_2$ $T_2$ $i_2$ $T_3$ \dots $T_{n-1}$ $i_3$ $T_n$ $E$
+% \end{tabular}
+% \end{center}
+% and so forth. For example, a standard comma-separated list could
+% be formatted by
+% \begin{verbatim}
+% \PrintSeries{}{ and }{, }{, and }{}{...}
+%\end{verbatim}
+%
+% That is the simple case but in practice there are
+% additional complications. What if user-supplied line breaks have to
+% be supported at the boundaries between elements? What if in
+% addition to adding material between elements we also want to apply
+% some handy function to each element (e.g., \cn{textsc})? Even
+% worse, what if we want the function to be different depending on
+% the position of the element in the list? Indeed if this did not
+% happen to be the case with the current application I would not have
+% gone to the extra trouble of supporting it. But if it must be so,
+% then the output that we need from a list |\do{A}\do{B}...| is
+% \begin{verbatim}
+% f0{A}
+% f0{A} p1 i1 f1{B}
+% f0{A} p2 i2 f2{B} p3 i3 f3{B}
+%\end{verbatim}
+% and so on, where
+% \begin{itemize}
+% \item $f_n$ is a macro taking one argument,
+% \item $p_n$ is punctuation\mdash material that must precede a line
+% break if one occurs at this boundary,
+% \item $i_n$ other interpolated material, as before.
+% \end{itemize}
+% To reduce the number of distinct required objects we decree that
+% each element will get braces wrapped around it as a matter of
+% course; then it is possible for $f_1$, $f_2$, $f_3$ to be
+% assimilated onto the tail end of $i_1$, $i_2$, $i_3$. Since we
+% also have to specify the macro that delimits the elements
+% of the list, we end up with the following rather formidable
+% signature:
+% \begin{quote}\raggedright
+% |\PrintSeries{\m} {|$f_0$|}|
+% |{|$p_1$|}{|$i_1 f_1$|}| |{|$p_2$|}{|$i_2 f_2$|}|
+% |{|$p_3$|}{|$i_3 f_3$|}|
+% \hspace*{2 em} |{|$S$|} {\m{|$T_1$|}|$\dots$|\m{|$T_n$|}} {|$E$|}|
+%\end{quote}
+% and our comma-separated list example becomes
+% \begin{verbatim}
+% \PrintSeries{\do}{} {}{ and } {,}{ } {,}{ and } {}{...}{}
+%\end{verbatim}
+%
+% \begin{macro}{\series@index}
+% First we define a dedicated count register to be used in tracking
+% the ordinal number of the item currently being processed.
+% \begin{macrocode}
+\newcount\series@index
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintSeries}
+% \begin{macrocode}
+\def\PrintSeries#1#2#3#4#5#6#7#8{%
+ \begingroup
+ \def\series@add@a{#2}%
+ \def\series@add@b{\SwapBreak{#3}#4}%
+ \def\series@add@c{\SwapBreak{#5}#6}%
+ \def\series@add@d{\SwapBreak{#7}#8}%
+ \def\series@add@e{\SwapBreak{#7}}%
+ \PrintSeries@a{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrinteSeries@a}
+% For \cs{PrintSeries@a} the first arg is the iterator function
+% present in the list which is arg 3. Args 2 and 4 are extra material
+% to be added before and after the list that may require the use of
+% \cn{Plural} or \cn{SingularPlural}.
+% \begin{macrocode}
+\def\PrintSeries@a#1#2#3#4{%
+ \get@numberof\@tempcnta#1{#3}%
+ \chardef\series@total=\@tempcnta
+ \ifnum\series@total=\@ne
+ \let\SingularPlural\@firstoftwo
+ \else
+ \let\SingularPlural\@secondoftwo
+ \fi
+ \series@index=\z@
+ \let#1\series@add
+ #2#3#4\relax
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\series@add}
+% This is the inner function called by \cn{PrintSeries} that
+% carefully distributes all the material stored previously in
+% \cs{series@add@...} macros.
+%
+% Note that the handling of ``et al.''\ cases is somewhat
+% hardcoded. This seemed preferable to adding yet another argument
+% (or two!\@) to \cs{PrintSeries}.
+% \begin{macrocode}
+\def\series@add#1{%
+ \advance\series@index\@ne
+ \ifx\etaltext#1\relax
+ \ifnum\series@index=\tw@
+ \def\@tempa{\space\SubEtal}%
+ \else
+ \def\@tempa{\series@add@e\space\SubEtal}%
+ \fi
+% \end{macrocode}
+% We assume there are fewer than 20,000 items in the list.
+% \begin{macrocode}
+ \series@index\@MM
+ \else
+ \ifcase\series@index
+ \or
+% \end{macrocode}
+% Material before name 1:
+% \begin{macrocode}
+ \let\@tempa\series@add@a
+ \or
+% \end{macrocode}
+% Material before name 2:
+% \begin{macrocode}
+ \ifnum\series@total<\thr@@
+ \let\@tempa\series@add@b
+ \else
+ \let\@tempa\series@add@c
+ \fi
+ \else
+% \end{macrocode}
+% Material before names 3, 4, 5,\dots
+% \begin{macrocode}
+ \ifnum\series@index=\series@total
+ \let\@tempa\series@add@d
+ \else
+ \ifnum\series@index<\series@total
+ \let\@tempa\series@add@c
+ \else
+ \let\@tempa\@gobble
+ \fi
+ \fi
+ \fi
+ \fi
+ \@tempa{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\SwapBreak}
+% This takes a single argument, which should begin with a
+% punctuation character, and conditionally appends it to the
+% current horizontal list after removing any preceding whitespace.
+% If there was also a penalty at the end of the hlist (presumed to
+% be the result of a |\linebreak| at the end of a field value), it
+% moves the penalty to \emph{after} the argument.
+%
+% \begin{bug}
+% \cn{SwapBreak} interferes with \TeX's kerning mechanism. For
+% example, consider a field value that ends with a~``y'' and that
+% should have a comman automatically appended. \pkg{amsrefs}
+% generates the equivalent of |y\SwapBreak{,}|, which results in
+% ``y\SwapBreak{,}'' (no kern before the comma) rather than~``y,''.
+% Unfortunately, fixing this would likely require a
+% disproportionate effort. In cases where the lack of kerning is
+% unacceptable, a workaround is to add the punctuation mark to the
+% field value manually. For example, |title={...y,}| would
+% generate the equivalent of |y,\SwapBreak{,}|, which in turn would
+% produce ``y,\SwapBreak{,}'' since \cs{SwapBreak} is careful not
+% to add duplicate punctuation.
+% \end{bug}
+% \begin{macrocode}
+\def\SwapBreak#1{%
+ \relax\ifvmode\leavevmode\fi
+ \@tempcnta\@MM
+ \toks@{#1}%
+% \end{macrocode}
+% First, remove any preceding glue. (There usually shouldn't be
+% any of this.)
+% \begin{macrocode}
+ \unskip
+% \end{macrocode}
+% There might be also be kern, typically an italic correction left
+% there by a previous \texttt{TextFontCommand} like \ncn{textit}.
+% But don't remove the special 1\,sp kern used to mark the
+% beginning of a bibliography entry.
+%
+% \begin{bug}
+% Sometimes we want to keep the italic correction.
+% \end{bug}
+% \begin{macrocode}
+ \ifnum \lastkern>\@ne \unkern \fi
+% \end{macrocode}
+% And now look for a penalty and stash it in a safe place.
+% \begin{macrocode}
+ \ifnum\lastpenalty=\z@
+ \else
+ \@tempcnta\lastpenalty
+ \unpenalty
+ \fi
+% \end{macrocode}
+% Now we add the punctuation, \emph{unless} one of the following
+% conditions is true:
+% \begin{enumerate}
+%
+% \item
+% The last item on the horizontal list was a kern of~1\,sp,
+% indicating that we're at the very beginning of a bibliography
+% item.
+%
+% \item
+% The current space factor is equal to the \cs{sfcode} of the
+% puncutation mark we are adding, meaning that the mark is already
+% on the list.
+%
+% \item
+% The current space factor is equal to the special value
+% |\@nopunctsfcode|, meaning that |\nopunct| was specified.
+%
+% \end{enumerate}
+% This relies on distinct punctuation marks having distinct space
+% factors, as established by our definition of \cn{frenchspacing}.
+% \begin{macrocode}
+ \edef\@tempa{%
+ \@nx\deferredquoteslogical
+ \ifnum\lastkern=\@ne
+ \else
+ \ifnum\spacefactor=\sfcode\@xp\@xp\@xp`\@xp\@car\string#1)\@nil
+ \else
+ \ifnum\spacefactor=\@nopunctsfcode
+ \else
+ \the\toks@
+ \fi
+ \fi
+ \fi
+ \@nx\deferredquotes
+ \ifnum\@tempcnta=\@MM \else \penalty\number\@tempcnta\space \fi
+ \ifnum\lastkern=\@ne \ignorespaces \fi
+ }%
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Plural}
+% \begin{macro}{\SingularPlural}
+% \cn{Plural} takes one argument and prints it if there were two or
+% more elements in the current list. So, to get \qq{editors} instead
+% of \qq{editor} after printing a list of editor names, write
+% \verb'editor\Plural{s}'.
+%
+% \cn{SingularPlural} takes two arguments and prints the first if
+% there was only one element, otherwise prints the second arg.
+% \begin{macrocode}
+\newcommand{\SingularPlural}[2]{#1}
+\newcommand{\Plural}{\SingularPlural{}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Formatting names and series of names}\label{name-style}
+%
+% Now that we have a general mechanism for formatting series, we
+% can easily specialize to the common case of a comma-separated
+% list of names. First we provide specifications for the three
+% most common name formats.
+%
+% \begin{macro}{\setbib@nameLE}
+% This sets a name in standard western uninverted order, e.g.,
+% ``John Doe Jr.'' (The ``LE'' stands for little-endian.)
+% \begin{macrocode}
+\BibSpec{nameLE}{
+ +{}{}{given}
+ +{}{\IfEmptyBibField{given}{}{ }}{surname}
+ +{}{ }{jr}
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\setbib@nameBE}
+% Big-endian order, as used for example in traditional Chinese,
+% Japanese, Vietnamese, and Hungarian names: ``Doe John''.
+% Big-endian formatting can be requested for name by setting the
+% ``inverted'' property to ``yes.''
+% \begin{macrocode}
+\BibSpec{nameBE}{
+ +{}{}{surname}
+ +{}{ }{given}
+% \end{macrocode}
+% I don't know what should happen if there's a suffix, so I'm going
+% to just leave it out for now (although I should probably issue a
+% warning). I suspect that either (a)~it never comes up or (b)~if
+% it does come up, there's no set standard for how it should be
+% handled.
+% \begin{macrocode}
+% +{}{ }{jr}
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\setbib@nameinverted}
+% Inverted western-style names: ``Doe, John, Jr.''
+% \begin{macrocode}
+\BibSpec{nameinverted}{
+ +{} {} {surname}
+ +{,}{ } {given}
+ +{,}{ } {jr}
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Incidentally, it would probably be cleaner if names had their
+% own namespace like properties do, i.e., something like
+% \begin{verbatim}
+% \DefineSimpleKey{name}{given}
+% \DefineSimpleKey{name}{initials}
+% \DefineSimpleKey{name}{surname}
+% \DefineSimpleKey{name}{jr}
+%\end{verbatim}
+% followed by
+% \begin{verbatim}
+% \NameSpec{nameLE}{...}
+%\end{verbatim}
+% or
+% \begin{verbatim}
+% \BibSpec[name]{nameLE}{...}
+%\end{verbatim}
+% But this seems a little extravagant at this stage, so I've
+% decided to leave things as-is for now.
+%
+% \begin{macro}{\PrintNames}
+% \cn{PrintNames} is a simplified interface to \cs{PrintSeries} that
+% takes only the last three arguments:
+% \begin{quote}\raggedright
+% |\PrintNames {|$S$|} {|$E$|} {\name{|$T_1$|}|$\dots$|\name{|$T_n$|}}|
+%\end{quote}
+% The order of the last two arguments is reversed to make it
+% moderately easier to use; cf.\ \cn{PrintEditorsA}, etc.
+%
+% The first name in a series is treated differently than the other
+% names in the \opt{author-year} style, so we use a separate
+% formatting macro for it.
+% \begin{macrocode}
+\newcommand{\PrintNames}{%
+ \@ifstar{\PrintNames@a\set@othername}{\PrintNames@a\set@firstname}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintNames@a}
+% \begin{macrocode}
+\newcommand{\PrintNames@a}[4]{%
+ \PrintSeries{\name}
+ {#1}
+ {}{ and \set@othername}
+ {,}{ \set@othername}
+ {,}{ and \set@othername}
+ {#2}{#4}{#3}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\set@firstname}
+% By default, the first name is formatted in little-endian format.
+% The \opt{author-year} option changes this to inverted order.
+% \begin{macrocode}
+\def\set@firstname#1{%
+ \set@name{#1}\setbib@nameLE
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\set@othername}
+% The rest of the names are set in little-endian format by
+% default.
+% \begin{macrocode}
+\def\set@othername#1{%
+ \set@name{#1}\setbib@nameLE
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\set@name}
+% Parse the name into its components and then pass control to
+% \cs{set@name@a}, which will decide what format to use for the
+% name.
+% \begin{macrocode}
+\def\set@name#1{%
+ \name@split#1,,,\@nil
+ \set@name@a
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\set@namea}
+% Use the requested format unless the |order| property has been set
+% to ``inverted.''
+% \begin{macrocode}
+\def\set@name@a#1{%
+ \begingroup
+ \get@current@properties
+ \select@auxlanguage
+ \def\@tempa{yes}%
+ \ifx\@tempa\prop'inverted
+ \setbib@nameBE
+ \else
+ #1%
+ \fi
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintPrimary}
+% \begin{macrocode}
+\def\PrintPrimary{%
+ \ifx\current@primary\@empty
+ \EmptyPrimaryWarning
+ \else
+ \print@primary\current@primary
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\EmptyPrimaryWarning}
+% \begin{macrocode}
+\def\EmptyPrimaryWarning{%
+ \amsrefs@warning{No authors, editors or translators}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintAuthors}
+% The comparison of \cs{previous@primary} and \cs{current@primary}
+% doesn't look at auxiliary properties (see also \cs{PrintEditorsA}
+% and \cs{PrintTranslatorsA}). This is probably ok.
+% \begin{macrocode}
+\newcommand{\PrintAuthors}[1]{%
+ \ifx\previous@primary\current@primary
+ \sameauthors\@empty
+ \else
+ \def\current@bibfield{\bib'author}%
+ \PrintNames{}{}{#1}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\sameauthors}
+% \begin{macrocode}
+\newcommand{\sameauthors}[1]{\bysame#1}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bysame}
+% \begin{macrocode}
+\def\bysame{%
+ \leavevmode\hbox to3em{\hrulefill}\thinspace
+ \kern\z@
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintNameList}
+% This just prints the names without any additional information.
+% \begin{macrocode}
+\newcommand{\PrintNameList}{\PrintNames{}{}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintEditorsC}
+% \begin{macrocode}
+\newcommand{\PrintEditorsC}[1]{%
+ \PrintNames{Edited by }{}{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintEditorsA}
+% When we consider editor names we have to think about some further
+% complications. First, for the case of a book where editor names are
+% listed in place of author names, just copy the same style with a
+% bit of added text at the end.
+% \begin{macrocode}
+\newcommand{\PrintEditorsA}[1]{%
+ \ifx\previous@primary\current@primary
+ \sameauthors{(ed\Plural{s}.)}%
+ \else
+ \def\current@bibfield{\bib'editor}%
+ \PrintNames{}{ (ed\Plural{s}.)}{#1}%
+ \fi
+ \erase@field\bib'editor
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintEditorsB}
+% \begin{macrocode}
+\newcommand{\PrintEditorsB}{%
+ \PrintNames*{(}{\SwapBreak{,}~ed\Plural{s}.)}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintContributions}
+% \begin{macrocode}
+\newcommand{\PrintContributions}[1]{%
+ \PrintSeries
+ {\fld@elt}
+ {\print@contribution}
+ {}{ and \print@contribution}
+ {,}{ \print@contribution}
+ {,}{ and \print@contribution}{}{#1}{}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\print@contribution}
+% \begin{macrocode}
+\newcommand{\print@contribution}[1]{%
+ \in@={#1}%
+ \ifin@
+ \ifnum\series@index=\@ne with \fi
+ \RestrictedSetKeys{}{bib}{%
+ \bib@print@inner\setbib@contribution{\the\rsk@toks}%
+ }{#1}%
+ \else
+ #1%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\resolve@inner}
+% \begin{macrocode}
+\def\resolve@inner#1#2{%
+ \in@={#2}%
+ \ifin@
+ \RestrictedSetKeys{}{bib}{#1{\the\rsk@toks}}{#2}%
+ \else
+ \@ifundefined{bi@#2}{%
+ \XRefWarning{#2}%
+ }{%
+ #1{\csname bi@#2\endcsname}%
+ }%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintConference}
+% \begin{macrocode}
+\def\PrintConference{%
+ \resolve@inner{\bib@print@inner\setbib@conference}
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintConferenceDetails}
+% \begin{macrocode}
+\def\PrintConferenceDetails#1{%
+ \ifx\@empty\bib'address
+ \ifx\@empty\bib'date
+ \else
+ \PrintConferenceDetails@
+ \fi
+ \else
+ \PrintConferenceDetails@
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintConferenceDetails@}
+% \begin{macrocode}
+\def\PrintConferenceDetails@{%
+ \ifnum\lastkern=\@ne\else\space\fi(\kern 1sp
+ \ifx\@empty\bib'address
+ \else
+ \bib'address
+ \fi
+ \ifx\@empty\bib'date
+ \else
+ \SwapBreak{,}\space
+ \print@date
+ \fi
+ )%\spacefactor\sfcode`\,%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintBook}
+% \begin{macrocode}
+\def\PrintBook{%
+ \resolve@inner{\bib@print@inner\setbib@innerbook}
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintReprint}
+% \begin{macrocode}
+\def\PrintReprint{%
+ \resolve@inner{\bib@reprint}
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bib@reprint}
+% \begin{macrocode}
+\def\bib@reprint#1{%
+ \begingroup
+ #1\relax % execute definitions locally
+ \bib@field@patches
+ \bib'setup
+ \IfEmptyBibField{copula}{reprinted in}{\bib'copula} \nopunct
+ \let\bib'language\@empty
+ \setbib@book
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintTranslation}
+% \begin{macrocode}
+\def\PrintTranslation{%
+ \resolve@inner{\bib@translation}
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bib@translation}
+% \begin{macrocode}
+\def\bib@translation#1{%
+ \begingroup
+ #1\relax % execute definitions locally
+ \bib@field@patches
+ \bib'setup
+ \let\PrintPrimary\@empty
+ \bib@append{;}{ % keep this space!
+ \IfEmptyBibField{language}{English}{\bib'language} transl.%
+ \IfEmptyBibField{pages}{ in \kern\@ne sp}{, }%
+ }\bib'transition
+ \let\bib'language\@empty
+ \setbib@@
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintTranslatorsC}
+% \begin{macrocode}
+\newcommand{\PrintTranslatorsC}[1]{%
+ \PrintNames{translated by }{}{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintTranslatorsA}
+% \begin{macrocode}
+\newcommand{\PrintTranslatorsA}[1]{%
+ \ifx\previous@primary\current@primary
+ \sameauthors{(trans.)}%
+ \else
+ \def\current@bibfield{\bib'translator}%
+ \PrintNames{}{ (trans.)}{#1}%
+ \fi
+ \erase@field\bib'translator
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintTranslatorsB}
+% \begin{macrocode}
+\newcommand{\PrintTranslatorsB}[1]{
+ \PrintNames*{(}{\SwapBreak{,}~tran\Plural{s}.)}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Some special handling for ``et alii'' or ``and others''.
+% \begin{macrocode}
+\DefineName{alii}{\etaltext}
+\DefineName{others}{\etaltext}
+% \end{macrocode}
+%
+% \begin{macro}{\etaltext}
+% \begin{macro}{\SubEtal}
+% The Chicago Manual of Style suggests that it is slightly better not
+% to italicize `et al' and some other extremely common abbreviations
+% inherited from Latin. (Compare `etc'.)
+% \begin{macrocode}
+\newcommand{\etaltext}{et al.}
+\newcommand{\SubEtal}[1]{\etaltext}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{The \fld{partial} field}
+%
+% \begin{macro}{\print@partial}
+% \begin{macrocode}
+\newcommand{\print@partial}{%
+ \resolve@inner{\bib@print@inner\setbib@partial}
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Special formatting for other fields}
+%
+% \begin{macro}{\parenthesize}
+% The \cn{parenthesize} function adds parentheses around its
+% argument, calling \cn{upn} to optionally prevent italic
+% parentheses from being used.
+% \begin{macrocode}
+\newcommand{\parenthesize}[1]{%
+ \leavevmode\push@bracket)\upn{(}#1\pop@bracket
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\upn}
+% By default, \cn{upn} is a no-op, meaning that this refinement
+% lies dormant unless the \pkg{upref} package or other activation
+% is done. (Probably better done via special fonts, anyway.)
+% \begin{macrocode}
+\providecommand{\upn}[1]{#1}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\push@bracket}
+% \begin{macro}{\pop@bracket}
+% \begin{macrocode}
+\let\bracket@stack\@empty
+
+\def\push@bracket#1{%
+ \xdef\bracket@stack{#1\bracket@stack}%
+}
+
+\def\pop@bracket{%
+ \iffalse{\fi
+ \@xp\pop@bracket@a\bracket@stack \@empty}%
+}
+
+\def\pop@bracket@a#1{%
+ \leavevmode\/\upn{#1}%
+ \xdef\bracket@stack{\iffalse}\fi
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\bibquotes}
+% \begin{macrocode}
+\newcommand{\bibquotes}[1]{%
+ \textquotedblleft#1%
+ \gdef\deferredquotes{%
+ \global\let\deferredquotes\@empty
+ \textquotedblright
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\mdash}
+% \begin{macro}{\ndash}
+% Cf.\@ \pkg{textcmds}, where there's also a penalty added.
+% \begin{macrocode}
+\providecommand{\mdash}{\textemdash}
+\providecommand{\ndash}{\textendash}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\MR}
+% \begin{macrocode}
+\def\MR#1{%
+ \relax\ifhmode\unskip\spacefactor3000 \space\fi
+ \def\@tempa##1:##2:##3\@nil{%
+ \ifx @##2\@empty##1\else\textbf{##1:}##2\fi
+ }%
+ \MRhref{#1}{MR \@tempa#1:@:\@nil}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MRhref}
+% For older versions of some AMS document classes, this patch is
+% needed.
+% \begin{macrocode}
+\providecommand{\MRhref}[1]{}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintReviews}
+% Reviews are handled as a list to support the theoretical
+% possibility of multiple reviews.
+% \begin{macrocode}
+\newcommand{\PrintReviews}[1]{%
+ \PrintSeries{\fld@elt}{}{,}{ }{,}{ }{,}{ }{}{#1}{}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintPartials}
+% \begin{macrocode}
+\newcommand{\PrintPartials}[1]{%
+ \PrintSeries
+ {\fld@elt}
+ {\print@partial}
+ {;}{ \print@partial}
+ {;}{ \print@partial}
+ {;}{ \print@partial}{}{#1}{}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintISBNs}
+% And similarly for ISBNs. There seem to be a few different
+% situations where one book might have two different ISBN numbers.
+% Here are the ones I know of so far [mjd,2002-02-18]: separate ISBN
+% numbers for hardback and paperback; separate ISBN numbers for U.S.
+% edition and European edition.
+% \begin{macrocode}
+\newcommand{\PrintISBNs}[1]{%
+ \PrintSeries{\fld@elt}{}{,}{ }{,}{ }{,}{ }{ISBN }{#1}{}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\voltext}
+% \begin{macrocode}
+\newcommand{\voltext}{\IfEmptyBibField{series}{Vol.~}{vol.~}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\issuetext}
+% \begin{macrocode}
+\newcommand{\issuetext}{no.~}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DashPages}
+% Scan the contents of a page value to see if it is a single page.
+% Presence of \cn{ndash} or hyphen is taken to mean no. Probably
+% should test also for spaces and commas. [mjd,2000/01/24]
+% \begin{macrocode}
+\newcommand{\DashPages}[1]{%
+ p\pp@scan@a#1@\ndash p@\ndash{\pp@scan#1@-p@-{}\@nil}\@nil.~#1%
+}
+
+\def\pp@scan#1-#2@-#3#4\@nil{#3}
+
+\def\pp@scan@a#1\ndash#2@\ndash#3#4\@nil{#3}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\eprintpages}
+% If we have eprint info and pages info and no journal name, the
+% pages information is presumably the number of pages in the eprint.
+% \begin{macrocode}
+\newcommand{\eprintpages}[1]{%
+ #1\IfEmptyBibField{eprint}{}{\IfEmptyBibField{journal}{ pp.}{}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintThesisType}
+% \begin{macrocode}
+\def\PrintThesisType#1{%
+ \thesis@type#1?\@nil{#1}%
+}
+
+\def\thesis@type#1#2\@nil#3{%
+ \ifx p#1%
+ Ph.D. Thesis%
+ \else
+ \ifx m#1%
+ Master's Thesis%
+ \else
+ #3%
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintDOI}
+% Perhaps need to add allowbreak penalties at the parentheses in a DOI.
+% Also what about prohibiting a break after the leading S?
+% \begin{macrocode}
+\newcommand{\PrintDOI}[1]{%
+ DOI #1%
+ \IfEmptyBibField{volume}{, (to appear in print)}{}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintDatePV}
+% Print date in different forms depending on DOI and volume
+% information.
+% \begin{macrocode}
+\newcommand{\PrintDatePV}[1]{%
+ \IfEmptyBibField{doi}{%
+ \let\@tempa\PrintDate
+ }{%
+ \IfEmptyBibField{volume}{%
+ \let\@tempa\PrintDatePosted
+ }{%
+ \let\@tempa\PrintDate
+ }%
+ }%
+ \@tempa{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintDate}
+% The intent is to handle variations such as \texttt{1987},
+% \texttt{August 1987}, \texttt{1987-08}, and
+% \texttt{1987-08-14}. If the month is present, print August or
+% Aug. or 08 or nothing, at the behest of the bib style.
+%
+% We've taken some special care to parse out the date info ahead of
+% time, so this function just discards arg 1 and uses the
+% already-parsed value.
+% \begin{macrocode}
+\newcommand{\PrintDate}[1]{(\print@date)}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintDateB}
+% The same, but without the parentheses.
+% \begin{macrocode}
+\newcommand{\PrintDateB}[1]{\print@date}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\print@date}
+% \begin{macrocode}
+\def\print@date{%
+ \ifx\bib@month\@empty
+ \else
+ \print@month@day
+ \fi
+ \bib@year
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\print@month@day}
+% \begin{macrocode}
+\def\print@month@day{%
+ \bib@monthname
+ \ifx\@empty\bib@day \else \nobreakspace\number 0\bib@day,\fi
+ \space
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bib@monthname}
+% With the Babel package, month names for a given language are
+% typically available in a macro \cs{month@}\emph{language}:
+% \begin{verbatim}
+% \def\month@german{\ifcase\month\or
+% Januar\or Februar\or M\"arz\or April\or Mai\or Juni\or
+% Juli\or August\or September\or Oktober\or November\or Dezember\fi}
+%\end{verbatim}
+% However this is not true for English.
+% \begin{macrocode}
+\newcommand{\bib@monthname}{%
+ \ifcase 0\bib@month
+ \or January\or February\or March\or April\or May\or June\or
+ July\or August\or September\or October\or November\or December\or
+ Winter\or Spring\or Summer\or Fall\else Unknown Month%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintYear}
+% You can use \cn{PrintYear} if you want to suppress month/day even
+% when supplied in the data.
+% \begin{macrocode}
+\newcommand{\PrintYear}[1]{\bib@year}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintDatePosted}
+% This one is special for AMS use.
+% \begin{macrocode}
+\newcommand{\PrintDatePosted}[1]{\unskip, posted on \print@date}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintEdition}
+% \begin{macrocode}
+\newcommand{\PrintEdition}[1]{%
+ \afterassignment\print@edition
+ \count@ 0#1\relax\@nil
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\print@edition}
+% If the number assignment swept up all the contents, produce a
+% cardinal number from \cs{count@}.
+% \begin{macrocode}
+\def\print@edition#1#2\@nil{%
+ \ifx\relax#1\relax
+ \ifnum\count@>\z@
+ \CardinalNumeric\count@
+ \else
+ ??th%
+ \fi
+ \ \editiontext
+ \else
+ \ifnum \count@>\z@ \number\count@ \fi
+ #1#2\relax
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\editiontext}
+% \begin{macrocode}
+\newcommand{\editiontext}{ed.}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\CardinalNumber}
+% \begin{macrocode}
+\newcommand{\CardinalNumeric}[1]{%
+ \number#1\relax
+ \if
+ \ifnum#1<14
+ \ifnum#1>\thr@@ T\else F\fi
+ \else
+ F%
+ \fi
+ T%
+ th%
+ \else
+ \@xp\keep@last@digit\@xp#1\number#1\relax
+ \ifcase#1th\or st\or nd\or rd\else th\fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\keep@last@digit}
+% \begin{macrocode}
+\def\keep@last@digit#1#2{%
+ \ifx\relax#2%
+ \@xp\@gobbletwo
+ \else
+ #1=#2\relax
+ \fi
+ \keep@last@digit#1%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\SentenceSpace}
+% Note how careful we are here to preserve \cn{frenchspacing}.
+% \begin{macrocode}
+\newcommand{\SentenceSpace}{\relax\ifhmode\spacefactor`\. \fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\eprint}
+% For now, this does nothing. Could do a url/hyperlink or something.
+% \begin{macrocode}
+\newcommand{\eprint}[1]{\url{#1}}
+% \end{macrocode}
+% \end{macro}
+% The \url{www.arXiv.org} recommendations for citing their eprints are
+% found at \url{http://xxx.lanl.gov/help/faq/references}, including
+% these examples:
+% \begin{verbatim}
+% arXiv:hep-th/9910001
+% arXiv:math.AT/9910001
+% arXiv:physics.acc-ph/9911027
+%\end{verbatim}
+%
+% \subsection{\BibTeX\ support}
+%
+% \begin{macro}{\bibliographystyle}
+% Disable \cn{bibliographystyle} since we're going to handle that
+% behind the scenes.
+% \begin{macrocode}
+\let\bibliographystyle\@gobble
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bibtex@style}
+% \begin{macrocode}
+\def\bibtex@style{amsrn}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\AtBeginDocument{
+ \if@filesw
+ \immediate\write\@auxout{\string\bibstyle{\bibtex@style}}%
+ \fi
+}
+% \end{macrocode}
+%
+% \subsection{Implementing package options}
+%
+% \subsubsection{The \opt{alphabetic} option}
+%
+% \begin{macrocode}
+\IfOption{alphabetic}{%
+ \def\bibtex@style{amsra}%
+ \def\alpha@label{%
+ \ifx\@empty\bib'label
+ \def\thebib{\CurrentBib}%
+ \else
+ \let\thebib\bib'label
+ \fi
+ }%
+ \let\generate@label\generate@alphalabel
+ \let\process@citelist\process@citelist@unsorted
+ \def\numeric@refs{01}%
+}{}
+% \end{macrocode}
+%
+% \subsubsection{The \opt{shortalphabetic} option}
+% \label{opt:shortalphabetic}
+%
+% \begin{macrocode}
+\IfOption{shortalphabetic}{%
+ \def\bibtex@style{amsrs}%
+ \def\alpha@label{%
+ \ifx\@empty\bib'label
+ \def\thebib{\CurrentBib}%
+ \else
+ \let\thebib\bib'label
+ \fi
+ }%
+ \let\@suffix@format\@arabic
+ \def\calc@author@part{%
+ \@xp\@multiauthorlabel\@xp{\@tempa}%
+ }%
+ \let\append@label@year\@empty
+ \let\generate@label\generate@alphalabel
+ \let\process@citelist\process@citelist@unsorted
+ \def\numeric@refs{01}%
+}{}
+% \end{macrocode}
+%
+% \subsubsection{The \opt{backrefs} option}
+%
+% \begin{macrocode}
+\IfOption{backrefs}{%
+ \let\PrintBackRefs\print@backrefs
+ \@ifundefined{Hy@backout}{%
+ \amsrefs@warning{backref option requires hyperref package}%
+ }{%
+ \let\BackCite\back@cite
+ \AtBeginDocument{\@starttoc{brf}{}}%
+ }%
+}{%
+}
+% \end{macrocode}
+%
+% \subsubsection{The \opt{citation-order} option}
+%
+% \begin{macrocode}
+\IfOption{citation-order}{%
+ \IfOption{alphabetic}{%
+ \amsrefs@warning@nl{%
+ The 'citation-order' and 'alphabetic' options are
+ incompatible%
+ }%
+ }{
+ \def\bibtex@style{amsru}%
+ }
+}{}
+% \end{macrocode}
+%
+% \subsubsection{The \opt{initials} option}
+%
+% \begin{macrocode}
+\IfOption{initials}{% TRUE:
+ \BibSpec{nameLE}{
+ +{}{}{initials}
+ +{}{\IfEmptyBibField{initials}{}{ }}{surname}
+ +{}{ }{jr}
+ }
+
+ \BibSpec{nameBE}{
+ +{}{}{surname}
+ +{}{ }{initials}
+ % +{}{ }{jr}
+ }
+
+ \BibSpec{nameinverted}{
+ +{} {} {surname}
+ +{,}{ } {initials}
+ +{,}{ } {jr}
+ }
+}{% initials? FALSE:
+% \let\extract@initials\@gobble
+} % end conditional code for initials option
+% \end{macrocode}
+%
+% \subsubsection{The \opt{jpa} option}
+%
+% \begin{macrocode}
+\IfOption{jpa}{%
+ \amsrefs@warning{The 'jpa' option is obsolete}%
+ \typeout{Trying \string\usepackage{amsjpa} instead ...}%
+ \RequirePackage{amsjpa}[2000/02/02]
+}{}
+% \end{macrocode}
+%
+% \subsubsection{The \opt{logical-quotes} option}
+%
+% \begin{macro}{\deferredquotes}
+% \begin{macrocode}
+\let\deferredquotes\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\deferredquoteslogical}
+% \begin{macrocode}
+\IfOption{logical-quotes}{%
+ \def\deferredquoteslogical{\deferredquotes}%
+}{%
+ \let\deferredquoteslogical\relax
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{The \opt{non-compressed-cites} option}
+%
+% \begin{macrocode}
+\IfOption{non-compressed-cites}{%
+ \let\cite@compress\cite@print
+}{}
+% \end{macrocode}
+%
+% \subsubsection{The \opt{non-sorted-cites} option}
+%
+% \begin{macrocode}
+\IfOption{non-sorted-cites}{%
+ \let\process@citelist\process@citelist@unsorted
+}{}
+% \end{macrocode}
+%
+% \subsubsection{The \opt{short-journals} option}
+%
+% \begin{macrocode}
+\IfOption{short-journals}{%
+ \renewcommand{\DefineJournal}[4]{%
+ \bib*{#1}{periodical}{
+ issn={#2},
+ journal={#3},
+ }%
+ }
+}{}
+% \end{macrocode}
+%
+% \subsubsection{The \opt{short-publishers} option}
+%
+% \begin{macrocode}
+\IfOption{short-publishers}{%
+ \renewcommand{\DefinePublisher}[4]{%
+ \bib*{#1}{publisher}{%
+ publisher={#2},%
+% \end{macrocode}
+% Maybe \opt{short-publishers} should suppress the \fld{address}? Or
+% is that a separate option? I sense a combinatorial explosion
+% coming on.\ldots
+% \begin{macrocode}
+ address={#4},
+ }%
+ }%
+}{}
+% \end{macrocode}
+%
+% \subsubsection{The \opt{short-months} option}
+%
+% \begin{macrocode}
+\IfOption{short-months}{%
+ \renewcommand{\bib@monthname}{%
+ \ifcase 0\bib@month
+ \or Jan.\or Feb.\or Mar.\or Apr.\or May\or June\or
+ July\or Aug.\or Sep.\or Oct.\or Nov.\or Dec.\or
+ Winter\or Spring\or Summer\or Fall\else Unknown Month%
+ \fi
+ }%
+}{}
+% \end{macrocode}
+%
+% \subsubsection{The \opt{y2k} option}
+%
+% \begin{macrocode}
+\IfOption{y2k}{%
+ \IfOption{alphabetic}{%
+ \def\year@short#1\@nil{#1}%
+ \def\bibtex@style{amsry}%
+ }{%
+ \amsrefs@warning@nl{%
+ The 'y2k' option can only be used with the^^J%
+ 'alphabetic' option%
+ }%
+}
+}{}
+% \end{macrocode}
+%
+% \subsubsection{The \opt{bibtex-style} option}
+%
+% \begin{macrocode}
+\IfOption{bibtex-style}{%
+ \RequirePackage{amsbst}
+}{}
+% \end{macrocode}
+%
+% \subsubsection{The \opt{author-year} option}
+%
+% Here ends the \pkg{amsrefs} package, unless the \opt{author-year}
+% option is in effect; then we want to use some different
+% bibspecs.
+% \begin{macrocode}
+\IfOption{author-year}{}{\PopCatcodes \endinput}
+% \end{macrocode}
+%
+% \begin{macro}{\generate@label}
+% \begin{macrocode}
+\def\generate@label{%
+% \end{macrocode}
+% If the user supplied an explicit \fld{label} field, we use it.
+% Otherwise, we generate our own.
+% \begin{macrocode}
+ \ifx\bib'label\@empty
+ \begingroup
+% \end{macrocode}
+% We begin by saving the previous stem and initializing the
+% current stem to the empty string.
+% \begin{macrocode}
+ \global\let\previous@stem\current@stem
+ \global\let\current@stem\@empty
+ \global\let\previous@year\current@year
+ \global\let\current@year\bib@year
+% \end{macrocode}
+% The list of primary contributors is available to us in
+% \cs{current@primary} in the form
+% \begin{quote}
+% \cnm{name}{$\mathrm{Last}_1, \mathrm{First}_1$}%
+% \cnm{name}{$\mathrm{Last}_2, \mathrm{First}_2$}
+% \ldots
+% \cnm{name}{$\mathrm{Last}_n, \mathrm{First}_n$}
+% \end{quote}
+% We will be executing this list multiple times with various
+% definitions of \cs{name}. So the first thing we want to do is
+% establish a safe environment and normalize the names.
+% \begin{macrocode}
+ \@apply\auto@protect\amsrefs@textsymbols
+ \@apply\auto@protect\amsrefs@textaccents
+ \def\name##1{\@nx\name{\lnscan@a##1,\@nil}}%
+ \auto@protect\etaltext
+ \normalize@edef\current@stem{\current@primary}%
+ \xdef\current@stem{\current@stem}%
+% \end{macrocode}
+% At this point, the \cs{current@stem} is complete and we're ready
+% to determine what (if any) suffix is needed to disambiguate
+% it from the previous label.
+% \begin{macrocode}
+ \calc@alpha@suffix
+% \end{macrocode}
+% We have all the pieces now. Arrange to end the current group and
+% then define \cs{bib@label} in the enclosing group. (This keeps
+% \cs{bib@label} from being defined outside the group started by
+% \cs{bib@start}. This isn't strictly necessary, but it provides a
+% bit of compartmentalization.)
+% \begin{macrocode}
+ \edef\@tempa{%
+ \def\@nx\cite@label{\current@stem}%
+ \def\@nx\bib@label@year{%
+ \current@year
+ \alpha@label@suffix
+ }%
+ }
+ \@xp\endgroup
+ \@tempa
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\lnscan@a}
+% \begin{macrocode}
+\def\lnscan@a#1,#2\@nil{#1}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citesel@author}
+% \begin{macrocode}
+\def\citesel@author#1#2#3#4#5{\PrintCiteNames{#3}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citesel@authoryear}
+% \begin{macrocode}
+\def\citesel@authoryear#1#2#3#4#5{\PrintCNY{#3}{#4}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citesel@object}
+% \begin{macrocode}
+\def\citesel@object#1#2#3#4#5{\PrintCiteNames{#3} \citeleft#4}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citesel}
+% \begin{macrocode}
+\let\citesel\citesel@authoryear
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\numeric@refs}
+% \begin{macrocode}
+\def\numeric@refs{01}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citeleft}
+% \begin{macrocode}
+\def\citeleft{(}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citeright}
+% \begin{macrocode}
+\def\citeright{)}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@citeleft}
+% \begin{macrocode}
+\def\@citeleft{\ifx\citesel\citesel@object\else\citeleft\fi}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citepunct}
+% \begin{macrocode}
+\def\citepunct{; }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\BibLabel}
+% \begin{macrocode}
+\let\BibLabel\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\process@citelist}
+% \begin{macrocode}
+\let\process@citelist\process@citelist@unsorted
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ycite}
+% \begin{macrocode}
+\DeclareRobustCommand{\ycite}[1]{%
+ \star@{\cite@a\citesel@year{#1}}{}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ycites}
+% \begin{macrocode}
+\DeclareRobustCommand{\ycites}[1]{%
+ \begingroup
+ \def\citepunct{, }%
+ \let\citesel\citesel@year
+ \cites{#1}%
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ocite}
+% \begin{macrocode}
+\DeclareRobustCommand{\ocite}[1]{%
+ \star@{\cite@a\citesel@object{#1}}{}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ocites}
+% \begin{macrocode}
+\DeclareRobustCommand{\ocites}[1]{%
+ \begingroup
+ \let\@citelist\@ocitelist
+ \cites{#1}%
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ocitelist}
+% \begin{macrocode}
+\def\@ocitelist#1{%
+ \PrintSeries{\InnerCite}%
+ {\ocite}%
+ {}{ and \ocite}%
+% \end{macrocode}
+% For three or more names: print `et al' instead of the last name.
+% Have to putz around with the space factor a bit or the comma
+% between name and year will not be applied.
+% \begin{macrocode}
+ {,}{ \ocite}%
+ {,}{ and \ocite}%
+ {}%
+ {#1}%
+ {}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citeauthor}
+% \begin{macrocode}
+\DeclareRobustCommand{\citeauthor}[1]{%
+ \star@{\cite@a\citesel@author{#1}}{}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citeauthory}
+% \begin{macrocode}
+\DeclareRobustCommand{\citeauthory}[1]{%
+ \citeauthor{#1} \ycite{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fullcite}
+% \begin{macrocode}
+\DeclareRobustCommand{\fullcite}[1]{%
+ \begingroup
+ \let\print@citenames\CiteNamesFull
+ \star@{\cite@a\citesel@authoryear{#1}}{}%
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fullocite}
+% \begin{macrocode}
+\DeclareRobustCommand{\fullocite}[1]{%
+ \begingroup
+ \let\print@citenames\CiteNamesFull
+ \star@{\cite@a\citesel@object{#1}}{}%
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Invert the first author's name.
+% \begin{macrocode}
+\def\set@firstname#1{%
+ \set@name{#1}\setbib@nameinverted
+}
+% \end{macrocode}
+%
+% \begin{macro}{\PrintCNY}
+% \begin{macrocode}
+\def\PrintCNY#1#2{%
+ \PrintCiteNames{#1}%
+ \@ifnotempty{#2}{\@addpunct{,} #2}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintCiteNames}
+% \begin{macrocode}
+\def\PrintCiteNames#1{%
+ \leavevmode
+ \def\@tempa{#1}%
+ \ifx\@tempa\prev@names
+ \else
+ \gdef\prev@names{#1}%
+ \@xp\ifx\@car#1.\@nil\CitePrintUndefined
+ #1\relax
+ \else
+ \print@citenames{#1}%
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\CiteNames}
+% \begin{macrocode}
+\newcommand{\CiteNames}[1]{%
+ \PrintSeries{\name}%
+ {}%
+ {}{ and }%
+% \end{macrocode}
+% For three or more names: print `et al' instead of the last name.
+% Have to putz around with the space factor a bit or the comma
+% between name and year will not be applied.
+% \begin{macrocode}
+ {}{\@gobble}%
+ {}{ \etaltext\@\@gobble}%
+ {}%
+ {#1}%
+ {}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\print@citenames}
+% \begin{macrocode}
+\let\print@citenames\CiteNames
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\CiteNamesFull}
+% \begin{macrocode}
+\newcommand{\CiteNamesFull}[1]{%
+ \PrintSeries{\name}%
+ {}%
+ {}{ and }%
+% \end{macrocode}
+% For three or more names: print `et al' instead of the last name.
+% Have to putz around with the space factor a bit or the comma
+% between name and year will not be applied.
+% \begin{macrocode}
+ {,}{ }%
+ {,}{ and }%
+ {}%
+ {#1}%
+ {}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintDate}
+% No parentheses around the year.
+% \begin{macrocode}
+\renewcommand{\PrintDate}[1]{\bib@label@year}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\print@date}
+% Only print the year, not the month or day.
+% \begin{macrocode}
+\def\print@date{%
+ \IfEmptyBibField{date}{%
+ \IfEmptyBibField{year}{\BibField{status}}{\bib@year}%
+ }{%
+ \bib@year
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\BibSpec{article}{%
+ +{} {\PrintAuthors} {author}
+ +{.} { \PrintDate} {date}
+ +{.} { \textit} {title}
+ +{.} { } {part}
+ +{:} { \textit} {subtitle}
+ +{,} { \PrintContributions} {contribution}
+ +{.} { \PrintPartials} {partial}
+ +{,} { } {journal}
+ +{} { \textbf} {volume}
+ +{,} { \issuetext} {number}
+ +{,} { \eprintpages} {pages}
+ +{,} { } {status}
+ +{,} { \PrintDOI} {doi}
+ +{,} { available at \eprint} {eprint}
+ +{} { \parenthesize} {language}
+ +{} { \PrintTranslation} {translation}
+ +{;} { \PrintReprint} {reprint}
+ +{.} { } {note}
+ +{.} {} {transition}
+ +{} {\SentenceSpace \PrintReviews} {review}
+}
+
+\BibSpec{book}{%
+ +{} {\PrintPrimary} {transition}
+ +{.} { \PrintDate} {date}
+ +{.} { \textit} {title}
+ +{.} { } {part}
+ +{:} { \textit} {subtitle}
+ +{,} { \PrintEdition} {edition}
+ +{} { \PrintEditorsB} {editor}
+ +{,} { \PrintTranslatorsC} {translator}
+ +{,} { \PrintContributions} {contribution}
+ +{,} { } {series}
+ +{,} { \voltext} {volume}
+ +{,} { } {publisher}
+ +{,} { } {organization}
+ +{,} { } {address}
+ +{,} { } {status}
+ +{} { \parenthesize} {language}
+ +{} { \PrintTranslation} {translation}
+ +{;} { \PrintReprint} {reprint}
+ +{.} { } {note}
+ +{.} {} {transition}
+ +{} {\SentenceSpace \PrintReviews} {review}
+}
+
+\BibSpec{collection.article}{%
+ +{} {\PrintAuthors} {author}
+ +{.} { \PrintDate} {date}
+ +{.} { \textit} {title}
+ +{.} { } {part}
+ +{:} { \textit} {subtitle}
+ +{,} { \PrintContributions} {contribution}
+ +{,} { \PrintConference} {conference}
+ +{} {\PrintBook} {book}
+ +{,} { } {booktitle}
+ +{,} { pp.~} {pages}
+ +{,} { } {status}
+ +{,} { \PrintDOI} {doi}
+ +{,} { available at \eprint} {eprint}
+ +{} { \parenthesize} {language}
+ +{} { \PrintTranslation} {translation}
+ +{;} { \PrintReprint} {reprint}
+ +{.} { } {note}
+ +{.} {} {transition}
+ +{} {\SentenceSpace \PrintReviews} {review}
+}
+
+\BibSpec{report}{%
+ +{} {\PrintPrimary} {transition}
+ +{.} { \PrintDate} {date}
+ +{.} { \textit} {title}
+ +{.} { } {part}
+ +{:} { \textit} {subtitle}
+ +{,} { \PrintEdition} {edition}
+ +{,} { \PrintContributions} {contribution}
+ +{,} { Technical Report } {number}
+ +{,} { } {series}
+ +{,} { } {organization}
+ +{,} { } {address}
+ +{,} { \eprint} {eprint}
+ +{,} { } {status}
+ +{} { \parenthesize} {language}
+ +{} { \PrintTranslation} {translation}
+ +{;} { \PrintReprint} {reprint}
+ +{.} { } {note}
+ +{.} {} {transition}
+ +{} {\SentenceSpace \PrintReviews} {review}
+}
+
+\BibSpec{thesis}{%
+ +{} {\PrintAuthors} {author}
+ +{.} { \PrintDate} {date}
+ +{.} { \textit} {title}
+ +{:} { \textit} {subtitle}
+ +{,} { \PrintThesisType} {type}
+ +{,} { } {organization}
+ +{,} { } {address}
+ +{,} { \eprint} {eprint}
+ +{,} { } {status}
+ +{} { \parenthesize} {language}
+ +{} { \PrintTranslation} {translation}
+ +{;} { \PrintReprint} {reprint}
+ +{.} { } {note}
+ +{.} {} {transition}
+ +{} {\SentenceSpace \PrintReviews} {review}
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\PopCatcodes
+%</pkg>
+% \end{macrocode}
+%
+% \subsection{The \pkg{amsbst} package}
+%
+% \begin{macrocode}
+%<*bst>
+% \end{macrocode}
+%
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+\ProvidesPackage{amsbst}[2004/03/29 v1.68]
+%\RequirePackage{amsrefs}[2004/03/29]
+% \end{macrocode}
+%
+% \begin{macrocode}
+\BibSpec{article}{%
+ +{} {\PrintAuthors} {author}
+ +{.} { } {title}
+ +{.} { } {part}
+ +{:} { } {subtitle}
+ +{.} { \PrintContributions} {contribution}
+ +{.} { \PrintPartials} {partial}
+ +{.} { \emph} {journal}
+ +{} { } {volume}
+ +{} { \parenthesize} {number}
+ +{:} {} {pages}
+ +{,} { \PrintDateB} {date}
+ +{,} { } {status}
+ +{.} { \PrintTranslation} {translation}
+ +{.} { Reprinted in \PrintReprint} {reprint}
+ +{.} { } {note}
+ +{.} {} {transition}
+}
+
+\BibSpec{partial}{%
+ +{} {} {part}
+ +{:} { } {subtitle}
+ +{.} { \PrintContributions} {contribution}
+ +{.} { \emph} {journal}
+ +{} { } {volume}
+ +{} { \parenthesize} {number}
+ +{:} {} {pages}
+ +{,} { \PrintDateB} {date}
+}
+
+\BibSpec{book}{%
+ +{} {\PrintPrimary} {transition}
+ +{.} { \emph} {title}
+ +{.} { } {part}
+ +{:} { \emph} {subtitle}
+ +{.} { } {series}
+ +{,} { \voltext} {volume}
+ +{.} { Edited by \PrintNameList} {editor}
+ +{.} { Translated by \PrintNameList}{translator}
+ +{.} { \PrintContributions} {contribution}
+ +{.} { } {publisher}
+ +{.} { } {organization}
+ +{,} { } {address}
+ +{,} { \PrintEdition} {edition}
+ +{,} { \PrintDateB} {date}
+ +{.} { } {note}
+ +{.} {} {transition}
+ +{.} { \PrintTranslation} {translation}
+ +{.} { Reprinted in \PrintReprint} {reprint}
+ +{.} {} {transition}
+}
+
+\BibSpec{collection.article}{%
+ +{} {\PrintAuthors} {author}
+ +{.} { } {title}
+ +{.} { } {part}
+ +{:} { } {subtitle}
+ +{.} { \PrintContributions} {contribution}
+ +{.} { \PrintConference} {conference}
+ +{.} { \PrintBook} {book}
+ +{.} { In } {booktitle}
+ +{,} { pages~} {pages}
+ +{.} { \PrintDateB} {date}
+ +{.} { \PrintTranslation} {translation}
+ +{.} { Reprinted in \PrintReprint} {reprint}
+ +{.} { } {note}
+ +{.} {} {transition}
+}
+
+\BibSpec{conference}{%
+ +{} {} {title}
+ +{} {\PrintConferenceDetails} {transition}
+}
+
+\BibSpec{innerbook}{%
+ +{.} { \emph} {title}
+ +{.} { } {part}
+ +{:} { \emph} {subtitle}
+ +{.} { } {series}
+ +{,} { \voltext} {volume}
+ +{.} { Edited by \PrintNameList} {editor}
+ +{.} { Translated by \PrintNameList}{translator}
+ +{.} { \PrintContributions} {contribution}
+ +{.} { } {publisher}
+ +{.} { } {organization}
+ +{,} { } {address}
+ +{,} { \PrintEdition} {edition}
+ +{,} { \PrintDateB} {date}
+ +{.} { } {note}
+ +{.} {} {transition}
+}
+
+\BibSpec{report}{%
+ +{} {\PrintPrimary} {transition}
+ +{.} { \emph} {title}
+ +{.} { } {part}
+ +{:} { \emph} {subtitle}
+ +{.} { \PrintContributions} {contribution}
+ +{.} { Technical Report } {number}
+ +{,} { } {series}
+ +{.} { } {organization}
+ +{,} { } {address}
+ +{,} { \PrintDateB} {date}
+ +{.} { \PrintTranslation} {translation}
+ +{.} { Reprinted in \PrintReprint} {reprint}
+ +{.} { } {note}
+ +{.} {} {transition}
+}
+
+\BibSpec{thesis}{%
+ +{} {\PrintAuthors} {author}
+ +{,} { \emph} {title}
+ +{:} { \emph} {subtitle}
+ +{.} { \PrintThesisType} {type}
+ +{.} { } {organization}
+ +{,} { } {address}
+ +{,} { \PrintDateB} {date}
+ +{.} { \PrintTranslation} {translation}
+ +{.} { Reprinted in \PrintReprint} {reprint}
+ +{.} { } {note}
+ +{.} {} {transition}
+}
+% \end{macrocode}
+%
+% \begin{macro}{\PrintEditorsA}
+% When we consider editor names we have to think about some further
+% complications. First, for the case of a book where editor names are
+% listed in place of author names, just copy the same style with a
+% bit of added text at the end.
+% \begin{macrocode}
+\renewcommand{\PrintEditorsA}[1]{%
+ \def\current@bibfield{\bib'editor}%
+ \PrintNames{}{, editor\Plural{s})}{#1}%
+ \erase@field\bib'editor
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\PrintTranslatorsA}
+% \begin{macrocode}
+\renewcommand{\PrintTranslatorsA}[1]{%
+ \def\current@bibfield{\bib'translator}%
+ \PrintNames{}{, translator\Plural{s}}{#1}%
+ \erase@field\bib'translator
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+%</bst>
+% \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}
+%
+% \CheckSum{5005}
+% \Finale
diff --git a/Master/texmf-dist/source/latex/amslatex/amstext.dtx b/Master/texmf-dist/source/latex/amslatex/amstext.dtx
new file mode 100644
index 00000000000..0ef49f67a64
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/amstext.dtx
@@ -0,0 +1,314 @@
+%%% ====================================================================
+%%% @LaTeX-file{
+%%% filename = "amstext.dtx",
+%%% version = "2.01",
+%%% date = "2000/06/29",
+%%% time = "08:34:33 EDT",
+%%% checksum = "09860 314 1647 12368",
+%%% author = "American Mathematical Society",
+%%% copyright = "Copyright 1995, 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.",
+%%% 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",
+%%% email = "tech-support@ams.org (Internet)",
+%%% supported = "yes",
+%%% keywords = "latex, math, text",
+%%% abstract = "This is a \LaTeX{} package that defines a
+%%% \cn{\text} macro, which makes it easy to
+%%% incorporate fragments of text inside a displayed
+%%% equation or a sub or superscript. Font sizes
+%%% are automatically scaled in sub/superscripts.",
+%%% 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
+%<*driver>
+\documentclass{amsdtx}
+\usepackage{amstext}
+\begin{document}
+\title{The \pkg{amstext} package}
+\author{Frank Mittelbach \and Rainer Sch\"opf}
+\date{Version \fileversion, \filedate}
+\hDocInput{amstext.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \maketitle
+%
+% \MakeShortVerb\|
+%
+% \section{Introduction}
+%
+% This style file implements the \AmSTeX{} macro \cn{text} for use
+% with the new font selection scheme. The \cn{text} macro is a
+% sophisticated command which allows the user to insert ``normal text''
+% into math formulas without worrying about correct sizes in sub- or
+% superscripts. It can also be used in ordinary text; there it
+% produces an unbreakable unit similar to \cn{mbox}.
+%
+% Here is an example demonstrating some of its features:
+% \[
+%^^A mathbin spacing is nonscript glue, disappears in superscript
+% x^{2\,\times\,\text{size of $y$}}
+% \leq
+% z_{i_{\text{upper bound of the array}}}
+% \]
+% This was produced by
+% \begin{verbatim}
+% \[
+% x^{2\,\times\,\text{size of $y$}}
+% \leq
+% z_{i_{\text{upper bound of the array}}}
+% \]
+% \end{verbatim}
+%
+% Additionally this style file redefines an internal \fn{plain.tex}
+% macro called \cs{mathhexbox} so that commands like \cn{dag}
+% or \cn{P} will change sizes if used in math subscripts.
+%
+% \StopEventually{}
+% Package information.
+% \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
+\ProvidesPackage{amstext}[2000/06/29 v2.01]
+% \end{macrocode}
+%
+% \section{The implementation}
+% We need a few tools from \fn{amsgen.sty}.
+% \begin{macrocode}
+\RequirePackage{amsgen}
+% \end{macrocode}
+%
+% \begin{macro}{\text}
+% Now we come to the \cn{text} macro which is used to place
+% ordinary text inside of math formulas. If it is used outside
+% math it will produce an unbreakable unit of text.
+% \begin{macrocode}
+\DeclareRobustCommand{\text}{%
+ \ifmmode\expandafter\text@\else\expandafter\mbox\fi}
+% \end{macrocode}
+% At the present time (late 1994) the \latex/ internal function
+% |\nfss@text| is used in |\ref|, in font commands like |\textbf|,
+% and in a few text symbol definitions like |\$| and |\pounds|. By
+% equating |\nfss@text| to |\text| we give it the ability of
+% |\text| to change sizes properly if used in a subscript.
+% \begin{macrocode}
+\let\nfss@text\text
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\text@}
+% If \cn{text} is encountered inside math mode the macro
+% \cs{text@} is called. It has one mandatory argument, the text
+% which should be produced. Since we do not know in which math
+% style we are currently in we call \cs{mathchoice} to tyeset
+% our text in all four possible styles.
+% \begin{macrocode}
+\def\text@#1{{\mathchoice
+% \end{macrocode}
+% To save token space we call a macro \cs{textdef@} which takes
+% three arguments: the current math style, the corresponding size
+% macro and the text to typeset possibly with some additional
+% information for typesetting.
+% \begin{macrocode}
+ {\textdef@\displaystyle\f@size{#1}}%
+% \end{macrocode}
+% The other three cases are similar except for the
+% \cs{iffirstchoice} switch which we set to false. This is
+% done to prevent \LaTeX{} macros like \cn{ref} or \cn{index}
+% from writing their arguments more than once.
+% \begin{macrocode}
+ {\textdef@\textstyle\f@size{\firstchoice@false #1}}%
+ {\textdef@\textstyle\sf@size{\firstchoice@false #1}}%
+ {\textdef@\textstyle \ssf@size{\firstchoice@false #1}}%
+% \end{macrocode}
+% Here we need to check whether a math size-change occurred inside
+% the argument of \cn{text}. If so, restore
+% \begin{macrocode}
+ \check@mathfonts
+ }%
+}
+% \end{macrocode}
+% The macros \cs{f@size}, \cs{sf@size} and \cs{ssf@size} hold the
+% sizes which should be used when we are loading a new font for use
+% in \cs{textfont}, \cs{scriptfont} and \cs{scriptscriptfont}. There
+% is some question whether we should use use \cs{tf@size} or
+% \cs{f@size} for the main size, but since the primary purpose of the
+% \cn{text} macro is to switch back to text within a display, it
+% seems that \cs{f@size} is the better choice. (Indeed it could be
+% said that the \cn{text} actually provides two different functions:
+% one for escaping out of math mode in a display to print some words,
+% and the other for handling math objects that are named by a
+% fragment of text, when \cn{operatorname} isn't the right choice.
+% For the latter \cs{tf@size} might be more correct but for the
+% former \cs{f@size} is clearly better.)
+% \end{macro}
+%
+% \begin{macro}{\textdef@}
+% To typeset the argument of \cn{text} correctly we have to make
+% several actions. We start by placing everything inside an
+% \cs{hbox}. But this is not enough: we need one extra level of
+% grouping. These extra braces are necessary because of the new
+% font selection scheme which might produce an \cs{aftergroup}
+% to globally restore some font values after the current group. To
+% prevent any damage by this mechanism we add the braces thereby
+% bringing the token inserted by \cs{aftergroup} inside the
+% \cs{hbox}.\footnote{The mechanism will not produce a second
+% \cs{aftergroup}. For more details see the technical documentation
+% for NFSS2.}
+% \begin{macrocode}
+\def\textdef@#1#2#3{\hbox{{%
+% \end{macrocode}
+% Since text typeset inside an \cs{hbox} always stays in the size
+% of the text surrounding the formula we have to adjust this for
+% script and scriptscript sizes. For any math formula inside this
+% argument this will be achieved by setting \cs{everymath} to
+% the first argument of \cs{textdef@} since this argument
+% contains the math size in the current typeset case of
+% \cs{mathchoice}.
+% Since \latex/ also knows about \cn{parbox}es and the
+% \env{minipage} environment it might be neccessary to adjust
+% \cs{everydisplay} too but this has to be tested further.
+% \begin{macrocode}
+ \everymath{#1}%
+% \end{macrocode}
+% The next line of code changes locally (i.e.\ inside the current
+% \cs{hbox}) the value of \cs{f@size}. This macro holds the
+% size for typesetting ordinary text (e.g.\ loading or selecting a
+% new font via \cs{selectfont}). By changing it to a smaller
+% value a following \cs{selectfont} will switch to the wanted
+% size.
+% \begin{macrocode}
+ \let\f@size#2\selectfont
+% \end{macrocode}
+% Now we simply call the third argument and close all open groups.
+% \begin{macrocode}
+ #3}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\iffirstchoice@}
+% Here is the switch that we use to decide if \cn{ref} etc.\
+% should print its warnings. The default is true since
+% normally these warnings shouldn't be suppressed.
+% \begin{macrocode}
+\newif\iffirstchoice@
+\firstchoice@true
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Re-definition of \latex/ macros to work with \cn{text}}
+%
+% If a counter-changing command occurs inside the argument of
+% \cn{text}, we don't want the counter to be changed four times
+% because \cn{stepcounter} and \cn{addtocounter} have global effect.
+% So we add the \cs{iffirstchoice@} test to make the counter
+% operations execute only once.
+%
+% \begin{macro}{\stepcounter}
+% Use \cs{def} rather than \cn{renewcommand*} because the star-form
+% (for non-\cs{long} definitions) doesn't work with the June 1994
+% release of \latex/.
+% \begin{macrocode}
+\def\stepcounter#1{%
+ \iffirstchoice@
+ \addtocounter{#1}\@ne
+ \begingroup \let\@elt\@stpelt \csname cl@#1\endcsname \endgroup
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\addtocounter}
+% \begin{macrocode}
+\def\addtocounter#1#2{%
+ \iffirstchoice@
+ \@ifundefined {c@#1}{\@nocounterr {#1}}%
+ {\global \advance \csname c@#1\endcsname #2\relax}%
+ \fi}
+% \end{macrocode}
+% \end{macro}
+%
+% For \cn{ref}, \cn{pageref}, and indeed anything else that issues a
+% warning or error, \cn{text} will produce four copies of the
+% warning/error message. To suppress the last three copies, we change
+% \cs{GenericInfo}, \cs{GenericWarning}, \cs{GenericError}.
+% \begin{macrocode}
+\let\m@gobble\@empty
+\@xp\let\csname m@gobble4\endcsname\@gobblefour
+\long\@xp\def\csname m@gobble6\endcsname#1#2#3#4#5#6{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\toks@{%
+ \csname m@gobble\iffirstchoice@\else 4\fi\endcsname
+ \protect}
+\edef\GenericInfo{\the\toks@
+ \@xp\@nx\csname GenericInfo \endcsname}
+%
+\edef\GenericWarning{\the\toks@
+ \@xp\@nx\csname GenericWarning \endcsname}
+%
+\toks@{%
+ \csname m@gobble\iffirstchoice@\else 6\fi\endcsname
+ \protect}
+\edef\GenericError{\the\toks@
+ \@xp\@nx\csname GenericError \endcsname}
+% \end{macrocode}
+%
+% At one time \cn{label}, \cs{@wrindex} and \cs{@wrglossary} were
+% changed here too to use the \cs{iffirstchoice@} test but it seems
+% that was a mistake because those are non-immediate writes.
+% Something like
+% \begin{verbatim}
+% \text{something \index{foo}}
+% \end{verbatim}
+% within a math formula would therefore \emph{lose the index term} if
+% the surrounding context was not displaystyle. (Unlikely in
+% practice, but not impossible.) [mjd,1994/12/09]
+%
+%\subsection{Applications of \cn{text}}
+%
+% \begin{macro}{\mathhexbox}
+% We start with an re-definition of the \fn{plain.tex} macro
+% \cs{mathhexbox}. (Although M. Spivak in \amstex/ uses the name
+% \cs{mathhexbox@} for this purpose, I [FMi] don't see any reason
+% to use a new name since the new definition is superior, has the
+% same syntax and is used for the same purpose.)
+% \begin{macrocode}
+\begingroup \catcode`\"=12
+\gdef\mathhexbox#1#2#3{\text{$\m@th\mathchar"#1#2#3$}}
+\endgroup
+% \end{macrocode}
+% This redefinition means that now symbols like \S, \P, \dag, \ldots,
+% which are defined via \cs{mathhexbox} in \fn{plain.tex} or
+% elsewhere now correctly change sizes if they are used in math mode.
+% \end{macro}
+%
+% 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}
+%
+% \CheckSum{129}
+% \Finale
diff --git a/Master/texmf-dist/source/latex/amslatex/amsxport.dtx b/Master/texmf-dist/source/latex/amslatex/amsxport.dtx
new file mode 100644
index 00000000000..308a8c2698c
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/amsxport.dtx
@@ -0,0 +1,1822 @@
+%%% ====================================================================
+%%% @BibTeX-source-file{
+%%% filename = "amsxport.dtx",
+%%% version = "2.00",
+%%% date = "2004/06/28",
+%%% time = "14:50:12 EDT",
+%%% author = "Michael J Downes",
+%%% address = "American Mathematical Society,
+%%% Publications Technical Group,
+%%% PO Box 6248,
+%%% Providence, RI 02940,
+%%% USA",
+%%% email = "tech-support at ams.org",
+%%% URL = "http://www.ams.org/",
+%%% abstract = "The BibTeX style file amsxport.bst produces .bbl
+%%% entries where most of the database structure is
+%%% retained. This is intended for processing by a smart
+%%% bibliography package such as the amsrefs package.",
+%%% checksum = "40425 1822 6396 51551",
+%%% docstring = "The checksum field, produced by Robert Solovay's
+%%% checksum utility, gives CRC-16 checksum, lines,
+%%% words, and characters.",
+%%% }
+%%% ====================================================================
+% \iffalse
+%<*driver>
+\NeedsTeXFormat{LaTeX2e}
+\documentclass[draft,oneside]{amsdtx}[1999/11/01]
+
+\providecommand{\vn}[1]{\emph{#1}}% variable name
+
+\renewcommand*\descriptionlabel[1]{\hspace\labelsep
+ \normalfont\bfseries #1:}
+
+%% Use normal typesize instead of \small for code listings.
+
+\def\MacroFont{%
+ \fontencoding\encodingdefault
+ \fontfamily\ttdefault
+ \fontseries\mddefault
+ \upshape
+}
+
+\makeatletter
+
+%% Don't prepend \ to macro names.
+
+\def\SpecialIndex@#1#2{%
+ \@SpecialIndexHelper@#1\@nil
+ \def\@tempb{ }%
+ \ifcat \@tempb\@gtempa
+ \special@index{\quotechar\space\actualchar
+ \string\verb\quotechar*\verbatimchar
+ \quotechar\space\verbatimchar#2}%
+ \else
+ \def\@tempb##1##2\relax{\ifx\relax##2\relax
+ \def\@tempc{\special@index{\quotechar##1\actualchar
+ \string\verb\quotechar*\verbatimchar
+ \quotechar##1\verbatimchar#2}}%
+ \else
+ \def\@tempc{\special@index{##1##2\actualchar
+ \string\verb\quotechar*\verbatimchar
+ ##1##2\verbatimchar#2}}%
+ \fi}%
+ \expandafter\@tempb\@gtempa\relax
+ \@tempc
+ \fi}
+
+\makeatother
+
+\PageIndex
+
+\begin{document}
+\title{The AMS Export Bib\TeX{} style [\fn{amsxport}]}
+\author{American Mathematical Society\\Michael Downes\\David M. Jones}
+\date{Version \fileversion, \filedate}
+\hDocInput{amsxport.dtx}
+\PrintIndex
+\end{document}
+%</driver>
+% \fi
+%
+% \MakeShortVerb{\|}
+%
+% \maketitle
+%
+% \tableofcontents
+%
+% \section{Introduction}
+%
+% \bst{amsxport} is the collective name for a collection of
+% \bibtex/ styles that form a bridge between \BibTeX\ and
+% \pkg{amsrefs}. It produces output in which the structural
+% information of the original \bibtex/ database file is
+% retained. No ad hoc visual formatting is introduced that would
+% hamper the application of alternative design specifications when
+% rendering the information on paper or screen. This makes it
+% possible to have \bibtex/ handle only extraction and sorting and
+% leave the visual appearance to be controlled entirely by
+% \latex/. The process of applying typical bibliography specs to
+% exported data is illustrated in the \pkg{amsrefs} package. The
+% authoritative description of the export format is in the
+% \pkg{amsrefs} documentation, inasmuch as interpreting the format
+% is the chief task of the \pkg{amsrefs} package.
+%
+% Each of the five \fn{.bst} files generated from this file
+% corresponds to a combination of \pkg{amsrefs} package options, as
+% follows:
+% \begin{description}
+%
+% \item[amsrn]
+%
+% This is the default style, used when none of the following is
+% appropriate.
+%
+% \item[amsru]
+%
+% This is used when the \opt{citation-order} option is specified.
+% It is identical to \bst{amsrn} except that the bibliography items
+% are not sorted.
+%
+% \item[amsra]
+%
+% This is when with the \opt{alphabetic} option is specified, byt
+% the \opt{y2k} option is \emph{not} also specified.
+%
+% \item[amsry]
+%
+% This is used when both the \opt{alphabetic} and \opt{y2k} options
+% are specified.
+%
+% \item[amsrs]
+%
+% This is used when the \opt{shortalphabetic} option is specified.
+%
+% \end{description}
+%
+% Readers may wish to refer also to the standard \bibtex/
+% documentation (\fn{btxdoc.tex}, \fn{btxhak.tex}, \fn{btxbst.doc})
+% for background information.
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+%
+% The list below gives the fields that are expected to occur. (Other
+% fields will be discarded without comment.)
+% suggested fields.
+% \begin{macrocode}
+%<*bst>
+ENTRY
+ {
+ address institution number status
+ archive isbn organization subtitle
+ author issn pages title
+ booktitle journal part translator
+ chapter key pii type
+ date language preprint url
+ edition meeting publisher volume
+ editor month review xid
+ eprint mrnumber school year
+ howpublished note series
+ }
+ { }
+ { label }
+% \end{macrocode}
+%
+% Some comments about specific fields:
+% \begin{description}
+% \item[archive] The archive that holds the eprint listed in the
+% \fn{eprint} field.
+% \item[author] \bibtex/ doesn't allow this field (or any field) to be
+% used more than once, but in the output its contents will be split
+% into a separate key-value pair for each name. Likewise for
+% \fn{editor} and \fn{translator}.
+% \item[crossref] This is a built-in field type, so it doesn't occur in
+% the argument of ENTRY above.
+% \item[date] This is a generalization of the \fn{year} and \fn{month}
+% fields. Its value should be written in ISO 8601 format, e.g.,
+% 1987-06-05; but the day and month are omissible, so this can be
+% easily be used instead of the \fn{year} field.
+% \item[edition] For books. The \bibtex/ documentation suggests that the
+% value of this field should be an ordinal word such as \qq{Second}.
+% This may be because the \bibtex/ language provides only the weakest
+% sort of support for an \emph{is-numeric} test.
+% \item[eprint] Electronic preprint information such as for
+% \url{www.arXiv.org}.
+% \item[institution] What's the difference between an \fn{institution}
+% and an \fn{organization}? The \bibtex/ documentation says that
+% \fn{institution} should be used for technical reports and
+% \fn{organization} for other entry types.
+% \item[isbn] International Standard Book Number.
+% \item[issn] International Standard Serial Number. See the discussion
+% of journal abbreviations.
+% \item[language] Language of the work. This is especially desirable
+% when the value of the title field is a translation of the true
+% title (most often when the original language is one like Arabic or
+% Chinese that poses rendering problems for non-native software).
+% \item[meeting] Since \bibtex/ doesn't allow a field name to be the
+% same as a function name, we have to use \fn{meeting} instead of
+% \fn{conference} if we want to give the title of a conference in a
+% dedicated field.
+% \item[mrnumber] An alias for \fn{review} which we provide because
+% MathSciNet has been using it in the \bibtex/ output that it
+% provides for a couple of years already.
+% \item[organization] See the comment for \fn{institution}.
+% \item[pii] Publisher Item Identifier
+% \item[part] This is for a long journal article that is published in
+% separate issues of the same journal. There should be a separate
+% \bibtex/ entry for each part (though all the ones after part 1
+% could crossref the first one).
+%
+% \item[preprint] It is not possible quite yet to assume that all
+% preprints should be classified as eprints. If you have a preprint
+% that is not an eprint, use this field to give the \qq{address}
+% where the preprint may be found (institution, preprint number,
+% etc.).
+%
+% \item[review] Review numbers or similar pointers, e.g., for
+% Mathematical Reviews or Zentralblatt.
+%
+% \item[school] The analog of \qq{organization}, for a thesis.
+%
+% \item[status] Typically used for notes such as ``to appear'' or ``in
+% preparation'' with journal articles.
+%
+% \item[subtitle] Typically used with a multipart journal article to
+% give a subtitle for each part.
+%
+% \item[translator] This needs no explanation, surely? Except perhaps to
+% note that the standard \bibtex/ styles don't provide it.
+%
+% \item[url] Universal Resource Locator.
+%
+% \item[xid] This is used by a cross-referenced item to pass its
+% identity to child entries that refer to it. It would not be
+% necessary if \bibtex/ left the \fn{crossref} field value
+% accessible, but for some reason that I have not found yet (skimming
+% in the source code) it is cleared internally before there is any
+% opportunity to save it.
+%
+% Practically speaking: For every \fn{crossref} in your \fn{.bib}
+% files, the target should contain a matching \fn{xid} field.
+%
+% \end{description}
+%
+% More on extra fields. In the Shelah bibliography, the \fn{author}
+% field is given without any accents in the author names, and the
+% normal \tex/ version of the author names is given in a separate
+% field called \fn{trueauthor}.
+%
+% Also, for MR reviews:
+% \begin{verbatim}
+% review = {MR 48:3735},
+%\end{verbatim}
+% And for each author a country is indicated with the \fn{fromwhere}
+% field, e.g.,
+% \begin{verbatim}
+% fromwhere = {UK, IL},
+%\end{verbatim}
+% This means the first author is from the United Kingdom and the
+% second one from Israel.
+%
+% \section{Macros for month names}
+%
+% \begin{macrocode}
+MACRO {jan} {"-01"}
+MACRO {feb} {"-02"}
+MACRO {mar} {"-03"}
+MACRO {apr} {"-04"}
+MACRO {may} {"-05"}
+MACRO {jun} {"-06"}
+MACRO {jul} {"-07"}
+MACRO {aug} {"-08"}
+MACRO {sep} {"-09"}
+MACRO {oct} {"-10"}
+MACRO {nov} {"-11"}
+MACRO {dec} {"-12"}
+% \end{macrocode}
+%
+% Some scratch variables and global variables.
+% \begin{macrocode}
+STRINGS { p s t l }
+% \end{macrocode}
+%
+% \begin{macrocode}
+INTEGERS { len ptr }
+%<bst>
+% \end{macrocode}
+%
+% \begin{footnotesize}\itshape
+% Note: \bibtex/ 0.99 requires a blank line in certain contexts, such
+% as after the \fn{READ} command, and will choke if it is missing.
+% When it is necessary to add a blank line at the boundary of a macro
+% code section we use a \verb'<bst>' marker.\par
+% \end{footnotesize}
+%
+% Some utility functions.
+% \begin{macrocode}
+FUNCTION {NOT} { { #0 } { #1 } if$ }
+
+FUNCTION {AND} { 'skip$ { pop$ #0 } if$ }
+
+FUNCTION {OR} { { pop$ #1 } 'skip$ if$ }
+
+FUNCTION {TRUE} { #1 }
+
+FUNCTION {FALSE} { #0 }
+%<bst>
+% \end{macrocode}
+%
+% \begin{macro}{incr.ptr}
+% \begin{macrocode}
+FUNCTION {incr.ptr} { ptr #1 + 'ptr := }
+%<bst>
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{current.char}
+% Returns: first character of STRING
+% \begin{macrocode}
+FUNCTION {current.char} { ptr #1 substring$ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{copy.two.chars}
+% The function \fn{copy.two.chars} appends the next two characters
+% from s to STRING.
+%
+% Arg: STRING (partial copy of pages string)
+%
+% Returns: Modified version of STRING
+%
+% Side effects: advances ptr
+% \begin{macrocode}
+FUNCTION {copy.two.chars} { t * incr.ptr s current.char * incr.ptr }
+%<bst>
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{is.digit}
+% \begin{macrocode}
+FUNCTION {is.digit} {
+ chr.to.int$
+ duplicate$
+ "0" chr.to.int$ #1 - >
+ swap$
+ "9" chr.to.int$ #1 + <
+ AND
+}
+%<bst>
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{is.lowercase.letter}
+% In a previous implementation the \fn{is.letter} function first
+% lowercased the character using \verb'change.case$', then tested it
+% against the range a--z. But \verb'change.case$' issues a warning if
+% it is applied to a lone brace character.
+% \begin{macrocode}
+FUNCTION {is.lowercase.letter} {
+ chr.to.int$ duplicate$
+ "a" chr.to.int$ #1 - >
+ swap$
+ "z" chr.to.int$ #1 + <
+ AND
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{is.uppercase.letter}
+% \begin{macrocode}
+FUNCTION {is.uppercase.letter} {
+ chr.to.int$ duplicate$
+ "A" chr.to.int$ #1 - >
+ swap$
+ "Z" chr.to.int$ #1 + <
+ AND
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{is.letter}
+% \begin{macrocode}
+FUNCTION {is.letter} {
+ duplicate$
+ is.lowercase.letter
+ { pop$ TRUE }
+ { is.uppercase.letter }
+ if$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{skip.accent}
+% This implementation of \fn{skip.accent} simply skips ahead one
+% character whenever a backslash is found. This handles things like
+% \verb'\v', \verb'\u', \verb'\k', \verb'\r'. Although this is overly
+% simplistic it is still an improvement over the previous method
+% which was to not even make the attempt. [mjd,2001-10-27]
+% \begin{macrocode}
+FUNCTION {skip.accent} { pop$ incr.ptr }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{strip.label}
+% \begin{macrocode}
+FUNCTION {strip.label} {
+ 's :=
+ #1 'ptr :=
+ ""
+ { s ptr #1 substring$ duplicate$ empty$ NOT }
+ { duplicate$ is.letter
+ { * }
+ { duplicate$ "\" =
+ { skip.accent }
+ 'pop$
+ if$
+ }
+ if$
+ incr.ptr
+ }
+ while$
+% \end{macrocode}
+% When the loop ends we have an extra empty-string on top of the
+% stack to get rid of.
+% \begin{macrocode}
+ pop$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{sortify}
+% \begin{macrocode}
+FUNCTION {sortify} {
+ purify$
+ "l" change.case$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{rpad}
+% Warning: The use of |text.length$| here and in \fn{lpad}
+% restricts their use to strings that we know do not contain any
+% special characters. Since we only use \fn{lpad} for field names
+% and \fn{rpad} for |purify$|ed strings, this is ok.
+%
+% \<string> \<int> \fn{rpad}
+% \begin{macrocode}
+FUNCTION {rpad} {
+ swap$
+ 'l :=
+ l text.length$ - 'len :=
+ { len #0 > }
+ {
+ l " " * 'l :=
+ len #1 - 'len :=
+ }
+ while$
+ l
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{lpad}
+% \<string> \<int> \fn{lpad}
+% \begin{macrocode}
+FUNCTION {lpad} {
+ swap$
+ 'l :=
+ l text.length$ - 'len :=
+ { len #0 > }
+ {
+ " " l * 'l :=
+ len #1 - 'len :=
+ }
+ while$
+ l
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{field.or.null}
+% \begin{macrocode}
+FUNCTION {field.or.null} {
+ duplicate$ empty$
+ { pop$ "" }
+ 'skip$
+ if$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{missing.or.empty}
+% \begin{macrocode}
+FUNCTION {missing.or.empty} { duplicate$ missing$ swap$ empty$ OR }
+%<bst>
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{append.ndash.and.skip.hyphens}
+% The function \fn{append.ndash.and.skip.hyphens} adds \verb'\ndash'
+% to STRING when a hyphen is found and advances ptr to the next
+% non-hyphen character in \fn{s}.
+%
+% Arg: STRING (partial copy of pages string)
+%
+% Returns: modified version of STRING
+%
+% Side effects: advances ptr
+% \begin{macrocode}
+FUNCTION {append.ndash.and.skip.hyphens} {
+ "\ndash " *
+ incr.ptr
+ { s current.char "-" = }
+ { incr.ptr }
+ while$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{n.dashify}
+% In the \fn{n.dashify} function we store the given string in \fn{s},
+% push an empty string on the stack, and start examining the
+% characters of \fn{s}. For a non-hyphen character, we just append a
+% copy of it to the top string. For a hyphen, we append \cs{ndash} to
+% the top string and advance the pointer until we reach a non-hyphen
+% character. And there is one more exceptional case: for a backslash,
+% we copy two characters instead of one. This keeps us from
+% erroneously translating \verb'\-' to \verb'\\ndash'. One would
+% scarcely expect to see an instance of \verb'\-' in a page number
+% field but let's face it, in actual use nearly anything can and does
+% happen.
+%
+% Arg: STRING (value of \fn{pages} field)
+%
+% Returns: STRING (dashified version of input string)
+% \begin{macrocode}
+FUNCTION {n.dashify} {
+ 's :=
+ #1 'ptr :=
+ ""
+ { s current.char 't := t "" = NOT }
+ { t "\" =
+ { copy.two.chars }
+ { t "-" =
+ { append.ndash.and.skip.hyphens }
+ { t * incr.ptr }
+ if$
+ }
+ if$
+ }
+ while$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{missing.warning}
+% Standard warning message for a missing or empty field. For the user
+% we call any such field `missing' without respect to the distinction
+% made by \bibtex/ between missing and empty.
+% \begin{macrocode}
+FUNCTION {missing.warning} {
+ "missing " swap$ * " in " * cite$ * warning$
+}
+%<bst>
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{string.length}
+% Because \bibtex/ doesn't provide a straightforward
+% \fn{string.length} function (\verb'text.length$' counts ``special
+% characters'' as a single character), it appears necessary to
+% implement one the hard way.
+% \begin{macrocode}
+INTEGERS { string.ptr }
+
+FUNCTION {string.length} {
+ #1 'string.ptr :=
+ { duplicate$ string.ptr #1 substring$ "" = 'FALSE 'TRUE if$ }
+ { string.ptr #1 + 'string.ptr := }
+ while$
+ pop$
+ string.ptr #1 -
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{format.title}
+% \begin{macrocode}
+FUNCTION {format.title}{
+ duplicate$
+ missing.or.empty
+ { pop$ "" }
+ { "t" change.case$ }
+ if$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{start.field}
+% \begin{macrocode}
+FUNCTION {start.field} {
+ #12 lpad "={" * write$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{fin.field}
+% \begin{macrocode}
+FUNCTION {fin.field} { "}," write$ newline$ }
+%<bst>
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{write.field}
+% \begin{macrocode}
+FUNCTION {write.field} {
+ duplicate$
+ missing$
+ { pop$ missing.warning }
+ { duplicate$ empty$
+ { pop$ missing.warning }
+ { swap$ start.field write$ fin.field }
+ if$
+ }
+ if$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{optional.field}
+% \begin{macrocode}
+FUNCTION {optional.field} {
+ duplicate$
+ missing.or.empty
+ { pop$ pop$ }
+ { swap$ start.field write$ fin.field }
+ if$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{optional.title.field}
+% \begin{macrocode}
+FUNCTION {optional.title.field} {
+ duplicate$
+ missing.or.empty
+ { pop$ pop$ }
+ { format.title swap$ start.field write$ fin.field }
+ if$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{optional.pages.field}
+% \begin{macrocode}
+FUNCTION {optional.pages.field} {
+ duplicate$
+ missing.or.empty
+ { pop$ pop$ }
+ { swap$ start.field
+ n.dashify
+ write$ fin.field
+ }
+ if$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{optional.mr.field}
+% \begin{macrocode}
+FUNCTION {optional.mr.field} {
+ duplicate$
+ missing.or.empty
+ { pop$ pop$ }
+ {
+ swap$ start.field
+ "\MR{" swap$ * "}" * write$ fin.field
+ }
+ if$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{remove.ordinal.suffix}
+% \begin{macrocode}
+FUNCTION {remove.ordinal.suffix} {
+ 's :=
+ s string.length 'len :=
+ #1 'ptr :=
+ { ptr len < s ptr #1 substring$ is.digit AND }
+ 'incr.ptr
+ while$
+ s ptr global.max$ substring$ 'p :=
+ p "st" =
+ { TRUE }
+ { p "nd" =
+ { TRUE }
+ { p "rd" =
+ { TRUE }
+ { p "th" =
+ { TRUE }
+ { FALSE }
+ if$
+ }
+ if$
+ }
+ if$
+ }
+ if$
+ { s #1 ptr #1 - substring$ }
+ { s }
+ if$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{optional.edition.field}
+% \begin{macrocode}
+FUNCTION {optional.edition.field} {
+ duplicate$ missing.or.empty
+ { pop$ pop$ }
+ { swap$ start.field
+ remove.ordinal.suffix
+ write$ fin.field
+ }
+ if$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Formatting author names and editor names}
+%
+% Take a name list in \bibtex/ form (names separated by the word
+% \qq{and}) and output the desired form of each name.
+% \begin{macrocode}
+INTEGERS { nameptr numnames namesleft }
+STRINGS { namelist fieldname }
+% \end{macrocode}
+%
+% \begin{macro}{format.name}
+% The \fn{format.name} function operates on a single name, producing
+% a string of the form
+% \begin{verbatim}
+% von Last, First, Jr.
+%\end{verbatim}
+%
+% Args: \vn{namelist}, \vn{index} (top; integer)
+%
+% Returns: formatted version of the $n$th name in \vn{namelist} where
+% integer \vn{index} specifies $n$.
+% \begin{macrocode}
+FUNCTION {format.name} { "{vv~}{ll}{, ff}{, jj}" format.name$ }
+%<bst>
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{optional.name.field}
+% The function \fn{optional.name.field} handles the task of splitting
+% a multiple-name field value into multiple fields with single
+% values.
+%
+% Args: \vn{fieldname}, \vn{namelist} (top)
+%
+% Side effects: writes a key/value pair to the output file for each
+% name in \vn{namelist}.
+% \begin{macrocode}
+FUNCTION {optional.name.field}{
+ duplicate$ missing.or.empty
+ { pop$ pop$ }
+ { swap$ 'fieldname :=
+ duplicate$ num.names$
+ 'namesleft :=
+ #1 'ptr :=
+ { namesleft #0 > }
+ { fieldname start.field
+% \end{macrocode}
+% Copy the name string before running \fn{format.name} on it.
+% \begin{macrocode}
+ duplicate$ ptr format.name write$
+ fin.field
+ ptr #1 + 'ptr :=
+ namesleft #1 - 'namesleft :=
+ }
+ while$
+% \end{macrocode}
+% At this point we have an extra copy of the name string on the
+% stack.
+% \begin{macrocode}
+ pop$
+ }
+ if$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Handling year, month, date}
+%
+% \begin{macro}{assemble.date.field}
+% In the output we produce a \fn{date} field instead of the year and
+% month fields normally used in \bibtex/ files. In the date field we
+% use ISO date notation (e.g., 1987-06-05) to facilitate switching
+% between full and abbreviated month names. The month and day parts
+% are frequently absent, making the date field equivalent to a year
+% field.
+% \begin{macrocode}
+FUNCTION {assemble.date.field}
+{ date missing$
+ { year missing.or.empty
+ { status missing.or.empty
+ { "No year or other date information for "
+ cite$ * warning$ }
+ 'skip$
+ if$
+ "status"
+ }
+ { year month missing$ { "" } { month } if$ * }
+ if$
+ }
+ { date }
+ if$
+% \end{macrocode}
+% If the date string is now equal to \qq{status}, it means that we
+% have a status field or we already gave a warning about lack of date
+% info; in either case omit the date field.
+% \begin{macrocode}
+ duplicate$ "status" =
+ { pop$ pop$ }
+ { swap$ start.field write$ fin.field }
+ if$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Journal abbreviations}
+%
+% Use of journal abbreviations is recommended to make supplying ISSN
+% numbers easier. To use this feature, you need a STRING definition
+% of the form
+% \begin{verbatim}
+% @STRING{cpam="cpam/0010-3640/"
+% #"Communications in Pure and Applied Mathematics"}
+%\end{verbatim}
+% Then when you write
+% \begin{verbatim}
+% journal=cpam,
+%\end{verbatim}
+% exporting with \fn{amsxport} will produce
+% \begin{verbatim}
+% journal={cpam},
+% ISSN={0010-3640},
+%\end{verbatim}
+% The text before the ISSN number in the STRING definition is
+% preferably a repetition of the abbreviation name (leaving expansion
+% to be done on the \latex/ side); or it could be the full journal
+% name.
+%
+% \textbf{Warning:} If you include braces and write
+% \verb'journal={cpam},' \bibtex/ will not expand the abbreviation
+% but leave it as the field value; and then you will not get
+% automatic lookup of the ISSN number.
+%
+% \begin{macro}{optional.journal.field}
+% \begin{macrocode}
+FUNCTION {optional.journal.field} {
+ duplicate$ missing.or.empty
+ { pop$ pop$ }
+ {
+ 's :=
+ start.field
+ #1 'ptr :=
+ s current.char is.lowercase.letter
+ {
+ s "/" * 's :=
+ { s ptr #1 substring$ "/" = NOT }
+ { incr.ptr }
+ while$
+% \end{macrocode}
+% Journal name started with a lowercase letter, but we couldn't find
+% no slash? All right, just let it go through as it is.
+% \begin{macrocode}
+ s ptr #1 + #1 substring$ empty$
+ { s #1 ptr #1 - substring$ }
+% \end{macrocode}
+% But if we did find a slash, then we probably have found us an ISSN
+% number that we can write out.
+% \begin{macrocode}
+ {
+ s #1 ptr #1 - substring$
+ write$
+ fin.field
+% \end{macrocode}
+% ISSNs are always nine characters in length (four digits, hyphen,
+% four digits).
+% \begin{macrocode}
+ "ISSN" start.field
+ s ptr #1 + #9 substring$
+ }
+ if$
+ }
+ { s }
+ if$
+ write$
+ fin.field
+ }
+ if$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Type info}
+%
+% \begin{macro}{optional.type.field}
+% Putz around with the type info a little, for theses mainly. Two
+% types here: the type field, and the entry type.
+% \begin{macrocode}
+FUNCTION {optional.type.field}
+{ duplicate$ missing.or.empty
+ { type$ "mastersthesis" = { "Master's Thesis" }
+ { type$ "phdthesis" = { "Ph.D. Thesis" }
+ { "" } if$ } if$
+ swap$ pop$
+ }
+ 'skip$
+ if$
+ duplicate$ empty$
+ { pop$ pop$ }
+ { swap$ start.field write$ fin.field }
+ if$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Miscellaneous tail-end information}
+%
+% \begin{macro}{url.note.status.review}
+% The following items are common to all entry types are output at
+% the tail end of the entry.
+% \begin{macrocode}
+FUNCTION {url.note.status.review} {
+ "url" url optional.field
+ "note" note optional.field
+ "status" status optional.field
+% \end{macrocode}
+% The \fn{review} field should perhaps be translated into multiple
+% fields like author names, if more than one review is given.
+% \begin{macrocode}
+ "review" review optional.field
+% \end{macrocode}
+% Data from MathSciNet will have the Math Reviews number in an
+% mrnumber field. We assume that a given entry will have a review
+% field or an mrnumber field but not both.
+% \begin{macrocode}
+ "review" mrnumber optional.mr.field
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Wrapper for each entry}
+%
+% \begin{macro}{start.entry}
+% \begin{macrocode}
+FUNCTION {start.entry} {
+ newline$
+ "\bib{" cite$ * "}{" *
+% \end{macrocode}
+% Merge Master's thesis and Ph.D. thesis into a single type.
+% \begin{macrocode}
+ type$ "mastersthesis" = type$ "phdthesis" = OR
+ { "thesis" }
+ { type$ }
+ if$
+ * "}{" * write$
+ newline$
+%<*debug>
+ "sort.label" label sortify optional.field
+ "sort.key" sort.key$ optional.field
+%</debug>
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{fin.entry}
+% \begin{macrocode}
+FUNCTION {fin.entry} {
+ "}" write$
+ newline$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Entry types}
+%
+% Here are the types of entries that are normally allowed in a
+% \bibtex/ file:
+% \begin{description}
+%
+% \item[book] A book with an explicit publisher.
+%
+% \item[booklet] A work that is printed and bound, but without a named
+% publisher or sponsoring institution.
+%
+% \item[inbook] A part of a book, which may be a chapter (or section or
+% whatever) and/or a range of pages.
+%
+% \item[incollection] A part of a book having its own title.
+%
+% \item[manual] Technical documentation.
+%
+% \item[mastersthesis] A Master's thesis.
+%
+% \item[phdthesis] A PhD thesis.
+%
+% \item[proceedings] The proceedings of a conference.
+%
+% \item[techreport] A report published by a school or other institution,
+% usually numbered within a series.
+%
+% \item[article] An article from a journal or magazine.
+%
+% \item[inproceedings] An article in a conference proceedings.
+%
+% \item[conference] An alias for \fn{inproceedings}.
+%
+% \item[unpublished] A document having an author and title, but not
+% formally published.
+%
+% \item[misc] Use this type when nothing else fits.
+%
+% \end{description}
+%
+% \begin{macro}{article}
+% A journal article differs from an inproceedings article by not
+% having booktitle, publisher, editor, and other such info.
+% \begin{macrocode}
+FUNCTION {article} {
+ start.entry
+ "author" author optional.name.field
+ "translator" translator optional.name.field
+ "title" title format.title write.field
+ "subtitle" subtitle optional.title.field
+ "language" language optional.field
+ "organization" organization optional.field
+ "how" howpublished optional.field
+% \end{macrocode}
+% Construct a date value from date, year, month fields
+% \begin{macrocode}
+ "date" assemble.date.field
+ "ISSN" issn optional.field
+ "journal" journal optional.journal.field
+ "volume" volume optional.field
+ "number" number optional.field
+ "pages" pages optional.pages.field
+ "PII" pii optional.field
+ "archive" archive optional.field
+ "eprint" eprint optional.field
+ "preprint" preprint optional.field
+ url.note.status.review
+ fin.entry
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{inproceedings}
+% An inproceedings entry may have xid, booktitle, meeting, publisher
+% info; it is not expected to have journal, eprint, or preprint info.
+% \begin{macrocode}
+FUNCTION {inproceedings} {
+ start.entry
+ "author" author optional.name.field
+ "translator" translator optional.name.field
+ "title" title format.title write.field
+ "subtitle" subtitle optional.title.field
+ "language" language optional.field
+ "organization" organization optional.field
+ "how" howpublished optional.field
+% \end{macrocode}
+% Construct a date value from date, year, month fields
+% \begin{macrocode}
+ "date" assemble.date.field
+ "xid" xid optional.field
+% \end{macrocode}
+% The following fields might be inherited from the parent of an
+% article in a proceedings volume or collection.
+% \begin{macrocode}
+ "conference" meeting optional.field
+ "booktitle" booktitle optional.title.field
+% \end{macrocode}
+% Include the edition in case this is an inbook entry.
+% \begin{macrocode}
+ "edition" edition optional.edition.field
+ "editor" editor optional.name.field
+ "series" series optional.field
+ "volume" volume optional.field
+ "publisher" publisher optional.field
+ "address" address optional.field
+ "pages" pages optional.pages.field
+ url.note.status.review
+ fin.entry
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{inbook}
+% \begin{macrocode}
+FUNCTION {inbook} { inproceedings }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{incollection}
+% \begin{macrocode}
+FUNCTION {incollection} { inproceedings }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{inproceedings}
+% \begin{macrocode}
+FUNCTION {conference} { inproceedings }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{book}
+% The book type includes a meeting field because otherwise we'd have
+% to repeat the entire definition for the proceedings type with that
+% as the sole difference.
+% \begin{macrocode}
+FUNCTION {book} {
+ start.entry
+ "author" author optional.name.field
+ "editor" editor optional.name.field
+ "translator" translator optional.name.field
+ "title" title missing$ { booktitle } { title } if$
+ format.title write.field
+ "subtitle" subtitle optional.title.field
+ "type" type optional.type.field
+ "language" language optional.field
+ "conference" meeting optional.field
+ "edition" edition optional.edition.field
+ "series" series optional.field
+ "publisher" publisher optional.field
+ organization missing.or.empty
+ { "institution" institution optional.field }
+ { "organization" organization optional.field }
+ if$
+ "address" address optional.field
+ "how" howpublished optional.field
+ "date" year write.field
+ "volume" volume optional.field
+% \end{macrocode}
+% The number here is intended for a tech report.
+% \begin{macrocode}
+ "number" number optional.field
+ "ISBN" isbn optional.field
+ url.note.status.review
+ fin.entry
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{booklet}
+% \begin{macrocode}{booklet}
+FUNCTION {booklet} { book }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{manual}
+% \begin{macrocode}
+FUNCTION {manual} { book }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{mastersthesis}
+% \begin{macrocode}
+FUNCTION {mastersthesis} { book }
+
+FUNCTION {phdthesis} { book }
+
+FUNCTION {proceedings} { book }
+
+FUNCTION {collection} { book }
+
+FUNCTION {techreport} { book }
+
+FUNCTION {unpublished} { book }
+
+FUNCTION {misc} { book }
+
+FUNCTION {default.type} { misc }
+%<bst>
+% \end{macrocode}
+% \end{macro}
+%
+% \bibtex/ 0.99 keels over if READ does not have a blank line after
+% it.
+% \begin{macrocode}
+%<bst>
+READ
+%<bst>
+% \end{macrocode}
+%
+% \section{Sorting the entries}
+%
+% Since the final labels will be produced by the \pkg{amsrefs}
+% package, we don't need to worry about generating suffixes to
+% disambiguate between equal stems. All we have to do is strive to
+% generate stems that are identical to the ones that \pkg{amsrefs}
+% will generate, so that \bst{amsxport} will sort its output in a
+% fashion that will be consistent with the labels.
+%
+% Overall, this simplifies our job, since we don't have to keep
+% track of duplicate labels, so we can process each entry in
+% isolation. However, we do have to be more careful about the
+% handling of text accents and text symbols in order to maintain
+% compatibility with \pkg{amsrefs}.
+%
+% See (\emph{inter alia}) the sections ``Lexical structure of
+% names'' and ``Generating alphabetic lables'' in the
+% \pkg{amsrefs} implementation documentation for more information.
+%
+% \begin{macrocode}
+%<*sort>
+% \end{macrocode}
+%
+% \begin{macro}{chop.word}
+% \begin{macrocode}
+FUNCTION {chop.word} {
+ 's :=
+ 'len :=
+ s #1 len substring$ =
+ { s len #1 + global.max$ substring$ }
+ 's
+ if$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{sort.format.title}
+% \begin{macrocode}
+FUNCTION {sort.format.title} {
+ 't :=
+ "A " #2
+ "An " #3
+ "The " #4 t chop.word
+ chop.word
+ chop.word
+ sortify
+ #1 global.max$ substring$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{format.lab.names}
+% \begin{macrocode}
+%<*alpha|short>
+FUNCTION {format.lab.names} {
+ 's :=
+ s num.names$ 'numnames :=
+ numnames #1 >
+ { numnames #4 >
+ { #3 'namesleft := }
+ { numnames 'namesleft := }
+ if$
+ #1 'nameptr :=
+ ""
+ { namesleft #0 > }
+ { nameptr numnames =
+ { s nameptr "{ff }{vv }{ll}{ jj}" format.name$ "others" =
+ { "{\etalchar{+}}" * }
+ { s nameptr "{v{}}{l{}}" format.name$ * }
+ if$
+ }
+ { s nameptr "{v{}}{l{}}" format.name$ * }
+ if$
+ nameptr #1 + 'nameptr :=
+ namesleft #1 - 'namesleft :=
+ }
+ while$
+ numnames #4 >
+ { "{\etalchar{+}}" * }
+ 'skip$
+ if$
+ }
+ { s #1 "{v{}}{l{}}" format.name$
+ duplicate$ text.length$ #2 <
+%<alpha> { pop$ s #1 "{ll}" format.name$ #3 text.prefix$ }
+%<short> { pop$ s #1 "{ll}" format.name$ #1 text.prefix$ }
+ 'skip$
+ if$
+ }
+ if$
+}
+
+FUNCTION {author.key.label}
+{ author empty$
+ { key empty$
+ { cite$ #1 #3 substring$ }
+ { key #3 text.prefix$ }
+ if$
+ }
+ { author format.lab.names }
+ if$
+}
+
+FUNCTION {author.editor.key.label}
+{ author empty$
+ { editor empty$
+ { key empty$
+ { cite$ #1 #3 substring$ }
+ { key #3 text.prefix$ }
+ if$
+ }
+ { editor format.lab.names }
+ if$
+ }
+ { author format.lab.names }
+ if$
+}
+
+FUNCTION {author.key.organization.label}
+{ author empty$
+ { key empty$
+ { organization empty$
+ { cite$ #1 #3 substring$ }
+ { "The " #4 organization chop.word #3 text.prefix$ }
+ if$
+ }
+ { key #3 text.prefix$ }
+ if$
+ }
+ { author format.lab.names }
+ if$
+}
+
+FUNCTION {editor.key.organization.label}
+{ editor empty$
+ { key empty$
+ { organization empty$
+ { cite$ #1 #3 substring$ }
+ { "The " #4 organization chop.word #3 text.prefix$ }
+ if$
+ }
+ { key #3 text.prefix$ }
+ if$
+ }
+ { editor format.lab.names }
+ if$
+}
+
+FUNCTION {calc.label}{
+ type$ "book" = type$ "inbook" = OR
+ 'author.editor.key.label
+ { type$ "proceedings" =
+ 'editor.key.organization.label
+ { type$ "manual" =
+ 'author.key.organization.label
+ 'author.key.label
+ if$
+ }
+ if$
+ }
+ if$
+ strip.label
+ sortify
+%<*alpha>
+ year field.or.null
+%<!y2k> #3 #8 substring$
+ purify$ *
+%</alpha>
+ 'label :=
+}
+%</alpha|short>
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{sort.format.names}
+% \begin{macrocode}
+FUNCTION {sort.format.names} {
+ 's :=
+ #1 'ptr :=
+ ""
+ s num.names$ 'numnames :=
+ numnames 'namesleft :=
+ { namesleft #0 > }
+ { ptr #1 >
+ { " " * }
+ 'skip$
+ if$
+ s ptr "{ll}{ ff}{ jj}" format.name$ 't :=
+ ptr numnames = t "others" = AND
+ { "et al" }
+ { t sortify }
+ if$
+ #20 rpad *
+ ptr #1 + 'ptr :=
+ namesleft #1 - 'namesleft :=
+ }
+ while$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{sort.warning}
+% \begin{macrocode}
+FUNCTION {sort.warning} {
+ "to sort, need " swap$ * " or key in " * cite$ * warning$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{author.sort}
+% \begin{macrocode}
+FUNCTION {author.sort}
+{ author empty$
+ { key empty$
+ { "author" sort.warning
+ ""
+ }
+ { key sortify }
+ if$
+ }
+ { author sort.format.names }
+ if$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{author.editor.sort}
+% \begin{macrocode}
+FUNCTION {author.editor.sort}
+{ author empty$
+ { editor empty$
+ { key empty$
+ { "author, editor," sort.warning
+ ""
+ }
+ { key sortify }
+ if$
+ }
+ { editor sort.format.names }
+ if$
+ }
+ { author sort.format.names }
+ if$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{author.organization.sort}
+% \begin{macrocode}
+FUNCTION {author.organization.sort}
+{ author empty$
+ { organization empty$
+ { key empty$
+ { "author, organization," sort.warning
+ ""
+ }
+ { key sortify }
+ if$
+ }
+ { "The " #4 organization chop.word sortify }
+ if$
+ }
+ { author sort.format.names }
+ if$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{editor.organization.sort}
+% \begin{macrocode}
+FUNCTION {editor.organization.sort}
+{ editor empty$
+ { organization empty$
+ { key empty$
+ { "editor, organization," sort.warning
+ ""
+ }
+ { key sortify }
+ if$
+ }
+ { "The " #4 organization chop.word sortify }
+ if$
+ }
+ { editor sort.format.names }
+ if$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{presort}
+% \begin{macrocode}
+FUNCTION {presort} {
+%<*alpha|short>
+ calc.label
+ label #20 rpad
+%</alpha|short>
+ type$ "book" = type$ "inbook" = OR type$ "collection" = OR
+ 'author.editor.sort
+ { type$ "proceedings" =
+ 'editor.organization.sort
+ { type$ "manual" =
+ 'author.organization.sort
+ 'author.sort
+ if$
+ }
+ if$
+ }
+ if$
+%<alpha|short> * " " *
+%<!alpha|short> year field.or.null sortify #12 rpad * " " *
+ title field.or.null sort.format.title *
+ #1 entry.max$ substring$
+ 'sort.key$ :=
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+ITERATE {presort}
+
+SORT
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</sort>
+% \end{macrocode}
+%
+% \section{Final pass for output}
+%
+% \begin{macro}{write.with.newlines}
+% The \fn{write.with.newlines} functions stores a string in \fn{s}
+% and runs through it looking for occurrences of \verb'^^M'; when one
+% is found, the substring before it is written out with a newline,
+% the remainder is left in \fn{s}, and the cycle begins again.
+% \begin{macrocode}
+FUNCTION {write.with.newlines}
+{ 's := #1 'ptr :=
+ { s ptr #2 + #1 substring$ "" = NOT }
+ { s ptr #3 substring$ "^^M" =
+ { s #1 ptr #1 - substring$ write$ newline$
+ ptr #3 + 'ptr :=
+ s ptr global.max$ substring$ 's :=
+ #1 'ptr :=
+ }
+ { incr.ptr }
+ if$
+ }
+ while$
+ s write$ newline$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{begin.bin}
+% \begin{macrocode}
+FUNCTION {begin.bib} {
+ preamble$ empty$
+ 'skip$
+ { preamble$ write.with.newlines }
+ if$
+ "% \bib, bibdiv, biblist are defined by the amsrefs package."
+ write$ newline$
+ "\begin{bibdiv}" write$ newline$
+ "\begin{biblist}" write$ newline$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{end.bin}
+% \begin{macrocode}
+FUNCTION {end.bib} {
+ newline$
+ "\end{biblist}" write$ newline$
+ "\end{bibdiv}" write$ newline$
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+EXECUTE {begin.bib}
+
+ITERATE {call.type$}
+
+EXECUTE {end.bib}
+%</bst>
+% \end{macrocode}
+%
+% \section{Journal abbreviations}
+%
+% By putting the ISSN into the \latex/ document, we make it easier to
+% construct www queries from the bibliography data. These string
+% definitions tie together journal abbreviations, ISSN numbers, and
+% journal names.
+%
+% These are the journals that are cited most frequently by American
+% Mathematical Society authors at the present time (2000 CE).
+%
+% The format used here is designed to make it easy for BibTeX
+% to retrieve an ISSN number when given a journal abbreviation.
+% \begin{macrocode}
+%<*abbrevs>
+@string{aa="aa/0065-1036/"
+ #"Acta Arithmetica"}
+@string{actamath="actamath/0001-5962/"
+ #"Acta Mathematica"}
+@string{asms="asms/0001-6969/"
+ #"Acta Scientiarum Mathematicarum"}
+@string{advmath="advmath/0001-8708/"
+ #"Advances in Mathematics"}
+@string{ajm="ajm/0002-9327/"
+ #"American Journal of Mathematics"}
+@string{amm="amm/0002-9890/"
+ #"American Mathematical Monthly"}
+@string{aifg="aifg/0373-0956/"
+ #"Annales de l'Institut Fourier"}
+@string{am2="am2/0003-486X/Annals of Mathematics"}
+@string{ap="ap/0091-1798/"
+ #"The Annals of Probability"}
+@string{asens4="asens4/0012-9593/"
+ #"Annales Scientifiques de l'\'{E}cole Normale Sup\'{e}rieure"}
+@string{amb="amb/0003-889X/Archiv der Mathematik"}
+@string{arma="arma/0003-9527/"
+ #"Archive for Rational Mechanics and Analysis"}
+@string{bamsn="bamsn/0273-0979/"
+ #"Bulletin (New Series) of the American Mathematical Society"}
+@string{bams="bams/0004-9727/"
+ #"Bulletin of the Australian Mathematical Society"}
+@string{blms="blms/0024-6093/"
+ #"Bulletin of the London Mathematical Society"}
+@string{bsmf="bsmf/0037-9484/"
+ #"Bulletin de la Soci\'{e}t\'{e} Math\'{e}matique de France"}
+@string{craspi="craspi/0764-4442/"
+ #"Comptes Rendus de l'Acad\'{e}mie des Sciences (Paris)"
+ #" S\'{e}rie I Math\'{e}matique"}
+@string{cjm="cjm/0008-414X/Canadian Journal of Mathematics"}
+@string{cmb="cmb/0008-4395/"
+ #"Canadian Mathematical Bulletin"}
+@string{colloqmath="colloqmath/0010-1354/"
+ #"Colloquium Mathematicum"}
+@string{commalgebra="commalgebra/0092-7872/"
+ #"Communications in Algebra"}
+@string{cmp="cmp/0010-3616/"
+ #"Communications in Mathematical Physics"}
+@string{cpam="cpam/0010-3640/"
+ #"Communications on Pure and Applied Mathematics"}
+@string{cmh="cmh/0010-2571/"
+ #"Commentarii Mathematici Helvetici"}
+@string{cvta="cvta/0278-1077/"
+ #"Complex Variables"}
+@string{compositiomath="compositiomath/0010-437X/"
+ #"Compositio Mathematica"}
+@string{c="c/0010-485X/Computing"}
+@string{constrapprox="constrapprox/0176-4276/"
+ #"Constructive Approximation"}
+@string{dmj="dmj/0012-7094/"
+ #"Duke Mathematical Journal"}
+@string{eraams="eraams/1079-6762/"
+ #"Electronic Research Announcements"
+ #" of the American Mathematical Society"}
+@string{etds="etds/0143-3857/"
+ #"Ergodic Theory and Dynamical Systems"}
+@string{fm="fm/0016-2736/"
+ #"Fundamenta Mathematicae"}
+@string{gd="gd/0046-5755/"
+ #"Geometriae Dedicata"}
+@string{illinoisjmath="illinoisjmath/0019-2082/"
+ #"Illinois Journal of Mathematics"}
+@string{iumj="iumj/0022-2518/"
+ #"Indiana University Mathematics"}
+@string{im="im/0020-9910/"
+ #"Inventiones Mathematicae"}
+@string{israeljmath="israeljmath/0021-2172/"
+ #"Israel Journal of Mathematics"}
+@string{iansm="iansm/??/"
+ #"Izvestiya Akademii Nauk SSSR. Seriya Matematicheskaya"}
+@string{ja="ja/0021-8693/"
+ #"Journal of Algebra"}
+@string{jams="jams/0894-0347/"
+ #"Journal of the American Mathematical Society"}
+@string{jam="jam/0021-7670/"
+ #"Journal d'Analyse Math\'{e}matique"}
+@string{jamm="jamm/0021-8928/"
+ #"Journal of Applied Mathematics and Mechanics"}
+@string{jat="jat/0021-9045/"
+ #"Journal of Approximation Theory"}
+@string{jamsa="jamsa/0263-6115/"
+ #"Journal of the Australian Mathematical Society"}
+@string{jcta="jcta/0097-3165/"
+ #"Journal of Combinatorial Theory"}
+@string{jde="jde/0022-0396/"
+ #"Journal of Differential Equations"}
+@string{jdg="jdg/0022-040X/Journal of Differential Geometry"}
+@string{jfa="jfa/0022-1236/"
+ #"Journal of Functional Analysis"}
+@string{jlms2="jlms2/0024-6107/"
+ #"Journal of the London Mathematical Society"}
+@string{jmaa="jmaa/0022-247X/"
+ #"Journal of Mathematical Analysis and Applications"}
+@string{jmp="jmp/0022-2488/"
+ #"Journal of Mathematical Physics"}
+@string{jmsj="jmsj/0025-5645/"
+ #"Journal of the Mathematical Society of Japan"}
+@string{jnt="jnt/0022-314X/Journal of Number Theory"}
+@string{jot="jot/0379-4024/"
+ #"Journal of Operator Theory"}
+@string{jpaa="jpaa/0022-4049/"
+ #"Journal of Pure and Applied Algebra"}
+% Braces instead of quotes, to hide the embedded \" control sequence
+@string{jram={jram/0075-4102/}
+ #{Journal f\"{u}r die Reine und Angewandte Mathematik}}
+@string{jsl="jsl/0022-4812/"
+ #"The Journal of Symbolic Logic"}
+@string{laa="laa/0024-3795/"
+ #"Linear Algebra and its Applications"}
+@string{mm="mm/0025-2611/"
+ #"Manuscripta Mathematica"}
+@string{matzametki="matzametki/0025-567X/Matematicheskie Zametki"}
+@string{ma="ma/0025-5831/"
+ #"Mathematische Annalen"}
+@string{mc="mc/0025-5718/"
+ #"Mathematics of Computation"}
+@string{mj="mj/0025-5513/"
+ #"Mathematica Japonica"}
+@string{mn="mn/0025-584X/Mathematische Nachrichten"}
+@string{mpcps="mpcps/0305-0041/"
+ #"Mathematical Proceedings of the"
+ #" Cambridge Philosophical Society"}
+@string{mrl="mrl/1073-2780/"
+ #"Mathematical Research Letters"}
+@string{ms="ms/0025-5521/"
+ #"Mathematica Scandinavica"}
+@string{mathz="mathz/0025-5874/"
+ #"Mathematische Zeitschrift"}
+@string{m="m/0025-5793/"
+ #"Mathematika"}
+@string{mmj="mmj/0026-2285/"
+ #"The Michigan Mathematical Journal"}
+@string{nmj="nmj/0027-7630/"
+ #"Nagoya Mathematical Journal"}
+@string{na="na/0362-546X/Nonlinear Analysis"}
+@string{nm="nm/0029-599X/Numerische Mathematik"}
+@string{ojm="ojm/0030-6126/"
+ #"Osaka Journal of Mathematics"}
+@string{pjm="pjm/0030-8730/"
+ #"Pacific Journal of Mathematics"}
+@string{pams="pams/0002-9939/"
+ #"Proceedings of the American Mathematical Society"}
+@string{pems2="pems2/0013-0915/"
+ #"Proceedings of the Edinburgh Mathematical Society"}
+@string{pjaa="pjaa/0386-2194/"
+ #"Proceedings of the Japan Academy"}
+@string{plms3="plms3/0024-6115/"
+ #"Proceedings of the London Mathematical Society"}
+@string{qjmo2="qjmo2/0033-5606/"
+ #"The Quarterly Journal of Mathematics"}
+@string{rmi="rmi/0213-2230/"
+ #"Revista Matem\'{a}tica Iberoamericana"}
+@string{rmjm="rmjm/0035-7596/"
+ #"Rocky Mountain Journal of Mathematics"}
+@string{sjam="sjam/0036-1399/"
+ #"SIAM Journal on Applied Mathematics"}
+@string{sjc="sjc/0097-5397/"
+ #"SIAM Journal on Computing"}
+@string{sjma="sjma/0036-1410/"
+ #"SIAM Journal on Mathematical Analysis"}
+@string{sjna="sjna/0036-1429/"
+ #"SIAM Journal on Numerical Analysis"}
+@string{sr="sr/0036-1445/"
+ #"SIAM Review"}
+@string{sm="sm/0039-3223/"
+ #"Studia Mathematica"}
+@string{tjm="tjm/0387-3870/"
+ #"Tokyo Journal of Mathematics"}
+@string{ta="ta/0166-8641/"
+ #"Topology and its Applications"}
+@string{t="t/0040-9383/"
+ #"Topology"}
+@string{tams="tams/0002-9947/"
+ #"Transactions of the American Mathematical Society"}
+%</abbrevs>
+% \end{macrocode}
+%
+% \section{To Do}
+%
+% ---When there is no author or editor info to create a label from: Use
+% the initial letters of all the words in the title. Plus the year.
+% Maybe year first.
+%
+% ---Add linelength and indent options to control the output?
+%
+% ---Discuss apacite "originalfoo" fields etc.
+%
+% ---Discuss Beebe's work.
+%
+% ---Add bibliography.
+%
+% ---Add AUDIO, VIDEO entry types.
+%
+% ---Add a field for MR subject classification numbers and the like?
+%
+% ---Write a converter to convert from typical .bib data to preferred
+% form. Have to go via perl or something to capture STRING defs and
+% PREAMBLE and interspersed comments? Or emacs lisp? Provide .bst
+% version as fallback.
+%
+% ---Alpha labels: add numbers after sorting? subscript option? L3Y2a
+% option.
+%
+% ---Test multi-author articles with ten-plus authors. What happens
+% with the alpha labels then?
+%
+% ---For url field especially, check length and prebreak by hand instead
+% of relying on \bibtex/'s slapdash stick-in-a-percent-at-column-72
+% regardless of where it happens to fall.
+%
+% ---How about a general `contributor' field.
+%
+% ---Test with a wimpy older version of \bibtex/.
+%
+% \CheckSum{24}
+% \Finale
diff --git a/Master/texmf-dist/source/latex/amslatex/amsxtra.dtx b/Master/texmf-dist/source/latex/amslatex/amsxtra.dtx
new file mode 100644
index 00000000000..b0f19da7d07
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/amsxtra.dtx
@@ -0,0 +1,136 @@
+%%% ====================================================================
+%%% @LaTeX-file{
+%%% filename = "amsxtra.dtx",
+%%% version = "1.2c",
+%%% date = "1999/11/15",
+%%% time = "14:15:41 EST",
+%%% author = "American Mathematical Society",
+%%% copyright = "Copyright 1995, 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.",
+%%% 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 = "41382 136 533 5124",
+%%% email = "tech-support@ams.org (Internet)",
+%%% codetable = "ISO/ASCII",
+%%% keywords = "latex, accentedsymbol, fracwithdelims, sphat",
+%%% supported = "yes",
+%%% abstract = "This package contains some seldom-used commands
+%%% ported from AMS-TeX in 1989.",
+%%% 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
+%<*driver>
+\documentclass{amsdtx}
+\begin{document}
+\title{The \pkg{amsxtra} package}
+\author{American Mathematical Society\\Michael Downes}
+\date{Version \fileversion, \filedate}
+\hDocInput{amsxtra.dtx}
+\end{document}
+%</driver>
+%\fi
+%
+% \maketitle
+%
+% \MakeShortVerb\|
+%
+% \section{Introduction}
+% The \pkg{amsxtra} package contains a few rarely used commands that
+% were present in version 1.1 of the \pkg{amstex} package:
+% \cn{fracwithdelims}, {accentedsymbol}, \cn{sphat}, \cn{spcheck},
+% \cn{sptilde}, \cn{spdot}, \cn{spddot}, \cn{spdddot}, \cn{spbreve}.
+% If any of these commands were used in existing documents, the
+% \pkg{amsxtra} package provides a way to get them. But for 99\% of
+% documents using the \pkg{amstex} package these commands are just
+% wasted overhead.
+%
+% \StopEventually{}
+%
+% \begin{macrocode}
+\ProvidesPackage{amsxtra}[1999/11/15 v1.2c]
+% \end{macrocode}
+% We need to ensure that either the \pkg{amstex} package or the
+% \pkg{amsmath} package is loaded. This means we need something a
+% little more complicated than \cn{RequirePackage}.
+% \begin{macrocode}
+\@ifpackageloaded{amstex}{}{%
+ \RequirePackage{amsmath}[1996/10/01 v1.2]}
+% \end{macrocode}
+%
+% Superscripted accent characters.
+% \begin{macrocode}
+\def\sphat{^{\mathchoice{}{}%
+ {\,\,\smash[b]{\hbox{\lower4\ex@\hbox{$\m@th\widehat{\null}$}}}}%
+ {\,\smash[b]{\hbox{\lower3\ex@\hbox{$\m@th\hat{\null}$}}}}}}
+\def\spcheck{^\vee}
+\def\sptilde{^\sim}
+\def\spdot{^{\hbox{\raise\ex@\hbox{\normalfont .}}}}
+\def\spddot{^{\hbox{\raise\ex@\hbox{\normalfont ..}}}}
+\def\spdddot{^{\hbox{\raise\ex@\hbox{\normalfont...}}}}
+\def\spbreve{^{\!\smash[b]{\hbox{\lower4\ex@\hbox{\u{}}}}}}
+% \end{macrocode}
+%
+% The \cn{fracwithdelims} command is skipped if the base package is
+% \pkg{amsmath}; it is only needed if the base package is
+% \pkg{amstex}.
+% \begin{macrocode}
+\@ifpackageloaded{amstex}{%
+\def\fracwithdelims#1#2{\new@ifnextchar[{\fracwithdelims@#1#2}%
+ {\fracwithdelims@#1#2[\@empty]}}
+\def\fracwithdelims@#1#2[#3]#4#5{\relax
+ \ifx\@empty#3{#4\overwithdelims#1#2#5}\else
+ {#4\abovewithdelims#1#2#3\relax#5}\fi}
+}{}
+% \end{macrocode}
+%
+% Perhaps |\accentedsymbol| should use |\newsavebox|, but I don't
+% know of any compelling reason at the moment.[mjd,5-Sep-1994]
+% |\accentedsymbol| can only produce a single size of
+% the given symbol, so you'd need two different versions for main
+% size and subscript size.
+% \begin{macrocode}
+\def\accentedsymbol#1#2{%
+ \expandafter\newbox
+ \csname\expandafter\@gobble\string#1@box\endcsname
+ \expandafter\setbox
+ \csname\expandafter\@gobble\string#1@box\endcsname
+ \hbox{$\m@th#2$}%
+ \newcommand{#1}{%
+ \expandafter\copy
+ \csname\expandafter\@gobble\string#1@box\endcsname{}}%
+}
+% \end{macrocode}
+%
+% Change the definition of \qc{\~} to automatically remove a
+% preceding space as well as a following space, if present.
+% \begin{macrocode}
+\def~{\nobreakspace}
+\DeclareRobustCommand{\nobreakspace}{\unskip\nobreak\ \ignorespaces}
+% \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}
+%
+% \CheckSum{113}
+% \Finale
diff --git a/Master/texmf-dist/source/latex/amslatex/ifoption.dtx b/Master/texmf-dist/source/latex/amslatex/ifoption.dtx
new file mode 100644
index 00000000000..4bb4670a72a
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/ifoption.dtx
@@ -0,0 +1,170 @@
+%%% ====================================================================
+%%% @LaTeX-doc-source-file{
+%%% filename = "ifoption.dtx",
+%%% version = "1.02",
+%%% date = "2002/03/04",
+%%% time = "16:33:16 EST",
+%%% author = "Michael J Downes",
+%%% address = "American Mathematical Society,
+%%% Publications Technical Group,
+%%% PO Box 6248,
+%%% Providence, RI 02940,
+%%% USA",
+%%% email = "tech-support@ams.org",
+%%% URL = "http://www.ams.org/",
+%%% abstract = "",
+%%% checksum = "06695 170 563 5432",
+%%% docstring = "The checksum field, produced by Robert Solovay's
+%%% checksum utility, gives CRC-16 checksum, lines,
+%%% words, and characters.",
+%%% }
+%%% ====================================================================
+% \iffalse
+%<*driver>
+\NeedsTeXFormat{LaTeX2e}
+\documentclass{amsdtx}
+\providecommand{\mdash}{\textemdash}
+\newcommand{\xt}[1]{\texttt{#1}}
+\providecommand{\qq}[1]{``#1''}
+\providecommand{\lat}[1]{\protect\LaTeX{}}
+\begin{document}
+\title{The \pkg{ifoption} package}
+\author{Michael~J. Downes\\American Mathematical Society}
+\date{Version \fileversion, \filedate}
+\hDocInput{ifoption.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \maketitle
+% \section{Introduction}
+%
+% The \pkg{ifoption} package provides an \cn{IfOption} command that
+% has certain advantages over the \cs{@ifpackagewith} command\mdash
+% e.g., default options specified with \cs{ExecuteOptions} test as
+% true rather than false. In order for this to work properly,
+% mutually exclusive options should be specified with
+% \cs{DeclareExclusiveOptions}, another command defined by the
+% \pkg{ifoption} package.
+% \StopEventually{}
+%
+% \section{Implementation}
+% \subsection{Package info}
+%
+% Standard declaration of package name and date.
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{ifoption}[2002/03/04 v1.02]
+% \end{macrocode}
+%
+% \subsection{Some utility functions}
+%
+% \begin{macrocode}
+\let\@xp\expandafter \let\@nx\noexpand
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\@True{00}
+\def\@False{01}
+% \end{macrocode}
+%
+% \subsection{Background}
+% See the definitions of \cs{@onefilewithoptions} and
+% \cs{@pushfilename} in the \lat/ kernel.
+%
+% When we have
+%\begin{verbatim}
+%\DeclareOption{foo}{some code}
+%\end{verbatim}
+% in a file named \fn{bar.sty}, \lat/ defines \cs{ds@foo} to contain
+% \emph{some code}. Then if the package is invoked with
+%\begin{verbatim}
+%\usepackage[foo]{bar}
+%\end{verbatim}
+% there are two consequences: \opt{foo} is added to the options list
+% for package \pkg{bar}, which is the control sequence
+% \cs{opt@bar.sty}; and when \cs{ProcessOptions} is called, it
+% executes \cs{ds@option-name} for each option found in the list.
+% When it is finished running the options, \cs{ProcessOptions}
+% undefines all the \cs{ds@whatever} for the current package, which
+% are listed in the control sequence \cs{@declaredoptions}. At the
+% end of \fn{bar.sty}, \cs{@declaredoptions} is globally reset to
+% empty. Thus subordinate packages with options cannot be loaded in
+% the \qq{first half} of a package that also has options, where first half
+% means the area leading up to the \cs{ProcessOptions} call.
+%
+% For mutually exclusive options \xt{a}, \xt{b}, \xt{c}, when option
+% \xt{b} is invoked it should remove all of its sibling options from
+% the options-actually-used list and add itself to the list. For this
+% task we make use of the fact that \cs{ProcessOptions} ends by
+% undefining all the declared options of the current package or
+% documentclass.
+%
+% \begin{macrocode}
+\def\CurrentPackage{\@currname}
+\let\CurrentClass\CurrentPackage
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newcommand{\IfOption}{}
+\def\IfPackageOption{\@ifpackagewith}
+\def\IfClassOption{\@ifclasswith}
+\def\IfOption{%
+ \ifx\@currext\@pkgextension \@xp\IfPackageOption
+ \else \@xp\IfClassOption
+ \fi
+ \@currname
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newcommand{\DeclareExclusiveOptions}[1]{%
+ \xdef\@declaredoptions{\@declaredoptions,#1}%
+ \gdef\ProcessExclusiveOptions{\relax}%
+ \@for\CurrOption:=#1\do{%
+ \@xp\deo@a\csname ds@\CurrOption\@xp\endcsname\@xp{\CurrOption}{#1}%
+ }%
+}
+\def\DeclareBooleanOption{\DeclareExclusiveOptions}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\deo@a#1#2#3{%
+ \def#1{%
+ \g@addto@macro\ProcessExclusiveOptions{\OptionsFalseTrue{#3}{#2}}%
+ }%
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\cull@options#1,{%
+ \@xp\ifx\csname ds@#1\@gobble\@percentchar\@empty\endcsname\@False
+ \else #1,\fi
+ \cull@options
+}
+
+\newcommand{\OptionsFalseTrue}[2]{%
+ \begingroup
+ \@for\CurrentOption:=#1\do{%
+ \@xp\let\csname ds@\CurrentOption\endcsname\@False
+ }%
+ \let\ds@\@False
+ \@xp\xdef\csname opt@\@currname.\@currext\endcsname{%
+ \@xp\@xp\@xp\cull@options\csname opt@\@currname.\@currext\endcsname
+% \end{macrocode}
+% Lacking \cs{@secondofthree} and not keen on defining it \ldots
+% \begin{macrocode}
+ ,\@firstoftwo\@firstoftwo,#2%
+ }%
+ \endgroup
+}
+% \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}
+%
+% \CheckSum{112}
+% \Finale
diff --git a/Master/texmf-dist/source/latex/amslatex/mathscinet.dtx b/Master/texmf-dist/source/latex/amslatex/mathscinet.dtx
new file mode 100644
index 00000000000..78e01159ad6
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/mathscinet.dtx
@@ -0,0 +1,595 @@
+%%% ====================================================================
+%%% @LaTeX-doc-source-file{
+%%% filename = "mathscinet.dtx",
+%%% version = "2.01",
+%%% date = "2004/06/30",
+%%% time = "12:00:17 EDT",
+%%% author = "Michael J Downes and David M. Jones",
+%%% address = "American Mathematical Society,
+%%% Publications Technical Group,
+%%% PO Box 6248,
+%%% Providence, RI 02940,
+%%% USA",
+%%% email = "tech-support@ams.org",
+%%% URL = "http://www.ams.org/",
+%%% abstract = "",
+%%% checksum = "34681 595 2175 20194",
+%%% docstring = "The checksum field, produced by Robert Solovay's
+%%% checksum utility, gives CRC-16 checksum, lines,
+%%% words, and characters.",
+%%% }
+%%% ====================================================================
+%%%
+% \iffalse
+%<*driver>
+\NeedsTeXFormat{LaTeX2e}
+\documentclass[draft]{amsdtx}
+
+\usepackage{mathscinet}
+
+\newcommand{\uchar}[1]{{\small \texttt{U+#1}}}
+
+\newcommand{\enc}{\texttt}
+
+\newenvironment{chartable}{%
+ \begin{tabular}{%
+ l@{\extracolsep{1em}}%
+ l@{\extracolsep{1em}}%
+ r@{\extracolsep{2em}}%
+ l@{\extracolsep{1em}}%
+ l@{\extracolsep{1em}}%
+ r}%
+}{%
+ \end{tabular}%
+}
+
+\makeatletter
+
+\DeclareTextCommandDefault{\xudot}{\@underaccent\@empty{'137}}
+
+\makeatother
+
+\MakeShortVerb{\|}
+
+\begin{document}
+\title{The \pkg{mathscinet} package}
+\author{American Mathematical Society}
+\date{Version \fileversion, \filedate}
+\hDocInput{mathscinet.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \maketitle
+% \section{Introduction}
+%
+% The \pkg{mathscinet} packages provides definitions for certain
+% commands that occasionally occur in bibliographic data exported
+% from MathSciNet and that are not provided by \latex/.
+%
+% \textbf{Warning:} Although the macros provided in this package
+% are probably acceptable if all you need to do is format an entry
+% downloaded from MathSciNet, they should probably not be used for
+% other purposes. In general, if you are trying to typeset
+% material in any languages that require these characters, you are
+% better off using specialized fonts and encodings for those
+% languages.
+%
+% All Unicode character references are taken from \emph{The Unicode
+% Standard, Version~3.0} (Addison-Wesley, 2000).
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+% Standard declaration of package name and date.
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{mathscinet}[2002/04/17 v1.05]
+\RequirePackage{textcmds}\relax
+% \end{macrocode}
+%
+% \begin{macro}{\setboxz@h}
+% A useful abbreviation borrowed from \pkg{amsgen}.
+% \begin{macrocode}
+\providecommand\setboxz@h{\setbox\z@\hbox}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Math font commands}
+%
+% \begin{macro}{\bold}
+% \begin{macro}{\scr}
+% These are simple aliases of core \latex/ commands.
+% \begin{macrocode}
+\providecommand{\bold}{\mathbf}
+\providecommand{\scr}{\mathcal}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\germ}
+% Since this doesn't correspond to a core \latex/ command, we
+% generate an error if no appropriate definition is available.
+% \begin{macrocode}
+\AtBeginDocument{%
+ \@ifundefined{mathfrak}{%
+ \providecommand{\germ}{%
+ \PackageError{mathscinet}{To use the \string\germ\space
+ command, please load the amsfonts package}\@ehc
+ }%
+ }{%
+ \providecommand{\germ}{\mathfrak}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\romsup}
+% \begin{macro}{\asup}
+% The \cs{tsup} command comes from the \pkg{textcmds} package.
+% \begin{macrocode}
+\providecommand{\romsup}{\tsup}
+\providecommand{\asup}{\tsup}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\hslash}
+% Planck's constant over~$2\pi$:~$\hslash$ (\uchar{210F}).
+%
+% If the \pkg{amssymb} package isn't loaded, we just want this to
+% be an alias for |\hbar|, which is defined in the \latex/ kernel
+% (and then redefined by the \pkg{amssymb} package). If the
+% \pkg{amssymb} package is loaded, we want to use its definition
+% of~|\hslash|. To prevent problems if \pkg{amsrefs} is loaded
+% before \pkg{amssymb}, we defer our definition of \cn{hslash}
+% until after all packages have been loaded.
+% \begin{macrocode}
+\AtBeginDocument{\providecommand{\hslash}{\hbar}}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Arabic transliteration}
+%
+% \begin{macro}{\rasp}
+% Transliteration of the Arabic letter \emph{hamza}
+% (\uchar{0621}):~\rasp\ (\uchar{02BE}).
+% \begin{macrocode}
+\ProvideTextCommandDefault{\rasp}{\leavevmode\raise.45ex\hbox{$\rhook$}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\lasp}
+% Transliteration of the Arabic letter \emph{ain}
+% (\uchar{0639}):~\lasp\ (\uchar{02BF}).
+% \begin{macrocode}
+\ProvideTextCommandDefault{\lasp}{\leavevmode\raise.45ex\hbox{$\lhook$}}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Latin Extended-A (\texttt{latin1}) characters}
+%
+% These are based on Barbara Beeton's definitions from
+% \fn{amsclass.dtx}.
+%
+% \begin{macro}{\Dbar}
+% Latin capital letter D with stroke:~\Dbar\ (\uchar{0110}). In the
+% T1 encoding, we just use |\DJ|; otherwise we fake it.
+% \begin{macrocode}
+\ProvideTextCommand{\Dbar}{T1}{\DJ}
+
+\ProvideTextCommandDefault{\Dbar}{%
+ \leavevmode\lower.5ex\rlap{\hskip-.07em\accent"16}D%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\dbar}
+% Latin lower letter~d with stroke:~\dbar\ (\uchar{0111}). In the
+% T1 encoding, we just use |\dj|; otherwise we fake it.
+% \begin{macrocode}
+\ProvideTextCommand{\dbar}{T1}{\dj}
+% \end{macrocode}
+% If it looks like this is a small-caps font, we adjust the spacing
+% appropriately.
+% \begin{macrocode}
+\ProvideTextCommandDefault{\dbar}{%
+ \begingroup
+ \edef\@tempa{\scdefault}%
+ \ifx\@tempa\f@shape
+ \dimen@-.75ex
+ \dimen@i-.08em
+ \else
+ \dimen@.02ex
+ \dimen@i.1em
+ \fi
+ \leavevmode\raise\dimen@\rlap{\hskip\dimen@i\char"16}d%
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Cyrillic transliteration}
+%
+% \begin{macro}{\cprime}
+% Transliteration of the Cyrillic letter soft sign
+% (\uchar{042C}):~\cprime.
+% \begin{macrocode}
+\ProvideTextCommandDefault{\cprime}{\tprime}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cdprime}
+% Transliteration of the Cyrillic letter hard sign
+% (\uchar{042A}):~\cdprime.
+% \begin{macrocode}
+\ProvideTextCommandDefault{\cdprime}{\tprime\tprime}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bud}
+% Ditto.
+% \begin{macrocode}
+\ProvideTextCommandDefault{\bud}{\cdprime}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cydot}
+% Vertically centered dot.
+% \begin{macrocode}
+\ProvideTextCommandDefault{\cydot}{\leavevmode\raise.4ex\hbox{.}}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Miscellaneous diacritics (aka Frankenstein's\\
+% diacritics)}
+%
+% \begin{macro}{\save@sf}
+% When putting together an accented character from bits and pieces,
+% the |\spacefactor| of the base character often gets lost in the
+% shuffle. We use essentialy the same technique as |\add@accent|
+% to save and restore the spacefactor, but we wrap in in a pair of
+% macros for convenience.
+% \begin{macrocode}
+\def\save@sf{%
+ \ifmmode\else\global\mathchardef\accent@spacefactor\spacefactor\fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\restore@sf}
+% And here's the corresponding restore.
+% \begin{macrocode}
+\def\restore@sf{\ifmmode\else\spacefactor\accent@spacefactor\fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@underaccent}
+% This is perhaps the most interesting macro in this package (which
+% admittedly isn't saying much). It attempts to convert a character
+% (usually one of the standard above-letter diacritics like~\"{})
+% into an underhanging diacritic (like~\dudot{\hbox to
+% .5em{\hss}}). This is similar in spirit to the way that the
+% \enc{OT1} \cn{b} command converts a macron into a bar-under
+% accent, or the way that \cn{d} converts a period into an
+% underhanging dot. However, the technique used here is a little
+% more complicated and, hopefully, a little more general, in the
+% sense of requiring fewer ad-hoc parameters. It only contains one
+% magic constant (.2\,ex), which seems to provide reasonable
+% results for all of the Computer Modern fonts.
+%
+% The basic algorithm is as follows:
+%
+% \begin{enumerate}
+%
+% \item
+% Create a box~$B$ containing the base character at its natural
+% height, depth, and width.
+%
+% \item
+% Create a box~$d$ consisting of the diacritic centered in a space
+% equal to the width of~$B$.
+%
+% \item
+% Lower box~$d$ by the sum of its height (to bring the top of~$d$
+% down to the baseline) plus the depth of $B$ (to bring the top
+% of~$d$ down to the bottom of~$B$) plus .2\,ex (to provide the
+% spacing between the bottom of the letter and the top of the
+% diacritic). Call the new box~$d'$.
+%
+% \item
+% Create a new box~$C$ by superimposing boxes $B$ and~$d'$.
+%
+% \item
+% If the height of~$d$ was greater than 1\,ex, reset the depth of
+% box~$C$ to the sum of the depth of~$B$ and 1\,ex less than the
+% height of~$d$. (See the appendix for a discussion of this step.)
+%
+% \end{enumerate}
+%
+% \begin{macrocode}
+\def\@underaccent#1#2#3{%
+ \leavevmode
+ \begingroup
+ \ifmmode\let\@mathtoggle$\else\let\@mathtoggle\relax\fi
+ \setboxz@h{\@mathtoggle#3\save@sf\@mathtoggle}%
+ \setbox\@ne\hb@xt@\wd\z@{%
+ \hss\fontshape\updefault\rmfamily#1\char#2\hss
+ }%
+ \dimen@\ht\@ne
+ \advance\dimen@\dp\z@
+ \advance\dimen@.2ex
+ \setboxz@h{\lower\dimen@\rlap{\copy\@ne}\unhbox\z@}%
+ \ifdim\ht\@ne>1ex
+ \advance\dimen@-1.2ex
+ \dp\z@\dimen@
+ \fi
+ \box\z@
+ \restore@sf
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\utilde}
+% Tilde below (\uchar{0330}):
+%
+% \begin{chartable}
+% |\utilde{E}| & \utilde{E} & \uchar{1E1A} &
+% |\utilde{e}| & \utilde{e} & \uchar{1E1B} \\
+% |\utilde{I}| & \utilde{I} & \uchar{1E2C} &
+% |\utilde{i}| & \utilde{i} & \uchar{1E2D} \\
+% |\utilde{U}| & \utilde{U} & \uchar{1E74} &
+% |\utilde{u}| & \utilde{u} & \uchar{1E75}
+% \end{chartable}
+% \begin{macrocode}
+\DeclareTextCommandDefault{\utilde}{\@underaccent\@empty{`\~}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\uarc}
+% Breve below (\uchar{032E}):
+%
+% \begin{chartable}
+% |\uarc{H}| & \uarc{H} & \uchar{1E2A} &
+% |\uarc{h}| & \uarc{h} & \uchar{1E2B}
+% \end{chartable}
+% \begin{macrocode}
+\DeclareTextCommandDefault{\uarc}{\@underaccent\@empty{'025}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\lfhook}
+% Comma below (\uchar{0326}):
+%
+% \begin{chartable}
+% |\lfhook{S}| & \lfhook{S} & \uchar{0218} &
+% |\lfhook{s}| & \lfhook{s} & \uchar{0219} \\
+% |\lfhook{T}| & \lfhook{T} & \uchar{021A} &
+% |\lfhook{t}| & \lfhook{t} & \uchar{021B}
+% \end{chartable}
+% \begin{macrocode}
+\DeclareTextCommandDefault{\lfhook}{\@underaccent\supsize{`\,}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\dudot}
+% Diaeresis below (\uchar{0324}):
+%
+% \begin{chartable}
+% |\dudot{U}| & \dudot{U} & \uchar{1E72} &
+% |\dudot{u}| & \dudot{u} & \uchar{1E73}
+% \end{chartable}
+% \begin{macrocode}
+\DeclareTextCommandDefault{\dudot}{\@underaccent\@empty{'177}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\udot}
+% Dot below (\uchar{0323}): There are two options for implementing
+% this: either map to the standard \cn{d} accent or define using
+% \cs{@underaccent}. If we choose the former, we have two
+% problems: (a)~when applied to capital letters, the standard
+% \enc{T1} and \enc{OT1} implementations of~|\d| produce
+% \cs{spacefactor}s of~1000 instead of~999, and (b)~the
+% underspacing of the \cs{udot} accent will differ from that of the
+% \cs{dudot} accent:~\udot{x}\dudot{x}. On the other hand, if we
+% choose the latter, course, \cn{d} and \cn{udot} will
+% differ:~\d{x}\xudot{x}.
+% Neither solution appeals, but it's easier to stick with~\cs{d},
+% so that's what I'll do.
+% \begin{macrocode}
+\DeclareTextCommandDefault{\udot}{\d}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\polhk}
+% Ogonek (Polish hook) (\uchar{0328}):
+%
+% \begin{chartable}
+% |\polhk{A}| & \polhk{A} & \uchar{0104} &
+% |\polhk{a}| & \polhk{a} & \uchar{0105} \\
+% |\polhk{E}| & \polhk{E} & \uchar{0118} &
+% |\polhk{e}| & \polhk{e} & \uchar{0119} \\
+% |\polhk{I}| & \polhk{I} & \uchar{012E} &
+% |\polhk{i}| & \polhk{i} & \uchar{012F} \\
+% |\polhk{U}| & \polhk{U} & \uchar{0172} &
+% |\polhk{u}| & \polhk{u} & \uchar{0173} \\
+% |\polhk{O}| & \polhk{O} & \uchar{01EA} &
+% |\polhk{o}| & \polhk{o} & \uchar{01EB}
+% \end{chartable}
+%
+% The \enc{T1} and \enc{OT4} encodings implement the |\k| accent,
+% so we just use it for most characters, although we will
+% supplement them later with
+% \begin{macrocode}
+\DeclareTextCommand{\polhk}{OT4}{\k}
+\DeclareTextCommand{\polhk}{T1}{\k}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareTextCommand{\polhk}{OT1}[1]{\TextSymbolUnavailable{\k{#1}}#1}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareTextCompositeCommand{\polhk}{OT1}{a}{\msc@ogonek {.6}{.07} a}
+\DeclareTextCompositeCommand{\polhk}{OT1}{A}{\msc@ogonek {.6}{.07} A}
+\DeclareTextCompositeCommand{\polhk}{OT1}{e}{\msc@ogonek 0 {.06} e}
+\DeclareTextCompositeCommand{\polhk}{OT1}{E}{\msc@ogonek{.35}{.07} E}
+\DeclareTextCompositeCommand{\polhk}{OT1}{i}{\msc@ogonek {.2}{.07} i}
+\DeclareTextCompositeCommand{\polhk}{OT1}{I}{\msc@ogonek {.2}{.07} I}
+\DeclareTextCompositeCommand{\polhk}{OT1}{u}{\msc@ogonek {.6}{.07} u}
+\DeclareTextCompositeCommand{\polhk}{OT1}{U}{\msc@ogonek 0 {.05} U}
+\DeclareTextCompositeCommand{\polhk}{OT1}{o}{\msc@ogonek 0 {.07} o}
+\DeclareTextCompositeCommand{\polhk}{OT1}{O}{\msc@ogonek 0 {.05} O}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareTextCompositeCommand{\polhk}{T1}{i}{\msc@ogonek@a 0 i}
+\DeclareTextCompositeCommand{\polhk}{T1}{I}{\msc@ogonek@a 0 I}
+\DeclareTextCompositeCommand{\polhk}{T1}{u}{\msc@ogonek@a {.6} u}
+\DeclareTextCompositeCommand{\polhk}{T1}{U}{\msc@ogonek@a 0 U}
+\DeclareTextCompositeCommand{\polhk}{T1}{o}{\msc@ogonek@a 0 o}
+\DeclareTextCompositeCommand{\polhk}{T1}{O}{\msc@ogonek@a 0 O}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareTextCompositeCommand{\polhk}{OT4}{i}{\msc@ogonek {.2}{.07} i}
+\DeclareTextCompositeCommand{\polhk}{OT4}{I}{\msc@ogonek {.2}{.07} I}
+\DeclareTextCompositeCommand{\polhk}{OT4}{u}{\msc@ogonek {.6}{.07} u}
+\DeclareTextCompositeCommand{\polhk}{OT4}{U}{\msc@ogonek 0 {.05} U}
+\DeclareTextCompositeCommand{\polhk}{OT4}{o}{\msc@ogonek 0 {.07} o}
+\DeclareTextCompositeCommand{\polhk}{OT4}{O}{\msc@ogonek 0 {.05} O}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\msc@ogonek}
+% \begin{macrocode}
+\def\msc@ogonek#1#2#3{%
+ \begingroup
+ \setboxz@h{#3\save@sf}%
+ \dimen@\wd\z@
+ \ooalign{%
+ \unhbox\z@\crcr
+ \hidewidth
+ \setboxz@h{\kern#1\dimen@\supsize$\lhook$}%
+ \dimen@\ht\z@
+ \advance\dimen@-#2ex\relax
+ \lower\dimen@\box\z@
+ \hidewidth
+ }%
+ \restore@sf
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\msc@ogonek@a}
+% \begin{macrocode}
+\def\msc@ogonek@a#1#2{%
+ \begingroup
+ \ooalign{%
+ #2\save@sf\crcr
+ \hidewidth
+ \raise0.02ex\hbox{\kern#1ex\char'014}%
+ \hidewidth
+ }%
+ \restore@sf
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\soft}
+% Polish `soft' letters T, D, L:
+%
+% \begin{chartable}
+% |\soft{T}| & \soft{T} & \uchar{0164} &
+% |\soft{t}| & \soft{t} & \uchar{0165} \\
+% |\soft{D}| & \soft{D} & \uchar{010E} &
+% |\soft{d}| & \soft{d} & \uchar{010f} \\
+% |\soft{L}| & \soft{L} & \uchar{013B} &
+% |\soft{l}| & \soft{l} & \uchar{013C}
+% \end{chartable}
+% \begin{macrocode}
+\DeclareTextCommand{\soft}{OT4}{\v}
+\DeclareTextCommand{\soft}{T1}{\v}
+\DeclareTextCommand{\soft}{OT1}{\v}
+
+\DeclareTextCompositeCommand{\soft}{OT1}{t}{\msc@soft{t}\@ne{.5ex}}
+\DeclareTextCompositeCommand{\soft}{OT1}{d}{\msc@soft{d}{.925}{.95ex}}
+\DeclareTextCompositeCommand{\soft}{OT1}{l}{\msc@soft{l}{.95}{.4ex}}
+\DeclareTextCompositeCommand{\soft}{OT1}{L}{\msc@soft{L}{.975}{.8ex}}
+
+\DeclareTextCompositeCommand{\soft}{OT4}{t}{\msc@soft{t}\@ne{.5ex}}
+\DeclareTextCompositeCommand{\soft}{OT4}{d}{\msc@soft{d}{.925}{.95ex}}
+\DeclareTextCompositeCommand{\soft}{OT4}{l}{\msc@soft{l}{.95}{.4ex}}
+\DeclareTextCompositeCommand{\soft}{OT4}{L}{\msc@soft{L}{.975}{.8ex}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\msc@soft}
+% \begin{macrocode}
+\def\msc@soft#1#2#3{%
+ \leavevmode
+ \begingroup
+ \setboxz@h{#1}%
+ \raise#2\ht\z@\rlap{\kern#3\supsize,}\unhbox\z@
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \section*{\raggedright Appendix: Plumbing the depths of
+% underhanging diacritics: Notes on the magic constant 0.2\,ex and
+% an exegesis of certain obscure corners of the \cn{@underaccent}
+% macro}
+%
+% \tex/ assumes that a combining accent can be superimposed
+% directly on top of any character whose height is 1\,ex. If the
+% actual height of the base character differs from 1\,ex, the
+% accent is shifted up or down to maintain the same vertical
+% separation. Put another way, subtracting 1\,ex from the height
+% of a combining accent tells us how much a character's height is
+% increased when that accent is added. Call this
+% distance~$\delta$.
+%
+% This distance can be analyzed into two pieces: $\delta = \sigma +
+% \eta$, where $\sigma$ is the separation between the top of
+% the base character and the \emph{bottom} of the accent, and
+% $\eta$ is the height of the bounding box of the accent.
+%
+% If we now consider moving the accent to the bottom of a
+% character, we have a new relation $\delta' = \sigma' + \eta$,
+% where $\sigma'$ is the distance between the bottom of the base
+% and the \emph{top} of the accent, and $\delta'$ is the amount by
+% which the depth of the base character is increased.
+%
+% If the placement of the underhanging version of an accent were
+% strictly symmetrical with the overhanging version, then we would
+% have $\sigma' = \sigma$ and thus $\delta' = \delta$. However, the
+% placement is not symmetric since for aesthetic reasons we have
+% chosen to set $\sigma' = .2\,\mathrm{ex}$, which seems in general
+% to be a little less than the corresponding~$\sigma$.
+% Unfortunately, this means we can't calculate~$\delta'$ accurately
+% since there is no way to deduce $\eta$ (or, equivalently,
+% $\sigma$) from the font metric information available to us
+% within~\TeX.\footnote{By exploiting symmetries present in some
+% fonts, one can calculate $\eta$ for some of the accents in those
+% fonts, but this doesn't help us much since both $\sigma$
+% and~$\eta$ vary between accents.}
+%
+% This leaves us in a bit of a bind, since it means there is no way
+% to calculate the depth accurately. In despair, I've decided just
+% to pretend that $\delta' = \delta$ for now.
+%
+% \subsection*{Finis}
+%
+% 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}
+%
+% \CheckSum{365}
+% \Finale
diff --git a/Master/texmf-dist/source/latex/amslatex/pcatcode.dtx b/Master/texmf-dist/source/latex/amslatex/pcatcode.dtx
new file mode 100644
index 00000000000..192cb201871
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/pcatcode.dtx
@@ -0,0 +1,359 @@
+%%% ====================================================================
+%%% @LaTeX-doc-source-file{
+%%% filename = "pcatcode.dtx",
+%%% version = "1.04",
+%%% date = "2002/04/16",
+%%% time = "09:20:52 EDT",
+%%% author = "Michael J Downes",
+%%% copyright = "Copyright 2001 American Mathematical Society",
+%%% address = "American Mathematical Society,
+%%% Publications Technical Group,
+%%% PO Box 6248,
+%%% Providence, RI 02940,
+%%% USA",
+%%% email = "tech-support@ams.org",
+%%% URL = "http://www.ams.org/",
+%%% abstract = "The pcatcode package changes LaTeX package loading
+%%% internals so that all subsequently loaded packages
+%%% can rely on having normal catcodes in effect.",
+%%% license = "Artistic",
+%%% checksum = "25118 359 1469 13319",
+%%% docstring = "The checksum field, produced by Robert Solovay's
+%%% checksum utility, gives CRC-16 checksum, lines,
+%%% words, and characters.",
+%%% }
+%%% ====================================================================
+% \iffalse
+%<*driver>
+\documentclass{amsdtx}
+%\usepackage{pcatcode}\relax
+\begin{document}
+\title{The \pkg{pcatcode} package}
+\author{Michael~J. Downes\\American Mathematical Society}
+\date{Version \fileversion, \filedate}
+\hDocInput{pcatcode.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \maketitle
+% \section{Introduction}
+%
+% The \pkg{pcatcode} package provides mechanisms for robustly
+% changing the catcode environment for the duration of a package and
+% restoring it afterwards to whatever it was before the package was
+% loaded.
+%
+% Motivation: The \pkg{amsmath} package (for example), makes a number
+% of assignments using characters such as double-quote and
+% left-quote, because these are hard-wired into the \tex/ syntax for
+% numbers and other things. If a package that makes double-quote an
+% active character is loaded before \pkg{amsmath}, all the
+% statements that use double-quote turn into error messages.
+%
+% But now! Groan and grumble no more, ye package writers, for putting
+% a magical invocation of the pcatcode package at the beginning of
+% your package file, as shown here, will ensure that your
+% package contents will be processed with completely normal catcodes.
+%\begin{verbatim}
+%\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+%\@ifundefined{PushCatcodes}{%
+% \RequirePackage{pcatcode}\relax\PushCatcodes\NormalCatcodes
+%}{}
+%\ProvidesPackage{foo}[2002/04/16 v1.04]
+%\end{verbatim}
+%
+% It must be followed by a matching \cs{PopCatcodes} command,
+% typically used in conjunction with \cs{endinput}.
+%
+% WARNING: This functionality would work best if it were built into
+% the \LaTeX{}2e kernel, but it cannot be usefully added to the
+% kernel now without adversely affecting document compatibility
+% across different systems. This package therefore modifies one or
+% two of the low-level package-loading functions defined by the
+% kernel. This means that there may be trouble if any other package,
+% or some future version of \LaTeX{}, changes the definitions of
+% those functions.
+%
+% NOTE: Packages that do not call \cs{PushCatcodes}
+% \cs{NormalCatcodes} will remain transparent to the external catcode
+% environment in the usual way (i.e., for all characters except the
+% \verb'@' character).
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+% \subsection{Preliminary Remarks}
+%
+% At the document level, we assume that the following characters
+% always have their standard catcode:
+% \begin{center}
+% \begin{tabular}{lp{.75\columnwidth}}
+% \verb'\{}' & for commands and arguments\\
+% \verb'%' & for comments\\
+% \verb'#' & for use with \cn{newcommand}\\
+% \verb'*' & cannot be changed without breaking star-form commands\\
+% \verb'[]' & cannot be changed without breaking optional arguments\\
+% \verb'~' & already active, no reason to change catcode
+% \end{tabular}
+% \end{center}
+%
+% One might think that we could assume hyphen, period (and comma, for
+% European decimal notation) are always catcode 12. Experience has
+% shown, however, that for just about every character there is some
+% plausible application that would be facilitated by making that
+% character active and giving it a complex definition. Surely hyphen
+% and period must stay catcode 12 in order to work in statements like
+% the following?
+%\begin{verbatim}
+%\addtocounter{section}{-1}
+%\addtolength{\columnwidth}{-1.5cm}
+%\end{verbatim}
+% Yet hyphen and period are important constituents of ordinary text
+% and therefore special applications arise. For example,
+% what if you would like
+% mdashes to be surrounded by extra space but your authors prefer to
+% continue writing \verb'---' in the accustomed manner?
+%
+% Theoretically speaking, the \pkg{pcatcode} package itself has to
+% guard against the kind of catcode problems that it is intended to
+% circumvent. If you would like a nice little \tex/nician's
+% exercise, try your hand, before looking at the code below, at the
+% task that I set for myself: Find the minimal set of catcode
+% assumptions that one has to make before attempting to establish
+% normalcy, where normalcy is defined as the state at the end of
+% \fn{latex.ltx}, just before the last \cs{makeatother}. This is the
+% state that may normally be expected at the beginning of a
+% documentclass file, if the \LaTeX{} format file does not have any
+% extensions (e.g., babel) compiled in.
+%
+% Ready to look, now?
+%
+% In order for the following code to work it is only necessary that
+% backslash, letters, and digits have their normal catcodes: 0, 11,
+% 12 respectively. One could argue that if \fn{pcatcode.sty} is
+% invoked through a standard \cs{RequirePackage} call, it can be
+% assumed that curly braces also have their normal catcodes. But I
+% suppose it is not utterly inconceivable that in some special
+% circumstances one might want to load the package with the
+% \cs{@@input} primitive, sans braces. And in any case the extra
+% overhead to handle braces as well is trivial so for esthetic
+% reasons I'm gonna put it in.
+%
+% If you look really hard you'll find one or two other assumptions,
+% such as ``endlinechar is not a letter''. Wait, come to think of it,
+% I can fix that \ldots
+%
+% The purpose of the group is chiefly to localize the temporarily
+% changed definitions of \cs{e}, \cs{n}, etc.
+% \begin{macrocode}
+\begingroup\let\e\endlinechar\iffalse\
+\fi\chardef\E\e\e13\chardef\n\catcode\e\catcode\e5\relax\relax
+\chardef\s\catcode32\chardef\t10\catcode32\t
+\chardef\c\catcode37 \catcode37 14 % percent
+\chardef\=\catcode61 \catcode61 12 % equal sign
+\chardef\l=\catcode123 \catcode123=1 % left brace
+\chardef\r=\catcode125 \catcode125=2 % right brace
+\chardef\[=\catcode91 \catcode91=12 % left bracket
+\chardef\]=\catcode93 \catcode93=12 % right bracket
+\chardef\^=\catcode94 \catcode94=7 % hat
+\chardef\.=\catcode46 \catcode46=12 % period
+\chardef\/=\catcode47 \catcode47=12 % slash
+\edef\c{%
+ \endgroup
+ \def\noexpand\pcat@restore{%
+ \catcode\number\e=\number\n \catcode32=\number\s
+ \catcode123=\number\l \catcode125=\number\r
+ \catcode37=\number\c \catcode61=\number\=%
+ \catcode91=\number\[\catcode93=\number\]\catcode94=\number\^%
+ \catcode46=\number\.\catcode47=\number\/%
+ \endlinechar=\number\E \relax
+ }%
+}
+\c
+\endlinechar13\catcode13\string=5\relax\relax
+\catcode32\string=10 \catcode37 14\relax\relax
+\catcode61 12\catcode123=1\catcode125=2\catcode91=12\catcode93=12\relax
+\catcode46=12\catcode47=12\catcode94=7\relax
+% \end{macrocode}
+%
+% This code was postponed until now to avoid all but the most
+% essential assumptions.
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{pcatcode}[2002/04/16 v1.04]
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\NormalCatcodes{%
+ \endlinechar=13%
+ \catcode33=12\catcode34=12\catcode35=6\catcode36=3\catcode37=14%
+ \catcode38=4\catcode39=12\catcode40=12\catcode41=12\catcode42=12%
+ \catcode43=12\catcode44=12\catcode45=12\catcode46=12\catcode47=12%
+ \catcode58=12\catcode59=12\catcode60=12\catcode61=12\catcode62=12%
+ \catcode63=12\catcode91=12\catcode92=0\catcode93=12\catcode94=7%
+ \catcode95=8\catcode96=12\catcode123=1\catcode124=12\catcode125=2%
+ \catcode126=13\catcode32=10\catcode13=5\catcode9=10\catcode10=12%
+ \relax
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\CatcodeStack{}
+% \end{macrocode}
+%
+% Notably absent from the following list: the \verb'@' character and
+% whitespace characters. The former is already handled in the
+% \LaTeX{} kernel, and I hesitate to interfere with its current
+% catcode transitions.
+% \begin{macrocode}
+\begingroup \escapechar=\m@ne \let\s\string
+\xdef\pcat@otherchars{%
+ \s\!\s\"\s\#\s\$\s\%\s\&\s\'\s\(\s\)\s\*\s +\s\,\s\-\s\.\s\/\s\:%
+ \s\;\s\<\s\=\s\>\s\?\s\[\s\\\s\]\s\^\s\_\s\`\s\{\s\|\s\}\s\~%
+}
+\endgroup
+% \end{macrocode}
+%
+% \begin{macrocode}
+\gdef\PushCatcodes{%
+ \xdef\CatcodeStack{%
+ \expandafter\PushCat@a\pcat@otherchars\ \
+ \^^I\^^J{T \@gobbletwo}\@empty
+ \relax
+ {\CatcodeStack}}%
+}
+\def\PushCat@a#1{\catcode\number`#1=\number\catcode`#1 \PushCat@a}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\PushCatcodes \NormalCatcodes
+% \end{macrocode}
+%
+% \begin{macrocode}
+\def\PopCatcodes{\expandafter\PopCat@a\CatcodeStack}
+\def\PopCat@a#1#{#1\xdef\CatcodeStack}
+% \end{macrocode}
+%
+% \subsection{Checking current settings}
+%
+% This can be used to store a copy of the current settings. Or print
+% it with \cs{typeout}.
+% \begin{macrocode}
+\def\CCSdo#1{ (\string#1\@iden{:\number\catcode`#1)\CCSdo}}
+\def\CurrentCatcodesSubset{%
+ \romannumeral 0\CCSdo\^^I\^^J\^^L\^^M\ \!\"\#\$\%\&\'\(\)\*+\,\-\.\/\:\;\<\=\>\?\@\[\\\]\^\_\`\{\|\}{\~\@gobbletwo}:\number\catcode`\~)%
+}
+% \end{macrocode}
+%
+% \subsection{Futurelet support}
+%
+% For code that does futureletting to see if a punctuation character
+% follows, it is distressing to handle the case when some characters
+% might be made active (e.g., by the babel package).
+%
+% The \cs{FutureLetSetup} function attempts to minimize the
+% difficulties by defining canonical control sequences to represent
+% all the visible ASCII characters (i.e., ranging from space to
+% \qc{\~}, 32--126, plus TAB) whose catcode could be changed without
+% transgressing the limits of standard \LaTeX{} syntax.
+% \begin{macrocode}
+\begingroup\pcat@restore
+\begingroup
+\catcode`\3="3 \catcode`\4="4 \catcode`\7="7 \catcode`\8="8
+\catcode`\A="A \catcode`\B="B \catcode`\C="C \catcode`\D="D
+\gdef\fls@let#1#2{%
+ \ifx\@@undefined#1\else\errmessage{\string#1 already defined}\fi
+ \begingroup
+ \lccode`\3=`#2\lccode`\7=`#2\lccode`\8=`#2%
+ \lccode`\B=`#2\lccode`\C=`#2\lccode`\D=`#2\relax
+ \ifnum\catcode`#2=\active
+ \def\do##1{\noexpand\do\noexpand##1\noexpand}%
+ \lowercase{%
+ \xdef\fls@active@characters{%
+ \fls@active@characters
+ \do#1D}%
+ }%
+ \fi
+ \aftergroup\global \aftergroup\let \aftergroup#1\aftergroup=%
+ \lowercase{\aftergroup} %
+ \lowercase{\expandafter\endgroup
+ \ifcase\catcode`#2 %
+ 0\or \bgroup\or \egroup\or 3\or 4\or 5\or 6\or 7\or 8\or 9\or
+ \@sptoken\or B\or C\else D\fi
+ }%
+}
+\endgroup
+% \end{macrocode}
+% \cs{dl@@dblquote} means ``document-level double quote'': a
+% character token number 34 that has the catcode which is in effect
+% at \verb'\begin{document}' for double quotes.
+% \begin{macrocode}
+\gdef\FutureLetSetup{%
+ \gdef\fls@active@characters{}%
+% \end{macrocode}
+% This will normally be the same as \cs{@sptoken}.
+% \begin{macrocode}
+ \fls@let\dl@@space\ %
+ \fls@let\dl@@exclam\!%
+ \fls@let\dl@@dblquote\"%
+ \fls@let\dl@@hash\#%
+ \fls@let\dl@@dollar\$%
+% \end{macrocode}
+% At document level, this cannot occur as a separate token.
+% \begin{macrocode}
+% \fls@let\dl@@percent\%%
+ \fls@let\dl@@ampersand\&%
+ \fls@let\dl@@rquote\'%
+ \fls@let\dl@@lparen\(%
+ \fls@let\dl@@rparen\)%
+ \fls@let\dl@@star\*%
+ \fls@let\dl@@plus\+%
+ \fls@let\dl@@comma\,%
+ \fls@let\dl@@hyphen\-%
+ \fls@let\dl@@period\.%
+ \fls@let\dl@@slash\/%
+ \fls@let\dl@@colon\:%
+ \fls@let\dl@@semicolon\;%
+ \fls@let\dl@@less\<%
+ \fls@let\dl@@equal\=%
+ \fls@let\dl@@greater\>%
+ \fls@let\dl@@question\?%
+ \fls@let\dl@@lbracket\[%
+% \end{macrocode}
+% At document level, this cannot occur as a separate token.
+% \begin{macrocode}
+% \fls@let\dl@@backslash\\%
+ \fls@let\dl@@rbracket\]%
+ \fls@let\dl@@hat\^%
+ \fls@let\dl@@underscore\_%
+ \fls@let\dl@@lquote\`%
+% \end{macrocode}
+% Here one would normally use \cs{bgroup}.
+% \begin{macrocode}
+ \fls@let\dl@@lbrace\{%
+ \fls@let\dl@@vert\|%
+% \end{macrocode}
+% Here one would normally use \cs{egroup}.
+% \begin{macrocode}
+ \fls@let\dl@@rbrace\}%
+ \fls@let\dl@@tilde\~%
+}
+\AtBeginDocument{\FutureLetSetup}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\gdef\FutureLetReset{%
+ \def\do##1##2{\let##1= ##2}%
+ \fls@active@characters
+ \let\do\relax
+}
+\endgroup
+% \end{macrocode}
+%
+% \begin{macrocode}
+\endinput \PopCatcodes\pcat@restore
+% \end{macrocode}
+%
+% \CheckSum{530}
+% \Finale
diff --git a/Master/texmf-dist/source/latex/amslatex/rkeyval.dtx b/Master/texmf-dist/source/latex/amslatex/rkeyval.dtx
new file mode 100644
index 00000000000..88d4642df27
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/rkeyval.dtx
@@ -0,0 +1,1116 @@
+%%% ====================================================================
+%%% @LaTeX-doc-source-file{
+%%% filename = "rkeyval.dtx",
+%%% version = "2.00",
+%%% date = "2004/06/28",
+%%% time = "15:19:29 EDT",
+%%% author = "Michael J Downes and David M. Jones",
+%%% address = "American Mathematical Society,
+%%% Publications Technical Group,
+%%% PO Box 6248,
+%%% Providence, RI 02940,
+%%% USA",
+%%% email = "tech-support@ams.org",
+%%% URL = "http://www.ams.org/",
+%%% abstract = "Key-value scanning functions with more restrictive
+%%% syntax than the standard keyval package. This permits
+%%% some improvements in the error-checking.",
+%%% checksum = "44721 1116 3178 30537",
+%%% docstring = "The checksum field, produced by Robert Solovay's
+%%% checksum utility, gives CRC-16 checksum, lines,
+%%% words, and characters.",
+%%% }
+%%% ====================================================================
+% \iffalse
+%<*driver>
+\documentclass[draft,oneside]{amsdtx}
+\pagestyle{myheadings}
+
+\makeatletter
+\DeclareRobustCommand{\fld}{\@category@index{field}}
+\makeatother
+
+\DoNotIndex{\@emptytoks,\@temptokenb}
+
+\CodelineIndex
+
+\begin{document}
+\title{The \pkg{rkeyval} package:\protect\linebreak[1]
+ Syntactically restricted key-value scanning}
+\author{Michael Downes and David M. Jones\\American Mathematical Society}
+\date{Version \fileversion, \filedate}
+\hDocInput{rkeyval.dtx}
+\PrintIndex
+\end{document}
+%</driver>
+% \fi
+%
+% \MakeShortVerb{\|}
+%
+% \maketitle
+% \markboth{The \protect\pkg{rkeyval} package}
+% {Version \protect\fileversion, \protect\filedate}
+%
+% \tableofcontents
+%
+% \section{Introduction}
+%
+% The \pkg{rkeyval} package provides functions for scanning key-value
+% notation similar to the kind of scanning supported by the standard
+% \pkg{keyval} package. However, the syntax is more restrictive in
+% order to make some improved error-checking possible. In particular,
+% if a comma is omitted between two instances of |key={value}|
+% form, the \cn{RestrictedSetKeys} command will spot the missing
+% comma and issue a suitable error message (and it will be given at
+% the point where the missing comma is detected, before reading any
+% further in the \tex/ file). The standard \cn{setkeys} command, by
+% contrast, will append the second key name to the value of the first
+% key and discard the second value, without any notification to the
+% user that anything has gone wrong. But that is partly because the
+% standard \cn{setkeys} command allows implied values and does not
+% require braces around explicit values (except when necessary to
+% hide material that has a syntactic resemblance to a key-value
+% pair). With \cn{RestrictedSetKeys} the value must always be present
+% and it must be enclosed in braces.
+%
+%^^A Maybe commas should be optional.
+%
+% Further restrictions of the \cn{RestrictedSetKeys} command and its
+% companion commands reduce memory consumption in certain ways.
+% Defining a key creates only one control sequence, a container for
+% holding the value. Processing of key values is normally limited to
+% storing a value given by the user; any additional processing must
+% be supplied separately by the programmer.
+%
+% Generally speaking, the error-checking done by
+% \cn{RestrictedSetKeys} is better for applications where all the
+% keys are expected to have textual values, while \cn{setkeys} is
+% better when one wants to silently recover as far as possible from
+% syntactic errors, instead of notifying the user of the errors; or
+% when keys have nontrivial default values (i.e., not empty) or other
+% kinds of special processing.
+%
+% \begin{verbatim}
+% \RestrictedSetKeys{setup-code}{group}{code}{key={val}, ...}
+%\end{verbatim}
+% Normally \cn{RestrictedSetKeys} simply carries out the following
+% assignment for each key-value pair:
+% \begin{verbatim}
+% \def\group'key{val}
+%\end{verbatim}
+% The first argument is normally empty, but the exact nature of the
+% warnings given and other aspects of the processing can be affected
+% by putting extra setup code there. The \pkg{amsrefs} package uses
+% this to implement a copying operation where field name and value
+% are written out immediately to another file instead of being stored
+% in the usual way.
+%
+% Some examples for defining the key names associated with a given
+% group. This defines ``title'' as a recognized key for the \fn{bib}
+% group:
+% \begin{verbatim}
+% \DefineSimpleKey{bib}{title}
+%\end{verbatim}
+% If a key is defined with \cs{DefineSimpleKey}, the result of using
+% the same key more than once in a single entry will be an error
+% message.
+%
+% This defines ``title'' to be a repeatable key:
+% \begin{verbatim}
+% \DefineSupersedingKey{bib}{title}
+%\end{verbatim}
+% If it occurs more than once, the last value supersedes the earlier
+% ones, instead of getting an error. This variation is not needed for
+% simple usage, but in more complicated situations where key values
+% are combined from multiple sources, it may be useful.
+%
+% This defines ``author'' to be a repeatable key, with each value
+% being appended to a list of values:
+% \begin{verbatim}
+% \DefineAdditiveKey{bib}{author}{\name}
+%\end{verbatim}
+% The third argument specifies a wrapper function that should be
+% applied to each item in the list. I.e., suppose that two author
+% names are given:
+% \begin{verbatim}
+% author={Smith, J. Q.},
+% author={Taylor, X. Y.},
+%\end{verbatim}
+% Then they will be stored in the form
+% \begin{verbatim}
+% \name{Smith, J. Q.}\name{Taylor, X. Y.}
+%\end{verbatim}
+%
+% This defines ``transition'' to be a dummy key with a value that is
+% superficially nonempty but effectly empty:
+% \begin{verbatim}
+% \DefineDummyKey{bib}{transition}
+%\end{verbatim}
+% Defining a dummy key like this can be useful in dealing with
+% certain boundary situations that sometimes arise.
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+% Standard declaration of package name and date.
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{rkeyval}[2004/05/05 v1.08]
+% \end{macrocode}
+%
+% \begin{macro}{\@xp}
+% \begin{macro}{\@nx}
+% \begin{macrocode}
+\let\@xp\expandafter
+\let\@nx\noexpand
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\@gobblethree}
+% \begin{macro}{\@nilgobble}
+% Not in the \latex/ kernel yet.
+% \begin{macrocode}
+\long\def\@gobblethree#1#2#3{}
+\long\def\@nilgobble#1\@nil{}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\@emptytoks}
+% Using \cs{@ifundefined} here avoids problems with really old
+% versions of \latex/ that choke on \cs{newtoks} if it is written
+% directly in the false branch of a conditional.
+% \begin{macrocode}
+\@ifundefined{@emptytoks}{\csname newtoks\endcsname\@emptytoks}{}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@temptokenb}
+% \begin{macrocode}
+\@ifundefined{@temptokenb}{\csname newtoks\endcsname\@temptokenb}{}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@append}
+% \begin{macrocode}
+\def\@append#1#2#3{\@xp\def\@xp#2\@xp{#2#1{#3}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\star@}
+% Test for a trailing option marked by a star. Usage:
+% \begin{verbatim}
+% \newcommand{\blub}[1]{\star@{\blubaux{#1}}{default}}
+%\end{verbatim}
+% Arg 1 of \cs{star@} is the code to
+% be run, arg 2 is the default value of the option (could be empty).
+% If arg 1 is \ncn{moo}, this test discards a star and expands to
+% \ncn{moo} if a star is found, or expands to |\moo{#2}| if
+% not. As the example shows, arg 1 need not be a single token.
+% \begin{macrocode}
+\def\star@#1#2{%
+ \def\star@a##1{#1}%
+ \def\star@b{#1{#2}}%
+ \futurelet\@let@token\star@test
+}
+
+\def\star@test{\ifx*\@let@token \let\star@b\star@a\fi \star@b}
+% \end{macrocode}
+%
+% Please note: If there is a space before the star, then the star is
+% not treated as an option char.
+%
+% Why use a star? Since it's already part of standard \latex/
+% command syntax, it's unlikely to suffer from catcode changes.
+%
+% Why not just put the star at the beginning in the usual way? It
+% seemed to me that the lack of a trailing option
+% feature was a deficiency in current \latex/ and could be given an
+% experimental implementation in a package like this without any
+% adverse effect on existing documents.
+% \end{macro}
+%
+% Ensure non-weird catcode for relevant characters.
+% \begin{macrocode}
+\@ifundefined{NormalCatcodes}{\RequirePackage{pcatcode}\relax}{}
+\PushCatcodes\NormalCatcodes
+% \end{macrocode}
+%
+% \begin{macro}{\extract@group}
+% Extracts ``group'' from |\group'field|.
+% \begin{macrocode}
+\def\extract@group#1{%
+ \@xp\extract@group@a\string#1\@nil
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\extract@group@a}
+% \begin{macrocode}
+\def\extract@group@a#1#2'{#2\@nilgobble}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Data structures}
+%
+% The result of scanning the key/value pairs is an assignment statement
+% for \cs{rsk@toks}. For example, consider the entry
+% \begin{verbatim}
+% \bib{LelekZ1962}{article}{
+% author={Lelek, A.},
+% author={Zaremba, D.},
+% title={Dimensions of irreducible ...},
+% journal={Fund. Math.},
+% date={1962/63},
+% }
+%\end{verbatim}
+% The scanned result is to assign
+% \begin{verbatim}
+% \global\rsk@toks{%
+% \set:bib'author{Lelek, A.}{}%
+% \set:bib'author{Zaremba, D.}{}%
+% \set:bib'title{Dimensions of irreducible ...}{}%
+% \set:bib'journal{Fund. Math.}{}%
+% \set:bib'date{1962/63}{}%
+% }
+%\end{verbatim}
+% The extra empty arguments on each line are for auxiliary
+% properties (see below).
+% What happens thereafter with \cs{rsk@toks} depends on the code in
+% the last arg of \cs{RestrictedSetKeys}.
+%
+% \section{Auxiliary properties}
+%
+% Unfortunately, the previous section isn't the entire story. In
+% addition to the values of each field, we need to store a set of
+% auxiliary properties associated with those values. Note that
+% properties are explicitly associated with \emph{values}, not with
+% keys, because each value of an additive key could have different
+% properties.
+%
+% All such extra data will be stored in a special field named
+% ``aux'', with embedded tags to indicate which field each piece of
+% the \fld{aux} field is associated with. The extra bits can be
+% extracted on demand using standard techniques, and the primary
+% value of each field is not burdened with any attachments, so that
+% comparisons or scanning of the field contents can remain as
+% simple as possible.
+%
+% Thus in practice there is at least one bit of auxiliary information
+% in every bib item, and our previous example would have the title
+% language indicated:
+% \begin{verbatim}
+% \DSK@def\bib'title{Eine Bemerkung zur Darstellung von Polynomen
+% \"{u}ber Verb\"{a}nden}%
+% \@append\bib'title\bib'aux{\selectlanguage{german}}%
+%\end{verbatim}
+%
+% \begin{macro}{\set@property}
+% \begin{macrocode}
+\def\set@property#1{%
+ \begingroup
+ \edef\@tempa{\extract@group#1}%
+ \edef\@tempa{%
+ \@nx\@append\@nx#1\@xp\@nx\csname \@tempa,aux\endcsname
+ }%
+ \@xp\endgroup
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\get@property}
+% \begin{macrocode}
+% \get@property\destination\bib'title
+\def\get@property#1#2{%
+ \get@nth@property#1#2\m@ne
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\get@nth@property}
+% \begin{macrocode}
+% \get@nth@property\destination\bib'title N
+\def\get@nth@property#1#2#3{%
+ \begingroup
+ \edef\@tempa{\extract@group#2}%
+ \@tempcnta#3\relax
+ \@tempcntb\z@
+ \@xp\scan@properties\@xp#2\csname \@tempa,aux\endcsname
+ \edef\@tempa{\def\@nx#1{\@tempa}}%
+ \@xp\endgroup
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\scan@properties}
+% \begin{macrocode}
+\def\scan@properties#1#2{%
+ \begingroup
+ \def\@tempa{#1}%
+ \let\@tempc\@empty
+ \@xp\find@property #2 \@nil\@nil
+ \edef\@tempa{\def\@nx\@tempa{\@tempc}}%
+ \@xp\endgroup
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\find@property}
+% \begin{macrocode}
+\def\find@property#1#2{%
+ \ifx\@nil#1%
+ \else
+ \def\@tempb{#1}%
+ \ifx\@tempa\@tempb
+ \ifnum\@tempcnta<\z@
+ \def\@tempc{#2}%
+ \else
+ \advance\@tempcntb\@ne
+ \ifnum\@tempcntb=\@tempcnta
+ \def\@tempc{#2}%
+ \fi
+ \fi
+ \fi
+ \@xp\find@property
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\reset@property}
+% \begin{macrocode}
+\def\reset@property#1#2{%
+ \reset@nth@property#1\m@ne{#2}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\reset@nth@property}
+% \begin{macrocode}
+% \reset@nth@property\bib'title N VALUE
+\def\reset@nth@property#1#2#3{%
+ \begingroup
+ \edef\@tempa{\extract@group#1}%
+ \@tempcnta#2\relax
+ \@temptokena{#3}%
+ \toks@\@emptytoks
+ \@tempcntb\z@
+ \@xp\reset@scan\@xp#1\csname \@tempa,aux\endcsname
+ \edef\@tempa{%
+ \def\@xp\@nx\csname \@tempa,aux\endcsname{\the\toks@}%
+ }%
+ \@xp\endgroup
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\reset@scan}
+% \begin{macrocode}
+\def\reset@scan#1#2{%
+ \begingroup
+ \def\@tempa{#1}%
+ \@xp\reset@scan@a #2 \@nil\@nil
+ \edef\@tempa{\toks@{\the\toks@}}%
+ \@xp\endgroup
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\find@property}
+% \begin{macrocode}
+\def\reset@scan@a#1#2{%
+ \ifx\@nil#1%
+ \else
+ \def\@tempb{#1}%
+ \ifx\@tempa\@tempb
+ \ifnum\@tempcnta<\z@
+ \@temptokenb\@temptokena
+ \else
+ \advance\@tempcntb\@ne
+ \ifnum\@tempcntb=\@tempcnta
+ \@temptokenb\@temptokena
+ \fi
+ \fi
+ \else
+ \@temptokenb{#2}%
+ \fi
+ \edef\@tempb{%
+ \toks@{\the\toks@ \@nx#1{\the\@temptokenb}}%
+ }%
+ \@tempb
+ \@xp\reset@scan@a
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Some machinery for finite state automata}
+%
+% Coincidentally I needed to write two finite state automaton parsers
+% for two related packages, so after writing them separately I spent
+% some time analyzing the code fragments they shared in common and
+% abstracted them so that the cs names could be shared.
+%
+% \begin{macro}{\fsa@l}
+% FSA lookahead.
+% \begin{macrocode}
+\def\fsa@l{\futurelet\@let@token\fsa@t}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fsa@b}
+% FSA bypass a token. Don't delete the space at the end!
+% \begin{macrocode}
+\def\fsa@b{\afterassignment\fsa@l \let\@let@token= }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fsa@c}
+% FSA copy a token (not space, bgroup, egroup).
+% \begin{macrocode}
+\def\fsa@c#1{\aftergroup#1\fsa@l}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fsa@n}
+% FSA next action. This is just a placeholder definition.
+% \begin{macrocode}
+\let\fsa@n\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fsa@t}
+% FSA test. This is just a placeholder definition.
+% \begin{macrocode}
+\let\fsa@t\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Now some of the real work}
+%
+% \begin{macro}{\rsk@toks}
+% \begin{macrocode}
+\newtoks\rsk@toks
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rkvIfEmpty}
+% Beginning here.
+% \begin{macrocode}
+\def\rkvIfEmpty#1#2{%
+ \@xp\ifx\csname#1'#2\endcsname\@empty
+ \@xp\@firstoftwo
+ \else
+ \@xp\@secondoftwo
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rkvIfAdditive}
+% \begin{macrocode}
+\def\rkvIfAdditive#1{%
+ \@xp\let\@xp\@let@token \csname \rkv@setter#1\endcsname
+ \afterassignment\@nilgobble
+ \@xp\let\@xp\@let@token \@let@token \@empty\@empty\@nil
+ \ifx\@let@token\DSK@append
+ \@xp\@firstoftwo
+ \else
+ \@xp\@secondoftwo
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rkv@setter}
+% It irritates me that I can't embed the \ncn{csname} and
+% \ncn{endcsname} in here.
+% \begin{macrocode}
+\def\rkv@setter#1{set:\@xp\@gobble\string#1}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rkv@DSAK}
+% Define a simple, superseding, or additive key.
+% \begin{macrocode}
+\def\rkv@DSAK#1#2{%
+ \addto@group@reset#1{\let#1\@empty}%
+ \edef\@tempa{\def\csname \rkv@setter#1\endcsname}%
+ \@tempa{#2#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rkv@DDK}
+% This function is used for a dummy key whose value (expansion)
+% should be empty but that should appear non-empty to
+% \cs{rkvIfEmpty}.
+% \begin{macrocode}
+\def\rkv@DDK#1{%
+ \addto@group@reset#1{\def#1{\@empty}}%
+ \@xp\let\csname \rkv@setter#1\endcsname\@gobble
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DSK@def}
+% \begin{macrocode}
+\def\DSK@def#1{%
+ \ifx#1\@empty\else
+ \PackageWarningNoLine{rkeyval}%
+ {Key \string#1 should not be repeated}%
+ \fi
+ \DSK@redef#1%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DSK@redef}
+% We weed out empty field values for consistency with
+% \cs{DSK@append}.
+% \begin{macrocode}
+\def\DSK@redef#1#2{%
+ \@ifempty{#2}{\@gobble}{%
+ \def#1{#2}%
+ \set@property#1
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\init@group@reset}
+% \begin{macrocode}
+\def\init@group@reset#1{%
+ \begingroup
+ \edef\@tempb{\@xp\@nx\csname #1@reset\endcsname}%
+ \@xp\ifx\@tempb\relax
+ \@xp\xdef\@tempb{\let \csname #1,aux\endcsname\@nx\@empty}
+ \fi
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\addto@group@reset}
+% \begin{macrocode}
+\def\addto@group@reset#1{%
+ \begingroup
+ \edef\@tempa{\extract@group#1}%
+ \init@group@reset\@tempa
+ \edef\@tempa{%
+ \@nx\g@addto@macro\@xp\@nx\csname\@tempa @reset\endcsname
+ }%
+ \@xp\endgroup
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DefineSimpleKey}
+% \begin{macrocode}
+\newcommand{\DefineSimpleKey}[2]{%
+ \@xp\rkv@DSAK
+ \csname #1'#2\endcsname
+ {\DSK@def}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DefineSupersedingKey}
+% \begin{macrocode}
+\newcommand{\DefineSupersedingKey}[2]{%
+ \@xp\rkv@DSAK
+ \csname #1'#2\endcsname
+ {\DSK@redef}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DefineAdditiveKey}
+% \begin{macrocode}
+\newcommand{\DefineAdditiveKey}[3]{%
+ \@xp\rkv@DSAK
+ \csname #1'#2\endcsname
+ {\DSK@append#3}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DSK@append}
+% We weed out empty field values (e.g., |editor={}| or
+% \verb*|editor={ }|) because otherwise an additive field could
+% end up with a value like |\name{}| which appears non-empty to
+% \cs{rkvIfEmpty} but produces no output on the page.
+% \begin{macrocode}
+\def\DSK@append#1#2#3{%
+ \@ifempty{#3}{\@gobble}{%
+ \@append#1#2{#3}%
+ \set@property#2
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DefineDummyKey}
+% \begin{macrocode}
+\newcommand{\DefineDummyKey}[2]{%
+ \@xp\rkv@DDK \csname #1'#2\endcsname
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\RestrictedSetKeys}
+% \begin{macrocode}
+\newcommand{\RestrictedSetKeys}[3]{%
+ \global\rsk@toks\@xp{\csname #2@reset\endcsname}%
+ \def\rsk@finish{#3}%
+ \gdef\rsk@set{\@xp\rsk@set@a\csname#2'}%
+ #1\relax
+ \begingroup
+ \rsk@changecase
+ \aftergroup\rsk@set
+% \end{macrocode}
+% Start by removing the opening brace.
+% \begin{macrocode}
+ \let\fsa@t\rsk@z
+ \fsa@l
+}
+% \end{macrocode}
+% \end{macro}
+%
+% The aftergroup tokens end up looking like this:
+% \begin{verbatim}
+% \lowercase{\rsk@set FIELDNAME\endcsname}
+% --> \@xp\rsk@set@a\csname bib'fieldname\endcsname
+% --> \rsk@set@a\bib'abcdef
+%\end{verbatim}
+%
+% \begin{macro}{\rsk@unknown@key}
+% \begin{macrocode}
+\def\rsk@unknown@key#1{%
+ \PackageWarning{rkeyval}{Unknown key: \string#1}%
+ \@xp\def\csname\rkv@setter#1\endcsname {\DSK@redef#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{The state machine}
+%
+%\begin{verbatim}
+% State 0: Skip opening brace (\rsk@z).
+% space -> 0
+% { -> 2
+% other -> error "Missing open brace"
+%
+% State 1: Skip comma (\rsk@a).
+% space -> 1
+% \par -> 1
+% comma -> 2
+% @ -> read optional arg; 1
+% } -> 6
+% other -> error "Missing comma"; 2
+%
+% State 2: Find field name (\rsk@b).
+% space -> 2
+% \par -> 2
+% comma -> 2
+% letter -> 3
+% { -> error "Missing key name"; 4
+% } -> 6
+% other -> error "Invalid key name character"; 2
+%
+% State 3: Scan field name (\rsk@c).
+% letter -> 3
+% comma -> error "Invalid key name character"; 3
+% equal -> 4
+% other punct -> 3
+% space -> 4
+% { -> error "Missing equal sign"; 4
+% } -> error "Missing equal sign"; 4
+% other -> error "Invalid key name character"; 3
+%
+% State 4: Skip equals (\rsk@d).
+% space -> 4
+% equal -> 4
+% { -> 5
+% other -> error "Missing { for value of current key"; 5
+%
+% State 5: Read field value (\rsk@set@a).
+% any -> 1
+%
+% State 6: Done (\rsk@end).
+%\end{verbatim}
+%
+% \begin{macro}{\rsk@z}
+% State 0: Skip opening brace.
+% \begin{macrocode}
+\def\rsk@z{%
+ \ifx\bgroup\@let@token
+ \let\fsa@t\rsk@b
+ \let\fsa@n\fsa@b
+ \else
+ \ifx\@sptoken\@let@token
+ \let\fsa@n\fsa@b
+ \else
+ \rsk@errf
+ \fi
+ \fi
+ \fsa@n
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@a}
+% State 1: Skip comma.
+% \begin{macrocode}
+\def\rsk@a{%
+ \ifx\@let@token\@sptoken
+ \let\fsa@n\fsa@b
+ \else
+ \ifx\@let@token\par
+ \let\fsa@n\fsa@b
+ \else
+ \ifx,\@let@token
+ \endgroup
+ \let\fsa@t\rsk@b
+ \let\fsa@n\fsa@b
+ \else
+ \ifx\egroup\@let@token
+ \endgroup
+ \let\fsa@n\rsk@end
+ \else
+ \endgroup
+ \let\fsa@n\rsk@erraa
+ \fi
+ \fi
+ \fi
+ \fi
+ \fsa@n
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@b}
+% State 2: Find field name.
+%
+% Allow \cs{par} here to permit a blank line after
+% the end of one key-val pair and the start of the next (perhaps to
+% break up a long list into sections).
+% \begin{macrocode}
+\def\rsk@b{%
+ \ifcat\@nx\@let@token A%
+ \let\fsa@t\rsk@c
+ \let\fsa@n\fsa@c
+ \else
+ \ifx\@sptoken\@let@token
+ \let\fsa@n\fsa@b
+ \else
+ \rsk@bb
+ \fi
+ \fi
+ \fsa@n
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@bb}
+% \begin{macrocode}
+\def\rsk@bb{%
+ \ifx,\@let@token
+ \let\fsa@n\fsa@b
+ \else
+ \ifx\bgroup\@let@token
+ \let\fsa@n\rsk@errb
+ \else
+ \ifx\egroup\@let@token
+ \let\fsa@n\rsk@end
+ \else
+ \ifx\par\@let@token
+ \let\fsa@n\fsa@b
+ \else
+ \let\fsa@n\rsk@errc
+ \fi
+ \fi
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@c}
+% State 3: Scan field name.
+% \begin{macrocode}
+\def\rsk@c{%
+ \ifcat\@nx\@let@token A%
+ \let\fsa@n\fsa@c
+ \else
+ \ifx\@sptoken\@let@token
+ \let\fsa@t\rsk@d
+ \let\fsa@n\fsa@b
+ \else
+ \ifx=\@let@token
+ \let\saw@equal T%
+ \let\fsa@t\rsk@d
+ \let\fsa@n\fsa@b
+ \else
+ \rsk@cb
+ \fi
+ \fi
+ \fi
+ \fsa@n
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@cb}
+% \begin{macrocode}
+\def\rsk@cb{%
+ \ifx,\@let@token
+ \let\fsa@n\rsk@errc
+ \else
+ \ifcat\@nx\@let@token .%
+ \let\fsa@n\fsa@c
+ \else
+ \ifx\bgroup\@let@token
+ \let\fsa@n\rsk@noequal
+ \else
+ \ifx\egroup\@let@token
+ \let\fsa@n\rsk@noequal
+ \else
+ \let\fsa@n\rsk@errc
+ \fi
+ \fi
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\saw@equal}
+% \begin{macrocode}
+\let\saw@equal=F
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@d}
+% State 4: Skip equals.
+%
+% If no equal sign ever came
+% along, then give a warning about it and set \cs{saw@equal} to true
+% so that when \cs{rsk@noequal} cycles through again it will take the
+% other branch.
+% \begin{macrocode}
+\def\rsk@d{%
+ \ifx\bgroup\@let@token
+ \ifx\saw@equal T%
+ \aftergroup\endcsname
+ \rsk@endcase
+ \let\fsa@n\endgroup
+ \else
+ \let\saw@equal T%
+ \let\fsa@n\rsk@noequal
+ \fi
+ \else
+ \ifx\@sptoken\@let@token
+ \let\fsa@n\fsa@b
+ \else
+ \ifx=\@let@token
+ \let\saw@equal T%
+ \let\fsa@n\fsa@b
+ \else
+ \let\fsa@n\rsk@erre
+ \fi
+ \fi
+ \fi
+ \fsa@n
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@casesensitive}
+% \begin{macrocode}
+\def\rsk@casesensitive{%
+ \let\rsk@changecase\@empty
+ \let\rsk@endcase\@empty
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@startlc}
+% \begin{macrocode}
+\def\rsk@startlc{\aftergroup\lowercase\aftergroup{\iffalse}\fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@endlc}
+% \begin{macrocode}
+\def\rsk@endlc{\iffalse{\fi\aftergroup}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@lowercase}
+% \begin{macrocode}
+\def\rsk@lowercase{%
+ \let\rsk@changecase\rsk@startlc
+ \let\rsk@endcase\rsk@endlc
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\rsk@lowercase
+% \end{macrocode}
+%
+% \begin{macro}{\rsk@resume}
+% Here we get improved reporting of error context by changing
+% end-of-line to be different from normal space. If we don't find a
+% comma on the current line, assume it is an error.
+% \begin{macrocode}
+\def\rsk@resume{%
+ \begingroup
+ \rsk@changecase
+ \aftergroup\rsk@set
+ \let\fsa@t\rsk@a
+ \begingroup
+ \catcode\endlinechar=\active
+ \lccode`\~=\endlinechar
+ \lowercase{\let~\par}%
+ \fsa@l
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@set@a}
+% State 5: Read field value.
+% \begin{macrocode}
+\def\rsk@set@a#1#2{%
+ \star@{\rsk@set@b#1{#2}}{}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@set@b}
+% \begin{macrocode}
+\def\rsk@set@b#1#2#3{%
+ \@xp\ifx \csname\rkv@setter#1\endcsname \relax
+ \rsk@unknown@key#1%
+ \fi
+ \edef\@tempa{\@xp\@nx\csname \rkv@setter#1\endcsname}%
+ \toks@\@xp{\@tempa{#2}{#3}}%
+ \edef\@tempa{%
+ \global\rsk@toks{\the\rsk@toks \the\toks@}%
+ }%
+ \@tempa
+ \rsk@resume
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@end}
+% State 6: Done.
+%
+% Lets see, now why did I add this?
+% \begin{macrocode}
+\def\rsk@end{%
+ \global\let\rsk@set\rsk@terminate
+ \rsk@endcase
+ \endgroup
+ \endcsname
+ \afterassignment\rsk@finish
+ \toks@\bgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@terminate}
+% \begin{macrocode}
+\def\rsk@terminate{\@xp\@gobble\csname}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NoCommaWarning}
+% \begin{macrocode}
+\def\NoCommaWarning{\PackageWarning{rkeyval}{Missing comma}}%
+% \end{macrocode}
+% \end{macro}
+%
+%% % \begin{macro}{\NoCommaError}
+%% % \begin{macrocode}
+%% \def\NoCommaError{\rsk@err{Missing comma}\@ehc}
+%% % \end{macrocode}
+%% % \end{macro}
+%
+% \begin{macro}{\rsk@nocomma}
+% \begin{macrocode}
+\def\rsk@nocomma{\NoCommaWarning}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@err}
+% \begin{macrocode}
+\def\rsk@err{\PackageError{rkeyval}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@errf}
+% \begin{macrocode}
+\def\rsk@errf{\rsk@err{Missing open brace}\@ehc\rsk@b}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@erraa}
+% \begin{macrocode}
+\long\def\rsk@erraa{\rsk@nocomma \let\fsa@t\rsk@b \fsa@l}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@errb}
+% \begin{macrocode}
+\def\rsk@errb{\rsk@err{Missing key name}\@ehc\rsk@d}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@errc}
+% \begin{macrocode}
+\def\rsk@errc{\rsk@err{Invalid key name character}\@ehc\fsa@b}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\rsk@noequal}
+% \begin{macrocode}
+\def\rsk@noequal{\rsk@err{Missing equal sign}\@ehc\rsk@d}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\rsk@erre}
+% In this case we guess that the value is without braces but probably
+% terminated with a comma. We want to scan up to the comma in order
+% to get back in synch.
+% \begin{macrocode}
+\def\rsk@erre#1,{%
+ \rsk@err{Missing open brace for key value}\@ehc
+ \iffalse{\fi
+ \endgroup
+ \endcsname
+ \rsk@endcase }{#1},%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\PopCatcodes
+% \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}
+%
+% \CheckSum{871}
+% \Finale
diff --git a/Master/texmf-dist/source/latex/amslatex/textcmds.dtx b/Master/texmf-dist/source/latex/amslatex/textcmds.dtx
new file mode 100644
index 00000000000..cbd82171c0a
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/textcmds.dtx
@@ -0,0 +1,283 @@
+%%% ====================================================================
+%%% @LaTeX-doc-source-file{
+%%% filename = "textcmds.dtx",
+%%% version = "1.05",
+%%% date = "2002/04/16",
+%%% time = "08:47:47 EDT",
+%%% author = "Michael J Downes",
+%%% address = "American Mathematical Society,
+%%% Publications Technical Group,
+%%% PO Box 6248,
+%%% Providence, RI 02940,
+%%% USA",
+%%% email = "tech-support@ams.org",
+%%% URL = "http://www.ams.org/",
+%%% abstract = "Short forms for textemdash and the other LaTeX
+%%% commands that correspond to ligatures of
+%%% convenience.",
+%%% checksum = "55773 283 1136 10227",
+%%% docstring = "The checksum field, produced by Robert Solovay's
+%%% checksum utility, gives CRC-16 checksum, lines,
+%%% words, and characters.",
+%%% }
+%%% ====================================================================
+% \iffalse
+%<*driver>
+\NeedsTeXFormat{LaTeX2e}
+\documentclass{amsdtx}
+% Undo some things defined by amsdtx.cls
+\let\qq=\UnDefined \let\mdash=\UnDefined \let\ndash=\UnDefined
+\usepackage{textcmds}
+\begin{document}
+\title{The \pkg{textcmds} package}
+\author{Michael~J. Downes\\American Mathematical Society}
+\date{Version \fileversion, \filedate}
+\hDocInput{textcmds.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \maketitle
+% \section{Introduction}
+%
+% The \pkg{textcmds} package provides shorthand commands for all the
+% text symbols that are traditionally produced in \LaTeX{} documents
+% by non-letter ligatures. One of the principal benefits of using
+% these commands is that it makes translating your document from
+% \LaTeX{} to some other form (e.g., HTML) easier and less bug-prone.
+% But it also makes your document less dependent on the use of
+% special font metric files having the required ligature information,
+% and it makes it far easier to achieve special effects for the
+%^^A Either don't use \mdash here, or add textcmds pkg in the driver.
+% characters in question\textemdash for example, to add or not to add
+% a small amount of extra space around an em-dash character. With the
+% ligature method you have to manually add the space for each
+% instance, whereas if you use the \verb'\mdash' command, it suffices
+% to change the definition of \verb'\mdash' to suit your wishes.
+%
+% All of these definitions use the preferred
+% font-encoding-independent \LaTeX{} commands to obtain the
+% characters in question.
+% \begin{center}
+% \begin{tabular}{lll}
+% \textbf{Command}& \textbf{Definition}& \textbf{Result}\\
+% \cn{mdash}& \cn{textemdash}& \mdash\\
+% \cn{ndash}& \cn{textendash}& \ndash\\
+% \cn{qd}& \cn{textquestiondown}& \qd\\
+% \cn{xd}& \cn{textexclamdown}& \xd\\
+% \cn{ldq}& \cn{textquotedblleft}& \ldq\\
+% \cn{rdq}& \cn{textquotedblright}& \rdq\\
+% \cn{lq}& \cn{textquoteleft}& \lq\\
+% \cn{rq}& \cn{textquoteright}& \rq
+% \end{tabular}
+% \end{center}
+%
+% This package also provides short forms for certain text
+% symbols whose generic name is too long for convenient entry.
+% (The \cn{cwm} command does not produce visible output but marks
+% word boundaries in a compound word.)
+% \begin{center}
+% \begin{tabular}{lll}
+% \textbf{Command}& \textbf{Definition}& \textbf{Result}\\
+% \cn{bul}& \cn{textbullet}& \bul\\
+% \cn{vsp}& \cn{textvisiblespace}& \vsp\\
+% \cn{pdc}& \cn{textperiodcentered}& \pdc\\
+% \cn{vrt}& \cn{textbar}& \vrt\\
+% \cn{cir}& \cn{textasciicircum}& \cir\\
+% \cn{til}& \cn{textasciitilde}& \til\\
+% \cn{bsl}& \cn{textbackslash}& \bsl\\
+% \cn{cwm}& \cn{textcompwordmark}& \cwm
+% \end{tabular}
+% \end{center}
+%
+% Finally, a few other miscellaneous commands are provided, including
+% a quoting command \cn{qq}. It seems clearly consonant with other
+% parts of \LaTeX{} to write \verb'\qq{...}' to quote a word or short
+% phrase rather than \verb'\ldq ...\rdq'; and the use of higher-level
+% markup is groundwork that must be laid if one should ever want to
+% do anything more sophisticated at the boundaries of a quoted
+% expression (such as automatically transposing the quote character
+% with following punctuation, if traditional rather than logical
+% punctuation style is desired).
+%
+% \begin{center}
+% \begin{tabular}{lll}
+% \textbf{Example}& \textbf{Definition}& \textbf{Result}\\
+% \verb'\qq{some text}'& \verb'\ldq#1\rdq'& \qq{some text}\\
+% \verb'\lara{some text}'& \verb'\textlangle#1\textrangle'&
+% \lara{some text}\\
+% \verb'Jello\tsup{TM}'& \textit{raise .9ex}\verb'{\supsize#1}'&
+% Jello\tsup{TM}\\
+% \verb'Jello\tsub{TM}'& \textit{lower .6ex}\verb'{\supsize#1}'&
+% Jello\tsub{TM}\\
+% \verb'a\tprime b'& \verb'\tsup{\textprimechar}'&
+% a\tprime b
+% \end{tabular}
+% \end{center}
+%
+% \StopEventually{}
+%
+% \begin{macrocode}
+%<*pkg>
+% \end{macrocode}
+%
+% \section{Implementation}
+%
+% Package name, date, version number.
+% \begin{macrocode}
+\ProvidesPackage{textcmds}[2002/04/16 v1.05]
+% \end{macrocode}
+%
+% Dashes and inverted beginning-of-sentence punctuation.
+% \begin{macrocode}
+\providecommand{\mdash}{\textemdash\penalty\exhyphenpenalty}
+\providecommand{\ndash}{\textendash\penalty\exhyphenpenalty}
+\newcommand{\qd}{\textquestiondown}
+\newcommand{\xd}{\textexclamdown}
+% \end{macrocode}
+%
+% Quote commands. Note that \cs{lq} and \cs{rq} are defined in the
+% \LaTeX{} kernel to produce functionally different quote characters.
+% \begin{macrocode}
+\newcommand{\ldq}{\textquotedblleft}
+\newcommand{\rdq}{\textquotedblright}
+\newcommand{\lsq}{\textquoteleft}
+\newcommand{\rsq}{\textquoteright}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newcommand{\bul}{\textbullet}%
+\newcommand{\vsp}{\textvisiblespace}%
+\newcommand{\pdc}{\textperiodcentered}%
+\newcommand{\vrt}{\textbar}%
+\newcommand{\cir}{\textasciicircum}%
+\newcommand{\til}{\textasciitilde}%
+\newcommand{\bsl}{\textbackslash}%
+\newcommand{\cwm}{\textcompwordmark}%
+% \end{macrocode}
+%
+% \begin{macrocode}
+\providecommand{\qq}[1]{\ldq#1\/\rdq}
+% \end{macrocode}
+%
+% Unlike \cs{textsuperscript} and \cs{textsubscript}, these do not
+% use math mode at all. The difference between \cn{scriptsize} and
+% \cn{supsize} is that the former is fixed at a single constant size
+% regardless of context, whereas the latter adapts to the current
+% font size.
+% \begin{macrocode}
+\newcommand{\supsize}{%
+% \end{macrocode}
+% Cf \cs{glb@settings}.
+% \begin{macrocode}
+ \expandafter\ifx\csname S@\f@size\endcsname\relax
+ \calculate@math@sizes
+ \fi
+ \csname S@\f@size\endcsname
+ \fontsize\sf@size\z@\selectfont
+}
+\DeclareRobustCommand{\tsup}[1]{%
+ \leavevmode\raise.9ex\hbox{\supsize #1}%
+}
+\DeclareRobustCommand{\tsub}[1]{%
+ \leavevmode\lower.6ex\hbox{\supsize #1}%
+}
+% \end{macrocode}
+%
+% The \LaTeX{} kernel contains fallback definitions for various
+% symbols that traditionally came from the \texttt{cmsy} font:
+%\begin{verbatim}
+%\DeclareTextSymbolDefault{\textbraceleft}{OMS}
+%\end{verbatim}
+% But there is no definition of that kind for the cmsy prime
+% character that we want to use for \cn{tprime}. So we need to do it
+% here.
+% \begin{macrocode}
+\DeclareTextSymbolDefault{\textprimechar}{OMS}
+\DeclareTextSymbol{\textprimechar}{OMS}{48}
+\DeclareRobustCommand{\tprime}{\tsup{\textprimechar}}
+% \end{macrocode}
+%
+% And one more pair of symbols that are sometimes useful in text, yet
+% do not have suitable text definitions in the \LaTeX{} kernel. (They
+% do in the \pkg{textcomp} package.)
+%
+% If the \pkg{textcmds} package is loaded together with the
+% \pkg{textcomp} package, we don't want to clobber the TS1 default.
+% \begin{macrocode}
+\@ifundefined{textlangle}{%
+ \DeclareTextSymbolDefault{\textlangle}{OMS}
+ \DeclareTextSymbolDefault{\textrangle}{OMS}
+}{}
+\DeclareTextSymbol{\textlangle}{OMS}{"68}
+\DeclareTextSymbol{\textrangle}{OMS}{"69}
+% \end{macrocode}
+% Not sure what's the best name for the angle-brackets analog of the
+% \cn{qq} command. How about ``lara'' for ``left-angle right-angle''?
+%
+% Unlike the quotes case, it is highly unlikely that the font
+% contains kern information for the rangle character and the
+% character preceding it! So let's put in an italic correction.
+% \begin{macrocode}
+\DeclareRobustCommand{\lara}[1]{\textlangle#1\/\textrangle}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\csname endinput\endcsname
+%</pkg>
+% \end{macrocode}
+%
+% Do you want some Emacs code to convert \verb"--" to \cn{ndash} while
+% you write? And \verb"``" to \verb'\qq{' ? Try this.
+% \begin{macrocode}
+<*emacs>
+(defvar latex-ndash-command "\\ndash"
+ "*String to insert for an n-dash in LaTeX mode.")
+
+(defvar latex-mdash-command "\\mdash"
+ "*String to insert for an m-dash in LaTeX mode.")
+
+(defvar latex-quote-command "\\qq"
+ "*String to insert for quotes in LaTeX mode.")
+
+(defun latex-maybe-start-quotes (arg)
+ "Insert the beginning of a \\qq{...} structure if the preceding char is
+a left quote."
+ (interactive "*p")
+ (if (= (preceding-char) ?\`)
+ (progn
+ (delete-backward-char 1)
+ (insert-and-inherit (concat latex-quote-command "\{")))
+ (self-insert-command arg)))
+
+(defun latex-maybe-end-quotes (arg)
+ "Insert the end of a \\qq{...} structure if appropriate."
+ (interactive "*p")
+ (if (= (preceding-char) ?\')
+ (progn
+ (delete-backward-char 1)
+ (insert-and-inherit "\}"))
+ (self-insert-command arg)))
+
+(defun latex-maybe-dash (arg)
+ "Convert two or three hyphens to \\mdash or \\ndash."
+ (interactive "*p")
+ (cond
+ ((re-search-backward
+ (concat (regexp-quote latex-ndash-command) " *\\=") nil t)
+ (replace-match (concat (regexp-quote latex-mdash-command) " ")))
+ ((= (preceding-char) ?-)
+ (delete-backward-char 1)
+ (insert-and-inherit (concat latex-ndash-command " ")))
+ (t (self-insert-command arg))))
+
+(add-hook 'TeX-mode-hook
+ '(lambda
+ (define-key LaTeX-mode-map "\`" 'latex-maybe-start-quotes)
+ (define-key LaTeX-mode-map "\'" 'latex-maybe-end-quotes)
+ (define-key LaTeX-mode-map "-" 'latex-maybe-dash)))
+</emacs>
+% \end{macrocode}
+%
+% \CheckSum{133}
+% \Finale
diff --git a/Master/texmf-dist/source/latex/amslatex/upref.dtx b/Master/texmf-dist/source/latex/amslatex/upref.dtx
new file mode 100644
index 00000000000..843126b3b58
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amslatex/upref.dtx
@@ -0,0 +1,151 @@
+%%% ====================================================================
+%%% @LaTeX-file{
+%%% filename = "upref.dtx",
+%%% version = "2.01",
+%%% date = "2004/07/29",
+%%% time = "16:37:01 EDT",
+%%% checksum = "07926 151 617 5530",
+%%% author = "American Mathematical Society",
+%%% copyright = "Copyright 1996 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.",
+%%% 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",
+%%% email = "tech-support@ams.org (Internet)",
+%%% codetable = "ISO/ASCII",
+%%% keywords = "latex, amslatex, ams-latex, cross references",
+%%% supported = "yes",
+%%% abstract = "This is a LaTeX package that provides printing
+%%% of \cn{ref}s in an upright font even if the
+%%% current context is italic or slanted.",
+%%% 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
+%<*driver>
+\documentclass{amsdtx}
+\begin{document}
+\title{The \pkg{upref} package}
+\author{American Mathematical Society\\ Michael Downes\\
+ updated by Barbara Beeton}
+\date{Version \fileversion, \filedate}
+\hDocInput{upref.dtx}
+\end{document}
+%</driver>
+%\fi
+%
+% \maketitle
+%
+% \MakeShortVerb\|
+%
+% \section{Introduction}
+%
+% This package changes the \cn{ref} command so that it never applies
+% a slanted font shape to its argument, regardless of context. This
+% was the default behavior in \cls{amsart} version 1.1. Starting with
+% \cls{amsart} version 1.2, upright references must be obtained via
+% |\usepackage{upref}|.
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+% Give package name, date, version.
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}[1995/06/01]
+\ProvidesPackage{upref}[2004/07/29 v2.01]
+% \end{macrocode}
+%
+% \begin{macro}{\@noref}
+% Give a warning if a cited reference isn't defined.
+% \begin{macrocode}
+\newcommand{\@noref}[1]{%
+ \G@refundefinedtrue
+ \nfss@text{\reset@font\bfseries ??}%
+ \@latex@warning{Reference `#1' on page \thepage\space undefined}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@setref}
+% If the current fontshape is italic or slanted, we want to switch to
+% upright/roman for printing the number of a \cn{ref}. This requires
+% changing the \cs{@setref} command.
+%
+% Since \cs{@setref} is modified by the \pkg{hyperref} package, delay
+% the definition until \cs{AtBeginDocument}. Then check whether
+% \pkg{hyperref} is loaded. If it is, we have to redefine some
+% control sequences that \pkg{hyperref} defined in order to get
+% upright references even in a \pkg{hyperref} environment.
+% [tjk,bnb, 2004/07/29]
+% \begin{macrocode}
+\AtBeginDocument{%
+ \@ifpackageloaded{hyperref}{%
+% \end{macrocode}
+% We overload \cs{Hy@setref@link} as this is where the upright
+% references get clobbered. Used in overloaded \cs{@setref}.
+% \begin{macrocode}
+ \def\Hy@setref@link#1#2#3#4#5#6\@nil#7{%
+ \begingroup
+ \toks0{\hyper@@link{#5}{#4}}%
+ \toks1\@xp{#7{\textup{#1}\hbox{}}{#2}{#3}{#4}{#5}}%
+ \edef\x{\endgroup\the\toks0{\the\toks1}}\x
+ }%
+% \end{macrocode}
+% We should not have to overload \cs{@setref}, but there is
+% a chance that an author is using an old version of hyperref
+% which does not use \cs{Hy@setref@link} in \cs{@setref}.
+% \begin{macrocode}
+ \def\@setref#1#2#3{%
+ \ifx#1\relax
+ \@xp\protect\@noref{#3}%
+ \else
+ \@xp\Hy@setref@link#1\@empty\@empty\@nil{#2}%
+ \fi
+ }%
+ }{%
+ \def\@setref#1#2#3{\ifx#1\relax
+ \protect\@noref{#3}%
+ \else
+ \protect\textup{\@xp#2#1\hbox{}}%
+ \fi
+ }%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@upn}
+% The function \cs{\@upn} is used to force theorem numbers and
+% similar elements to be upright in sloped or italic contexts.
+% If a suitable italic font with upright numbers and punctuation is
+% available, this function should be redefined to be a no-op.
+% \begin{macrocode}
+\providecommand\@upn{\textup}
+% \end{macrocode}
+% \end{macro}
+%
+% 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}
+%
+% \CheckSum{61}
+% \Finale