summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/amsrefs
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-08-27 18:26:20 +0000
committerKarl Berry <karl@freefriends.org>2006-08-27 18:26:20 +0000
commita8e899a92e2ac03c70c878f363128748808f8135 (patch)
tree4383fc3cf704e59d1dcd9a164aba9ab5ba5de9aa /Master/texmf-dist/source/latex/amsrefs
parent7c55de4fbb8a3fd98697b47aa5500a56a590f2c0 (diff)
amslatex package amsrefs update from latex-tds (27aug06)
git-svn-id: svn://tug.org/texlive/trunk@2051 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/amsrefs')
-rw-r--r--Master/texmf-dist/source/latex/amsrefs/00readme.txt143
-rw-r--r--Master/texmf-dist/source/latex/amsrefs/ams-r1.ins43
-rw-r--r--Master/texmf-dist/source/latex/amsrefs/amsrefs.dtx8030
-rw-r--r--Master/texmf-dist/source/latex/amsrefs/amsxport.dtx1822
-rw-r--r--Master/texmf-dist/source/latex/amsrefs/ifoption.dtx170
-rw-r--r--Master/texmf-dist/source/latex/amsrefs/install.txt69
-rw-r--r--Master/texmf-dist/source/latex/amsrefs/manifest.txt56
-rw-r--r--Master/texmf-dist/source/latex/amsrefs/mathscinet.dtx595
-rw-r--r--Master/texmf-dist/source/latex/amsrefs/pcatcode.dtx359
-rw-r--r--Master/texmf-dist/source/latex/amsrefs/rkeyval.dtx1116
-rw-r--r--Master/texmf-dist/source/latex/amsrefs/textcmds.dtx283
11 files changed, 12686 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/amsrefs/00readme.txt b/Master/texmf-dist/source/latex/amsrefs/00readme.txt
new file mode 100644
index 00000000000..0dec0fb6419
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amsrefs/00readme.txt
@@ -0,0 +1,143 @@
+00readme.txt for amsrefs 2.0 [2004-06-30]
+
+See also install.txt and manifest.txt. There is a history of changes at
+the end of this file.
+
+Please send bug reports and questions to tech-support@ams.org.
+
+========================================================================
+
+The amsrefs package deals with bibliographies and citations in LaTeX
+documents. The basic citation command remains more or less the same as
+in standard LaTeX (\cite), but a number of additional variations address
+certain known pitfalls or gaps in the standard LaTeX set of citation
+features.
+
+The command for bibliography items is different---\bib instead of
+\bibitem---for reasons that will be evident upon further reading in the
+documentation.
+
+A set of BibTeX style files are provided to allow people to extract
+data from .bib files and produce .bbl files in amsrefs format instead
+of conventional \bibitem format.
+
+User documentation is in amsrdoc.pdf.
+
+Technical documentation (including documentation for package writers)
+is in amsrefs.pdf.
+
+========================================================================
+I. FEATURES
+
+---Preservation of structure.
+
+The internal structural information of the bibliography entries is not
+lost when they are imported from the database file into the LaTeX
+document. This takes on its greatest significance when archiving
+documents in LaTeX form or transmitting them to another user (such as a
+publisher).
+
+---Deferred formatting.
+
+This means that the style of the bibliography can be changed on demand
+without reimporting everything from the original database(s).
+
+---More natural data format for titles.
+
+Proper nouns do not need to have braces added to prevent capitalization
+problems.
+
+---Less ambiguous format for author names.
+
+When author names are given in inverted order (last name first) it is
+possible for LaTeX to unambiguously identify the last name without any
+further markup, even in cases like Saunders Mac Lane (Mac Lane,
+Saunders) versus Stephen H. Lane (Lane, Stephen H.), or Cam Van Tran
+(Tran, Cam Van) versus Bert Van Keulen (Van Keulen, Bert). In
+BibTeX some of these would need to have extra braces added to ensure
+that the surname is accurately distinguished.
+
+---Author-year citations.
+
+There is integrated support for citations in author-year form.
+
+---Back-reference support.
+
+Works in conjunction with the hyperref package.
+
+---Setup requires only LaTeX knowledge.
+
+All bibliography setup can be done in LaTeX; learning another
+programming language (such as, the one used in BibTeX bst files) is
+unnecessary.
+
+---Self-printable database files.
+
+A LaTeX document that contains only a bibliography in amsrefs forms can
+be used as a database for exporting entries to other documents. And
+because it is a LaTeX document, the database can be printed directly at
+any time simply by running it through LaTeX in the usual way.
+
+---Self-contained.
+
+In many cases it seems possible to do without BibTeX entirely. For
+example, if the entries are extracted from a single database file that
+is maintained in sorted order, the bibliography can be printed directly
+by LaTeX on the first pass and the citations resolved on the second
+pass.
+
+========================================================================
+II. GETTING STARTED
+
+1. Install the package, referring to install.txt as needed.
+
+2. There are four example files provided:
+
+ cite-xa : Demonstrates an author-year citation scheme. The
+ bibliography is embedded in the .tex file instead of
+ residing in a separate .bbl file.
+
+ cite-xb : Demonstrates usage with more-or-less standard BibTeX
+ methods.
+
+ cite-xs : Shows how the bbl file can be created by LaTeX itself from a
+ suitably presorted ltb file.
+
+ cite-xh : A working hyperref/backrefs example.
+
+3. Run LaTeX on cite-xa.tex. Take a look at the messages that have to do
+with citations and the bibliography section. Run LaTeX again to resolve
+the citations and check the output.
+
+4. Run LaTeX on cite-xb.tex. Run BibTeX. Look at the bbl file.
+Interesting, huh? Run LaTeX twice more to resolve the citations.
+
+5. Run LaTeX on cite-xs.tex and look at the output.
+
+6. Run pdflatex on cite-xh.tex (it is set up to use BibTeX also, like
+cite-xb).
+
+========================================================================
+III. REMARKS ON THIS RELEASE
+
+This is a thorough overhaul and rewrite of the the amsrefs package.
+Many (perhaps even most) of the internals have changed and a number of
+new features have been added. Backwards compatibility for documents
+created with previous versions of this package has been
+
+See changes.pdf for information on the user-visible changes.
+
+========================================================================
+IV. SETTING UP A CUSTOM BIBLIOGRAPHY STYLE
+
+More documentation is needed here, but the discussion in amsrefs.pdf
+should be enough to get you started. See especially sections 4, 6.10,
+6.26.15, and 6.27.
+
+========================================================================
+V. CHANGE LOG
+
+*amsrefs.dtx 2.0 2004-06-30 11:24:39 EDT
+
+Major rewrite of internals. See changes.pdf for information on the
+user-visible changes.
diff --git a/Master/texmf-dist/source/latex/amsrefs/ams-r1.ins b/Master/texmf-dist/source/latex/amsrefs/ams-r1.ins
new file mode 100644
index 00000000000..c4a552ebcba
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amsrefs/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/amsrefs/amsrefs.dtx b/Master/texmf-dist/source/latex/amsrefs/amsrefs.dtx
new file mode 100644
index 00000000000..e8d81ed6336
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amsrefs/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/amsrefs/amsxport.dtx b/Master/texmf-dist/source/latex/amsrefs/amsxport.dtx
new file mode 100644
index 00000000000..308a8c2698c
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amsrefs/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/amsrefs/ifoption.dtx b/Master/texmf-dist/source/latex/amsrefs/ifoption.dtx
new file mode 100644
index 00000000000..4bb4670a72a
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amsrefs/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/amsrefs/install.txt b/Master/texmf-dist/source/latex/amsrefs/install.txt
new file mode 100644
index 00000000000..e03f5411a1e
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amsrefs/install.txt
@@ -0,0 +1,69 @@
+install.txt for amsrefs 2.0 [2004-06-30]
+
+Preliminary note: The normal destination directory for amsrefs.sty in a
+standard TDS structure would be texmf/tex/latex/amscls (see step 3
+below). In the future, the amsrefs package will be integrated more
+thoroughly into the amscls distribution, but the current release has to
+be provided in the form of a separate distribution for those who already
+have the amscls distrib but not amsrefs.
+
+------------------------------------------------------------------------
+The first step is to identify the primary location for LaTeX input files
+on your system. Typical examples are
+
+ /usr/local/share/texmf/tex/latex... (Unix)
+
+ C:\SWP30\TCITeX\TeX\LaTeX... (Windows)
+
+We define "ROOT" to mean everything preceding the "/tex/latex" part. In
+the second example, this would be "C:\SWP30\TCITeX". ROOT will normally
+end in "texmf"; if it doesn't you may need to consult the documentation
+for your TeX system to find out what to use. In the following
+instructions, wherever you see ROOT substitute the actual directory or
+folder name that is used on your system.
+
+If this terminology doesn't make sense to you, seek assistance from
+a friend or colleague, or from the company that you bought your TeX
+system from, or contact us at
+
+ tech-support@ams.org
+ 800-321-4AMS (321-4267) (USA/Canada)
+ 401-455-4080
+
+If you have multiple texmf trees (as discussed, for example, in the
+teTeX documentation), you may want to install amsrefs using the
+TEXMFLOCAL tree as the value of ROOT. In due course when you upgrade to
+a newer TeX system, we expect that you will find amsrefs already
+incorporated into the TEXMFMAIN tree as part of the tex/latex/amscls
+area, at which point you will no longer need the copy in your TEXMFLOCAL
+tree.
+
+------------------------------------------------------------------------
+1. Download the following archive file:
+
+ ftp://ftp.ams.org/pub/tex/amsrefs.zip
+
+2. Extract files using the texmf root directory as the destination. Some
+typical examples:
+
+WinZip: Click on "Extract" and then in the "Extract to" box, enter
+ c:\sw\texmf (or whatever ROOT is on your system)
+
+unzip: unzip amsrefs.zip -d ROOT
+
+3. Please note that although the source files for amsrefs unpack into
+the ROOT/source/latex/amsrefs area at the present time [2001-12-28], the
+other files unpack into .../latex/amscls because that is the natural
+location for them.
+
+To check the end result, you should find that you now have amsrefs.sty
+in the following location (substituting \ or : for / if appropriate):
+
+ ROOT/tex/latex/amscls/amsrefs.sty
+
+If you have a teTeX system you may need to rerun mktexlsr [known in
+earlier versions of teTeX as "texhash"].
+
+For a MikTeX system the command would be "initexmf -u", or look for
+"Refresh the Filename Database" in the MikTeX menus (this may be
+somewhat version-dependent).
diff --git a/Master/texmf-dist/source/latex/amsrefs/manifest.txt b/Master/texmf-dist/source/latex/amsrefs/manifest.txt
new file mode 100644
index 00000000000..ffeebfacf43
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amsrefs/manifest.txt
@@ -0,0 +1,56 @@
+
+texmf/bibtex/bst/ams/
+ amsra.bst
+ amsrn.bst
+ amsrs.bst
+ amsru.bst
+ amsry.bst
+
+texmf/doc/latex/amscls/
+ amsrdoc.pdf
+ amsrefs.faq
+ amsrefs.pdf
+ changes.pdf
+ cite-xa.tex
+ cite-xb.tex
+ cite-xh.tex
+ cite-xs.tex
+ gktest.ltb
+ jr.bib
+ mathscinet.pdf
+ textcmds.pdf
+
+texmf/source/latex/amsrefs/
+ 00readme.txt
+ ams-r1.ins
+ amsrdoc.pdf
+ amsrefs.dtx
+ amsrefs.faq
+ amsrefs.pdf
+ amsxport.dtx
+ changes.pdf
+ cite-xa.tex
+ cite-xb.tex
+ cite-xh.tex
+ cite-xs.tex
+ gktest.ltb
+ ifoption.dtx
+ install.txt
+ jr.bib
+ manifest.txt
+ mathscinet.dtx
+ mathscinet.pdf
+ pcatcode.dtx
+ rkeyval.dtx
+ textcmds.dtx
+ textcmds.pdf
+
+texmf/tex/latex/amscls/
+ amsrbeta.sty
+ amsrefs.sty
+ ifoption.sty
+ mathscinet.sty
+ pcatcode.sty
+ rkeyval.sty
+ rkvbeta.sty
+ textcmds.sty
diff --git a/Master/texmf-dist/source/latex/amsrefs/mathscinet.dtx b/Master/texmf-dist/source/latex/amsrefs/mathscinet.dtx
new file mode 100644
index 00000000000..78e01159ad6
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amsrefs/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/amsrefs/pcatcode.dtx b/Master/texmf-dist/source/latex/amsrefs/pcatcode.dtx
new file mode 100644
index 00000000000..192cb201871
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amsrefs/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/amsrefs/rkeyval.dtx b/Master/texmf-dist/source/latex/amsrefs/rkeyval.dtx
new file mode 100644
index 00000000000..88d4642df27
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amsrefs/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/amsrefs/textcmds.dtx b/Master/texmf-dist/source/latex/amsrefs/textcmds.dtx
new file mode 100644
index 00000000000..cbd82171c0a
--- /dev/null
+++ b/Master/texmf-dist/source/latex/amsrefs/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