summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/amsrefs
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/amsrefs
Initial commit
Diffstat (limited to 'macros/latex/contrib/amsrefs')
-rw-r--r--macros/latex/contrib/amsrefs/README347
-rw-r--r--macros/latex/contrib/amsrefs/amsrdoc.pdfbin0 -> 281056 bytes
-rw-r--r--macros/latex/contrib/amsrefs/amsrdoc.tex1867
-rw-r--r--macros/latex/contrib/amsrefs/amsrefs.dtx8389
-rw-r--r--macros/latex/contrib/amsrefs/amsrefs.faq68
-rw-r--r--macros/latex/contrib/amsrefs/amsrefs.ins76
-rw-r--r--macros/latex/contrib/amsrefs/amsrefs.pdfbin0 -> 545275 bytes
-rw-r--r--macros/latex/contrib/amsrefs/amsxport.dtx1814
-rw-r--r--macros/latex/contrib/amsrefs/amsxport.ins84
-rw-r--r--macros/latex/contrib/amsrefs/amsxport.pdfbin0 -> 269586 bytes
-rw-r--r--macros/latex/contrib/amsrefs/changes.pdfbin0 -> 170668 bytes
-rw-r--r--macros/latex/contrib/amsrefs/changes.tex519
-rw-r--r--macros/latex/contrib/amsrefs/cite-xa.tex253
-rw-r--r--macros/latex/contrib/amsrefs/cite-xb.tex130
-rw-r--r--macros/latex/contrib/amsrefs/cite-xh.tex143
-rw-r--r--macros/latex/contrib/amsrefs/cite-xs.tex51
-rw-r--r--macros/latex/contrib/amsrefs/gktest.ltb472
-rw-r--r--macros/latex/contrib/amsrefs/ifoption.dtx183
-rw-r--r--macros/latex/contrib/amsrefs/ifoption.ins75
-rw-r--r--macros/latex/contrib/amsrefs/ifoption.pdfbin0 -> 116906 bytes
-rw-r--r--macros/latex/contrib/amsrefs/install.txt88
-rw-r--r--macros/latex/contrib/amsrefs/jr.bib246
-rw-r--r--macros/latex/contrib/amsrefs/manifest.txt34
-rw-r--r--macros/latex/contrib/amsrefs/mathscinet.dtx607
-rw-r--r--macros/latex/contrib/amsrefs/mathscinet.ins77
-rw-r--r--macros/latex/contrib/amsrefs/mathscinet.pdfbin0 -> 197193 bytes
-rw-r--r--macros/latex/contrib/amsrefs/pcatcode.dtx368
-rw-r--r--macros/latex/contrib/amsrefs/pcatcode.ins77
-rw-r--r--macros/latex/contrib/amsrefs/pcatcode.pdfbin0 -> 125716 bytes
-rw-r--r--macros/latex/contrib/amsrefs/rkeyval.dtx1127
-rw-r--r--macros/latex/contrib/amsrefs/rkeyval.ins77
-rw-r--r--macros/latex/contrib/amsrefs/rkeyval.pdfbin0 -> 184933 bytes
-rw-r--r--macros/latex/contrib/amsrefs/textcmds.dtx300
-rw-r--r--macros/latex/contrib/amsrefs/textcmds.ins77
-rw-r--r--macros/latex/contrib/amsrefs/textcmds.pdfbin0 -> 177090 bytes
35 files changed, 17549 insertions, 0 deletions
diff --git a/macros/latex/contrib/amsrefs/README b/macros/latex/contrib/amsrefs/README
new file mode 100644
index 0000000000..920bd35056
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/README
@@ -0,0 +1,347 @@
+README for amsrefs 2.14 [2013/03/07]
+
+Copyright 2001-2004, 2007, 2008, 2010-2013 American Mathematical Society.
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either version 1.3c
+of this license or (at your option) any later version.
+The latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+and version 1.3c or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is the American Mathematical
+Society.
+
+American Mathematical Society
+Technical Support
+Publications Technical Group
+201 Charles Street
+Providence, RI 02904
+USA
+tel: (401) 455-4080
+ (800) 321-4267 (USA and Canada only)
+fax: (401) 331-3842
+email: tech-support@ams.org
+
+========================================================================
+ CONTENTS
+I. OVERVIEW
+II. FEATURES
+III. INSTALLATION AND GETTING STARTED
+IV. REMARKS ON THIS RELEASE
+V. CHANGE LOG
+
+========================================================================
+I. OVERVIEW
+
+The amsrefs package supports 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 and amsrefs.faq.
+
+Technical documentation (including documentation for package writers)
+is in amsrefs.pdf.
+
+========================================================================
+II. FEATURES
+
+-- Preservation of structure.
+
+With BibTeX alone, the structure of a bibitem in a .bib file is lost
+when items are imported into a .bbl file for direct processing by
+LaTeX. With amsrefs, there is no such conversion; LaTeX typesets the
+bibliography directly from the structured data. The greatest
+potential advantage of this is seen when archiving documents in LaTeX
+form or transmitting them to another user (such as a publisher).
+
+-- Deferred formatting.
+
+Since bibliography entries are stored in structured format in the
+LaTeX file and the formatting is under the control of a LaTeX package
+instead of a separate program, the style of the bibliography can be
+changed on demand without re-importing 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.
+
+========================================================================
+III. INSTALLATION AND 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).
+
+========================================================================
+IV. REMARKS ON THIS RELEASE
+
+Version 2.12 of amsrefs implements two new features for the biblist
+environment, one new entry type, one new warning, and one bug fix.
+
+New features: The biblist environment now takes an optional argument
+ consisting of an asterisk followed by a brace-delimited set of
+ key-value pairs. The currently supported keys are "labels," which
+ changes the label style of the current biblist, and "prefix,"
+ which adds a prefix to each label. For example, if you are using
+ numeric labels, then
+
+ \begin{biblist}*{prefix={A}}
+
+ will result in items labeled A1, A2, etc., instead of 1, 2, etc.
+
+ Similarly,
+
+ \begin{biblist}*{labels={alphabetic}}
+
+ will switch to alphabetic labels for the current bibliography.
+ Other allowable values are "numeric" and "shortalphabetic."
+
+ The biblist environment already takes a []-delimited optional
+ argument, so if you want to use both, the *-argument comes last:
+
+ \begin{biblist}[\normalsize]*{...}
+
+ NOTE: Use of non-numeric prefixes or of mixed numeric and
+ non-numeric label styles can interfere with the citation sorting
+ and compression features, depending on exactly how you arrange
+ your \cite's. You may need to pass the non-sorted-cites and
+ non-compressed-cites options to amsrefs to get the correct
+ behavior.
+
+New entry type: There is now a webpage entry designed for references
+ to online resources. It takes the following fields: accessdate,
+ author, date, note, subtitle, title, url.
+
+New warning: A common mistake when using non-numeric labels is to
+ place the bibliography items in an order that is incompatible with
+ the labels assigned by amsrefs. This can result in a sequence
+ such as this
+
+ [D] John Doe. ...
+ [DS] John Doe and Jane Smith. ...
+ [D] John Dunn. ...
+
+ where amsrefs does not automatically replace the first and third
+ labels by "D1" and "D2" as it would if they were consecutive.
+ This is because the real error lies in attempting to force the
+ labels into an unordered sequence. Readers are entitled to expect
+ that reference "D2" lies between references "D1" and "DS" in the
+ bibliography just as they are entitled to expect that reference
+ [2] lies between references [1] and [3].
+
+ If amsrefs encounters a situation like this, it will now issue a
+ warning. There are three ways to resolve the problem:
+
+ 1. Rearrange the items in an order that is compatible with the
+ label style you have chosen.
+
+ 2. Choose a different label style that is compatible with the
+ order you have chosen for the items.
+
+ 3. Use the label field to override the automatically-generated
+ label and leave your readers to their own devices.
+
+Bug fix: Spaces are now ignored inside the first argument (the
+ citekey) to \bib. Previously, something like
+
+ \bib{Doe 1998}{...}{...}
+
+ along with
+
+ \cite{Doe 1998}
+
+ would result in a warning that the citation 'Doe1998' was
+ undefined since the space was stripped from the argument to \cite,
+ but not from the first argument to \bib.
+
+========================================================================
+V. CHANGE LOG (REVERSE CHRONOLOGICAL ORDER)
+
+2012-03-07 amsrefs.dtx v2.14
+ -- More thorough patch to \calc@alpha@suffix.
+
+2012-03-06 amsrefs.dtx v2.13
+ -- Patched \calc@alpha@suffix to fix a problem with use of
+ \etalchar in alphabetic labels.
+
+2012-01-15 amsrefs.dtx v2.12
+ -- Added *-optional argument to biblist to allow setting of new
+ per-biblist prefix and labels options.
+ -- Added new webpage entry type.
+ -- Patched \bib to ignore spaces inside the citekey for
+ compatibility with \cite.
+ -- Add a warning if an out-of-order duplicate biblabel stem is
+ detected.
+
+2012-07-26 amsrefs.dtx v2.11
+ -- Minimal support for mixing \bibitem with \bib. This is *not*
+ recommended practice and will not be mentioned in the user
+ documentation, but it is necessary for certain internal AMS
+ applications.
+
+ -- Eliminated the "(to appear in print)" note that \PrintDOI used
+ to add if there was was no volume field.
+
+ -- Added \citeyear to aid in emulating natbib.
+
+ * textcmds.dtx 2.00:
+ -- Replaced most \newcommand's by \providecommand to minimize
+ chances of conflicts with other packages or user definitions.
+
+2012-05-08 amsrefs.dtx 2.10
+ -- patched amsbst.sty to remove unwanted close paren from \PrintEditorsA
+ -- patched \@endbiblist to reset \previous@primary between biblists
+
+2010-08-17 amsrefs.dtx 2.09
+
+ -- Restored support for \citeform that was inadvertently lost
+ somewhere along the way.
+ -- .bst files now unpack into bibtex/bst/amsrefs instead of
+ bibtex/bst/ams
+ -- .bib files now unpack into bibtex/bib/amsrefs instead of
+ bibtex/bib/ams
+
+2010-08-13 amsrefs.dtx 2.08
+
+ -- Updated license to LPPL.
+ -- Patched author-year \BibLabel to support hyperref.
+ -- Added \biblistfont to support easier customization of
+ bibliography font.
+
+2008-07-25 amsrefs.dtx 2.07: AMS-internal modifications.
+
+2008-07-25 amsrefs.dtx 2.06
+
+ -- Modified \BibLabel to typeset numeric labels flush-right
+ instead of flush-left, per AMS house style.
+
+amrefs.dtx 2.03, 2.04, 2.05: AMS-internal modifications only.
+
+2007-10-22 amsrefs.dtx 2.03
+
+ -- .sty files now unpack into tex/latex/amsrefs instead of
+ tex/latex/amscls.
+
+ * amsrefs.dtx 2.03:
+ -- Added the msc-links option.
+ -- \nocite no longer produces a back reference with the backrefs
+ option.
+ -- The backrefs option no longer automatically loads hyperref.
+ -- Fixed support for showkeys (not showlabels, as incorrectly
+ stated in the release notes for 2.02) and the showkeys
+ notcite option.
+ -- Modified the bibdiv, bibchapter and bibsection environments
+ to set the page headings correctly for non-AMS document
+ classes.
+ -- For journals with issue numbers but no volumes, the issue
+ number is now treated as a volume number, per AMS house
+ style.
+ -- \cite and related commands can now be used within the fields
+ of a \bib item, for example, note={See also \cite{SokalB1998}}
+
+ * textcmds.dtx 1.06:
+ -- Added \q for symmetry with \qq.
+
+2006-10-25 amsrefs.dtx 2.02
+
+ -- Updated copyright and license fields.
+ -- Numerous bug fixes.
+
+ * amsrefs.dtx 2.02:
+ -- Fixed bug in copying cross-referenced entries from .ltb files
+ to the .bbl file.
+ -- Fixed disappearing table of contents when used with AMS
+ document classes.
+ -- Enabled xrefs in more fields.
+ -- Fixed spacing problems with \MR. Also be more forgiving if
+ the argument to \MR begins with "MR" or "MR ".
+ -- Added support for showlabels.sty.
+ -- Fixed some bugs in the interaction with hyperref.
+ -- Removed support for the obsolete beta and jpa package options.
+
+ * amsxport.dtx 2.01:
+ -- Fixed bug in sort order of references.
+
+2004-06-30 amsrefs.dtx 2.0
+
+ * Major rewrite of internals. See changes.pdf for information on
+ the user-visible changes.
diff --git a/macros/latex/contrib/amsrefs/amsrdoc.pdf b/macros/latex/contrib/amsrefs/amsrdoc.pdf
new file mode 100644
index 0000000000..01f94d3304
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/amsrdoc.pdf
Binary files differ
diff --git a/macros/latex/contrib/amsrefs/amsrdoc.tex b/macros/latex/contrib/amsrefs/amsrdoc.tex
new file mode 100644
index 0000000000..ea3357a190
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/amsrdoc.tex
@@ -0,0 +1,1867 @@
+%% filename: amsrdoc.tex
+%% version: 1.04
+%% date: 2013/01/16
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 2004, 2006-2008, 2010, 2013 American Mathematical Society.
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+\documentclass[oneside]{amsdtx}
+
+\hyphenation{herme-neutics}
+
+\usepackage{amsrefs}
+\usepackage{amsthm}
+
+\renewcommand*\descriptionlabel[1]{\hspace\labelsep
+ \normalfont\bfseries #1:}
+
+\newcommand{\nshline}{\hline\omit\\}
+
+\makeatletter
+
+\newtheoremstyle{note}{3pt}{3pt}{}{}{\bfseries}{:}{.5em}{}
+
+\theoremstyle{note}
+\newtheorem*{note}{Note}
+
+\def\nitem[#1]{\item[#1\@gobble]}
+
+\DeclareRobustCommand{\fld}{\category@index{field}}
+\DeclareRobustCommand{\btype}{\category@index{entry type}}
+
+\DeclareRobustCommand{\attr}{\category@index{attribute}}
+
+\makeatother
+
+\newcommand{\rpack}[1]{\pkg{amsrefs} package}
+
+\providecommand{\cnbreak}{\penalty999\hskip0pt\relax}
+\providecommand{\cnm}[2]{\cn{#1}\cnbreak\embrace{#2}}
+\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}}
+
+\DeclareTextSymbol{\lbracechar}{OT1}{123}
+\DeclareTextSymbolDefault{\lbracechar}{OT1}
+\DeclareTextSymbol{\rbracechar}{OT1}{125}
+\DeclareTextSymbolDefault{\rbracechar}{OT1}
+
+\providecommand{\embrace}[1]{%
+ \begingroup \ntt\lbracechar#1\rbracechar\endgroup}
+
+\title{User's Guide to the \pkg{amsrefs} Package}
+\author{David M. Jones\\American Mathematical Society}
+\date{January 16, 2013}
+
+\begin{document}
+
+\maketitle
+
+\tableofcontents
+
+\section{Introduction}
+
+\pkg{amsrefs} is a \LaTeX\ package for preparing bibliography or
+reference lists. It attempts to provide many of the convenient
+features that \LaTeX\ and \BibTeX\ users have come to expect without
+imposing all of the overhead that \BibTeX\ entails. In particular, it
+has been carefully designed to encourage the preservation of
+structured markup of the bibliography throughout the entire lifetime
+of a document from rough draft to final archival version. As we shall
+see, it does this by replacing \LaTeX's unstructured \fn{.bbl} file
+format by a new, fully structured format. The package is compatible
+with the \pkg{showkeys}, \pkg{hyperref},\footnote{Note that unlike
+ most packages, which must be loaded \emph{before} \pkg{hyperref},
+ the \pkg{amsrefs} package must be loaded \emph{after} \pkg{hyperref}
+ in order to work properly.} and \pkg{backrefs} packages and
+implements the functionality of the popular \pkg{cite} package.
+Interoperability with \BibTeX\ is supported via a special bibliography
+style file, but \pkg{amsrefs} can be used without \BibTeX.
+
+\section{Using the \pkg{amsrefs} package}
+
+There are three ways of using the \rpack/:
+\begin{enumerate}
+
+\item
+Enter bibliography items directly in your \latex/ document using the
+\env{biblist} environment and the \cn{bib} command.
+
+\item
+Import items from an external \fn{.ltb} file.
+
+\item
+Import items from a \fn{.bib} file using \bibtex/ and the special
+bibliography styles distributed with the \pkg{amsrefs} package.
+
+\end{enumerate}
+
+\subsection{Direct entry of bibliography items}\label{direct-entry}
+
+The most basic way to use \pkg{amsrefs} is to enter the bibliography
+items directly in your \LaTeX\ document. For example, consider the
+following very short document:
+\begin{quote}
+ Alan Sokal~[2] recommends Bourbaki's text~[1]
+ for a gentle introduction to set theory.
+
+ \begin{bibsection}
+ \begin{biblist}
+
+ \bib{Bourbaki70}{book}{
+ title={Th\'eorie des ensembles},
+ author={Bourbaki, Nicolas},
+ date={1970},
+ publisher={Hermann},
+ address={Paris}
+ }
+
+ \bib{Sokal96}{article}{
+ title={Trangressing the boundaries},
+ subtitle={Toward a transformative hermeneutics of quantum gravity},
+ author={Sokal, Alan},
+ journal={Social Text},
+ volume={46/47},
+ date={1996},
+ pages={217--252}
+ }
+
+ \end{biblist}
+ \end{bibsection}
+\end{quote}
+Using \pkg{amsrefs}, this document would be coded as follows:
+\begin{verbatim}
+ \documentclass{article}
+
+ \usepackage{amsrefs}
+
+ \begin{document}
+
+ Alan Sokal~\cite{Sokal96} recommends Bourbaki's
+ text~\cite{Bourbaki70} for a gentle introduction to set theory.
+
+ \begin{bibdiv}
+ \begin{biblist}
+
+ \bib{Bourbaki70}{book}{
+ title={Th\'eorie des ensembles},
+ author={Bourbaki, Nicolas},
+ date={1970},
+ publisher={Hermann},
+ address={Paris}
+ }
+
+ \bib{Sokal96}{article}{
+ title={Trangressing the boundaries},
+ subtitle={Toward a transformative hermeneutics of quantum gravity},
+ author={Sokal, Alan},
+ journal={Social Text},
+ volume={46/47},
+ date={1996},
+ pages={217--252}
+ }
+
+ \end{biblist}
+ \end{bibdiv}
+
+ \end{document}
+\end{verbatim}
+Compared to the standard \LaTeX\ markup for bibliographies, there are
+two main differences:
+\begin{itemize}
+
+\item
+The functions of the \env{thebibliography} environment are split
+between two new environments: \env{bibdiv}, which produces the chapter
+or section heading for the bibliography, and \env{biblist}, which
+contains the reference list per se. These environments will be
+covered in more detail in sections \ref{biblist} and~\ref{bibdiv}.
+
+\item
+The \cn{bibitem} command is replaced by the \cn{bib} command, which is
+very similar to a \BibTeX\ database entry. However, as we shall see
+in section~\ref{bib-command}, there are some significant differences.
+
+\end{itemize}
+
+\subsection{Using an \fn{.ltb} database file}\label{ltb-files}
+
+The second way of using \pkg{amsrefs} is to keep your \cn{bib}
+commands in a separate database file and have \pkg{amsrefs} import the
+ones that are needed. For example, suppose you have a file
+\fn{nonsense.ltb} with the following contents:
+\begin{verbatim}
+ \documentclass{article}
+
+ \usepackage{amsrefs}
+
+ \begin{document}
+
+ \begin{bibdiv}
+
+ \begin{biblist}
+
+ \bib{Bourbaki70}{book}{
+ title={Th\'eorie des ensembles},
+ author={Bourbaki, Nicolas},
+ date={1970},
+ publisher={Hermann},
+ address={Paris}
+ }
+
+ \bib{Sokal96}{article}{
+ title={Trangressing the boundaries},
+ subtitle={Toward a transformative hermeneutics of quantum gravity},
+ author={Sokal, Alan},
+ journal={Social Text},
+ volume={46/47},
+ date={1996},
+ pages={217--252}
+ }
+
+ \bib{SokalB1998}{book}{
+ title={Fashionable Nonsense},
+ subtitle={Postmodern Intellectuals' Abuse of Science},
+ author={Sokal, Alan},
+ author={Bricmont, Jean},
+ publisher={Picador USA},
+ address={New York},
+ date={1998}
+ }
+
+ \end{biblist}
+
+ \end{bibdiv}
+
+ \end{document}
+\end{verbatim}
+Before seeing how this affects our sample document, take note of a
+couple of aspects of the format of \fn{nonsense.ltb}:
+\begin{enumerate}
+
+\item
+We have chosen to format \fn{nonsense.ltb} as a complete \LaTeX\
+document. This is so we can produce a formatted listing of our whole
+database by running \fn{nonsense.ltb} through \LaTeX. However, this
+is not necessary; when \pkg{amsrefs} treats \fn{nonsense.ltb} as a
+database file, it ignores everything except for the \cn{bib} commands.
+
+\item
+Each \cn{bib} command in the \fn{.ltb} file \emph{must} begin on a new
+line, and the first two arguments and the open brace of the third
+argument must be on that same line. Failure to follow this format may
+result in \pkg{amsrefs} getting terribly confused and aborting the
+processing of your document.
+
+\end{enumerate}
+
+With that out of the way, let's look at how this affects our main
+file, which we'll call \fn{sample.tex}:
+\begin{verbatim}
+ \documentclass{article}
+
+ \usepackage{amsrefs}
+
+ \begin{document}
+
+ Alan Sokal~\cite{Sokal96} recommends Bourbaki's
+ text~\cite{Bourbaki70} for a gentle introduction to set theory.
+
+ \begin{bibdiv}
+ \begin{biblist}
+
+ \bibselect{nonsense}
+
+ \end{biblist}
+ \end{bibdiv}
+
+ \end{document}
+\end{verbatim}
+When you run this document through \LaTeX, \pkg{amsrefs} will create a
+file \fn{sample.bbl} that contains all the relevant \cn{bib} entries
+from \fn{nonsense.ltb}. This is very similar to using \BibTeX, but
+with a few noteworthy differences:
+\begin{itemize}
+
+\item
+Because all processing is being handled by \latex/, the contents of
+the bibliography can be printed on the first pass; citation labels,
+consequently, are resolved on the second pass.
+
+\item
+Unlike \BibTeX, which adds the \env{thebibliography} environment
+automatically, \pkg{amsrefs} requires you to supply the \env{bibdiv}
+and \env{biblist} environments yourself. As we shall see later, this
+results in greater flexibility in the formatting of bibliographies.
+
+\item
+There is no need for a \cn{bibliographystyle} command.
+
+\item
+No sorting of the bibliography items is done. The entries will appear
+in your document in the same order that they appeared in the database
+files.
+
+\end{itemize}
+Like the \cn{bibliography} command, \cn{bibselect} can be given
+multiple files to process:
+\begin{verbatim}
+ \bibselect{bib1,bib2}
+\end{verbatim}
+and can be used multiple times in your document:
+\begin{verbatim}
+ \bibselect{bib1}
+ \bibselect{bib2}
+\end{verbatim}
+Normally each \cn{bibselect} command will only import entries that
+have been explicitly cited in your document. If you want to import
+all entries from a given file, you can use the $*$-variant:
+\begin{verbatim}
+ \bibselect*{sample}
+\end{verbatim}
+This is similar to the use of \label{nocite}\verb|\nocite{*}| but
+allows finer control. You can still use \verb|\nocite{*}|, but with
+one restriction: it only applies to \cn{bibselect} commands that occur
+after it in the document.
+
+The \cn{bibselect} command regenerates the \fn{.bbl} file each time
+the document is \LaTeX ed (unless, of course, the \cn{nofiles} switch
+is used). Once your bibliography is completed, you might wish to
+replace the \cn{bibselect} command by the contents of the \fn{.bbl}
+file to prevent any further modifications. This is particularly
+important if you need to edit the contents of the \fn{.bbl} file in
+any way (say, to re-order the items or adjust the capitalization of
+titles to match the style of the journal you are publishing in or to
+put in explicit line or page breaks). This will make your document
+more self-contained, which will make it easier to reuse and archive.
+
+\subsection{Using the \rpack/ with \bibtex/}
+
+Finally, you can use \pkg{amsrefs} in conjunction with \BibTeX:
+\begin{verbatim}
+ \documentclass{article}
+
+ \usepackage{amsrefs}
+
+ \begin{document}
+
+ Alan Sokal~\cite{Sokal96} recommends Bourbaki's
+ text~\cite{Bourbaki70} for a gentle introduction to set theory.
+
+ \bibliography{nonsense}
+
+ \end{document}
+\end{verbatim}
+Note two things:
+\begin{itemize}
+
+\item
+Unlike when you use \cn{bibselect} to import entries from a \fn{.ltb},
+in this case the \fn{.bbl} \emph{will} contain the \env{bibdiv} and
+\env{biblist} environments.
+
+\item
+There is no need for a \cn{bibliographystyle} command; \pkg{amsrefs}
+will automatically invoke the correct style. In fact, any
+\cn{bibliographystyle} command you put in your document will be
+ignored.
+
+\end{itemize}
+
+The main advantages of using \BibTeX\ are:
+\begin{itemize}
+
+\item
+you can take advantage of \BibTeX's ability to sort your items for
+you, and
+
+\item
+you can take advantage of the large number of \BibTeX\ database files
+already in existence.
+
+\end{itemize}
+
+As when using an \fn{.ltb} file, you may wish to replace the
+\cn{bibliography} command by the contents of the \fn{.bbl} file when
+you have finished compiling your bibliography.
+
+\section{The \protect\env{biblist} and \env{biblist*} environments}
+\label{biblist}
+
+As alluded to earlier, \env{thebibliography} performs two distinct
+functions: first, it produces the section heading for the bibliography
+and second, it provides the list environment for formatting the
+bibliography entries.
+
+In \pkg{amsrefs} these functions are performed by two distinct
+environments, \env{bibdiv} and \env{biblist}. As its name suggests,
+the \env{biblist} environment provides the second function. So, if
+you wanted a list of references with no heading at all, you could just
+leave out the \env{bibdiv} environment.
+
+The \env{biblist} environment has an optional argument to allow
+changing the list parameters. For example, suppose you know that your
+bibliography has between 100 and 999 entries and you want to ensure
+that there is enough space allocated for the labels on the first pass.
+You could write
+\begin{verbatim}
+ \begin{biblist}[\resetbiblist{999}]
+\end{verbatim}
+to tell \LaTeX\ to leave enough room for labels that are three digits
+long. Similarly, if you want your bibliography typeset in the normal
+font size instead of footnotesize, you could write
+\begin{verbatim}
+ \begin{biblist}[\normalsize]
+\end{verbatim}
+Want your bibliography numbered starting with~0 instead of~1? Just
+write
+\begin{verbatim}
+ \begin{biblist}[\setcounter{bib}{-1}]
+\end{verbatim}
+
+The \env{biblist} environment also takes a second optional argument
+that can be used to modify the current bibliography. This argument
+consists of an asterisk followed by a set of key-value pairs
+surrounded by braces:
+\begin{verbatim}
+ \begin{biblist}*{key={val},...}
+\end{verbatim}
+Two keys are supported at present:
+\begin{description}
+
+\item[labels]
+
+Set this to ``numeric,'' ``alphabetic,'' or ``shortalphabetic'' to
+override the default label style for the current bibliography.
+
+\item[prefix]
+
+The value of this key will be prepended to each of the labels in the
+current bibliography.
+
+\end{description}
+\begin{note}
+Neither of these can be used with the \opt{author-year} option.
+\end{note}
+For example, if you are using numeric labels, then
+\begin{verbatim}
+ \begin{biblist}*{prefix={A}}
+\end{verbatim}
+will cause the items to be labeled ``A1,'' ``A2,'' etc. Similarly,
+\begin{verbatim}
+ \begin{biblist}*{labels={alphabetic}}
+\end{verbatim}
+will cause the current list to be labeled alphabetically instead of
+numerically.
+
+\begin{note}
+Depending on your specific use of \cn{cite}s, use of non-numeric
+prefixes or of mixed numeric and non-numeric label styles can
+interfere with citation sorting and compression
+(section~\ref{sec:sorting}). You may need to pass the
+\opt{non-sorted-cites} and \opt{non-compressed-cites} options to
+amsrefs to get the correct behavior.
+\end{note}
+
+If you want to use both types of optional arguments, the key-value
+pairs come second:
+\begin{verbatim}
+ \begin{biblist}[\normalsize]*{...}
+\end{verbatim}
+
+Each \env{biblist} environment resets the \cnt{bib} counter so that
+its items are numbered starting from~1. If you want the numbering to
+start where the last \env{biblist} left off, use the \env{biblist*}
+environment instead.
+
+Finally, users familiar with the \env{thebibliography} environment may
+wonder why \env{biblist} doesn't have a mandatory argument to specify
+the longest label. The reason is that the \env{biblist} environment
+automatically calculates the width of the longest label and stores
+this information in the \fn{.aux} file. This means that the next time
+\LaTeX\ is run, the environment will know how much space to leave for
+the labels.
+
+\section[Section titles for bibliographies: \env{bibdiv} et
+ al.]{Section titles for bibliographies: \env{bibdiv},\\
+ \env{bibsection}, \env{bibchapter}}
+\label{bibdiv}
+
+As seen earlier, the \env{bibdiv} environment provides an appropriate
+section heading. Ordinarily that's all you need to know, since
+\env{bibdiv} will automatically switch between a \cn{chapter} and a
+\cn{section} heading depending on whether the document seems booklike
+or articlelike. Simililarly, it will use the current value of
+\cn{bibname} or \cn{refname} for the heading text. However, if that's
+not sufficient, there are three more ways of customizing its behavior:
+\begin{enumerate}
+
+\item
+Instead of \env{bibdiv}, you can use \env{bibchapter} or
+\env{bibsection} to generate the appropriate type of heading.
+
+\item
+All three environments take an optional argument to override the text
+of the heading:
+\begin{verbatim}
+ \begin{bibchapter}[Annotated Bibliography]
+\end{verbatim}
+
+\item
+For maximum flexibility, you can omit the \env{bibdiv} environment
+entirely and optionally add an arbitrary header:
+\begin{verbatim}
+ \subsection{Further reading}
+\end{verbatim}
+
+\end{enumerate}
+
+Finally, note that a further significant benefit of having separate
+\env{bibdiv} and \env{biblist} environments is that you can put
+arbitrary introductory text between the header and the list:
+\begin{verbatim}
+ \begin{bibdiv}
+
+ Abbreviations used:
+
+ ...
+
+ \begin{biblist}
+\end{verbatim}
+
+\section{More about the \cn{bib} command}\label{bib-command}
+
+As noted earlier, the syntax of the \cn{bib} command is very similar
+to that of a \BibTeX\ database record. For example, here's how the
+third bibliography item from section~\ref{ltb-files} might look in a
+\fn{.bib} file:
+\begin{verbatim}
+ @Book{SokalB1998,
+ title={Fashionable Nonsense: Postmodern Intellectuals' Abuse of
+ Science},
+ author={Alan Sokal and Jean Bricmont},
+ publisher={Picador USA},
+ address="New York",
+ year=1998
+ }
+\end{verbatim}
+However, there are a number of other significant differences between
+the two formats:
+
+\begin{description}
+
+\item[Order of type and key]
+
+In \BibTeX\ records, the entry type comes first and serves to mark the
+start of the field, and the cite key is separated from the data fields
+by a comma:
+\begin{verbatim}
+ @Book{SokalB1998,
+\end{verbatim}
+In \pkg{amsrefs}, every record begins with the \verb|\bib| command,
+followed first by the cite key and then by the entry type, and the
+data fields are preceded by an open brace, not a comma:
+\begin{verbatim}
+ \bib{SokalB1998}{book}{
+\end{verbatim}
+
+\item[Case sensitivity]
+
+In general, \BibTeX\ doesn't care how you capitalize field names. As
+far as it is concerned, ``title'', ``TITLE'' and ``tItLe'' are the
+same field name. Like \TeX\ in general, though, \pkg{amsrefs} is case
+sensitive. All of the standard field and bibliography entry-type
+names are spelled with all lowercase letters and must be typed exactly
+as shown in the documentation.
+
+\item[Mandatory braces]
+
+\BibTeX\ allows the braces around field values to be omitted in some
+contexts and allows double quotes to be substituted for braces. In
+\pkg{amsrefs}, every field value \emph{must} be surrounded by braces.
+
+\item[Repeated fields]
+
+\BibTeX\ does not allow fields to be repeated within a record;
+\pkg{amsrefs} allows certain fields (like \fld{author}) to be repeated
+as many times as needed.
+
+\item[Inverted names]
+
+\BibTeX\ allows names to be entered in a variety of formats, for
+example:
+\begin{verbatim}
+ author={John Doe}
+ author={Doe, John}
+ author={Doe, Jr., John}
+\end{verbatim}
+Although \BibTeX\ usually does a good job of parsing names into their
+components, sometimes it needs help, and experience shows that authors
+often have trouble telling when they need to provide such help. In
+order to avoid these problems, \pkg{amsrefs} takes the somewhat
+draconian step of requiring all names to be written in the form
+\emph{von Last, First, Jr.}, for example:
+\begin{verbatim}
+ author={Jones, John Paul}
+ author={van Beethoven, Ludwig}
+ author={Ford, Henry, Jr.}
+\end{verbatim}
+It is essential to follow this format for all names; otherwise
+\pkg{amsrefs} may produce profoundly incorrect results when it is
+asked to invert names (i.e., format the name as ``Doe, John'' instead
+of ``John Doe'', as some styles require), replace the first name by
+its initials (when the \opt{initials} option is used), or create a
+label based on the last name (the \opt{alphabetic} option).
+
+\end{description}
+
+In addition, there are differences in the rules that must be followed
+in marking the text inside fields:
+\begin{description}
+
+\item[Capitalization]
+
+Some \BibTeX\ styles will adjust the capitalization of titles to
+achieve a uniform style. This means that authors have to be careful
+to put extra braces around any characters that should not be upper- or
+lower-cased. For example, if you were to write
+\begin{verbatim}
+ title={An $O(n \log n)$ Sorting Network}
+\end{verbatim}
+many \BibTeX\ styles would change the title to
+\begin{quote}
+ An $o(n \log n)$ sorting network
+\end{quote}
+possibly resulting in great confusion on the part of the reader. To
+prevent this, you must surround the mathematical expression with an
+extra set of braces:
+\begin{verbatim}
+ title={An {$O(n \log n)$} Sorting Network}
+\end{verbatim}
+As with name formats, experience suggests that authors are often
+confused by \BibTeX's rules and fail to properly protect their titles.
+The good news is that \pkg{amsrefs} will not change the capitalization
+of any of your titles. The bad news is that this means you are solely
+responsible for editing the titles of your bibliography items to match
+the style your publisher requires.
+
+\item[Special characters]
+
+\BibTeX\ is also sometimes confused by text accents or other special
+characters such as \verb+\ae+ or \verb+\o+, which also have to be
+surrounded by braces for \BibTeX\ to process them correctly:
+\begin{verbatim}
+ author={Kurt G{\"o}del}
+ author={V. S{\o}rensen}
+\end{verbatim}
+\pkg{amsrefs} is more forgiving and will accept
+\begin{verbatim}
+ author={G\"odel, Kurt}
+ author={S\o rensen, V.}
+\end{verbatim}
+although it is probably still a good idea to surround \verb+\o+ with
+braces in the second example. We'll talk more about names in
+sections~\ref{names} and~\ref{attributes}.
+
+%% \item[ndash] Use of \cn{ndash} instead of \verb'--' for en-dashes is
+%% recommended (the \verb'--' notation, which is tied to
+%% idiosyncrasies of the Computer Modern \qq{\TeX{} text} font
+%% encoding, hinders document translation and the use of alternate
+%% fonts).
+
+\end{description}
+
+Finally, although \pkg{amsrefs} supports many of the same field and
+entry types that \BibTeX\ does, there are some differences, which we
+will explore in the next two sections.
+
+\subsection{Bibliography entry types}
+
+Compared to \BibTeX, \pkg{amsrefs} has a relatively small number of
+entry types. However, what it lacks in diversity it makes up for in
+versatility. Here are the supported entry types, along with some
+descriptive comments that are meant to suggest the variety of uses for
+which the type is appropriate.
+
+\begin{description}
+
+\item[article]
+
+A relatively short but self-contained item that is typically published
+as part of a larger collection, such as a journal, a conference
+proceedings, an edited collection published as a book, or even as part
+of a World Wide Web document.
+
+\item[book]
+
+A written work by one or more authors where the authors share credit
+for the work as a whole. For compatibility with \BibTeX, the
+following entry types are available as aliases for \btype{book}:
+\btype{collection}, \btype{proceedings}, \btype{manual},
+and \btype{unpublished}.
+
+\item[misc]
+
+Anything that doesn't fit into one of the other types.
+
+\item[report]
+
+A technical report, white paper, or the like. Similar to an
+\btype{article} but usually published and distributed by an
+organization such as a university or corporation whose primary
+business is usually not publishing. Also known as a
+\btype{techreport}.
+
+\item[thesis]
+
+Like \emph{report} but produced by the author for an educational
+institution to satisfy the requirements for a degree. Not (normally)
+produced by a commercial publisher for sale.
+
+\item[webpage]
+
+An online resource. It is limited to the following fields:
+\fld{accessdate},
+\fld{author},
+\fld{date},
+\fld{note},
+\fld{subtitle},
+\fld{title},
+\fld{url}.
+
+\end{description}
+
+\subsection{Field names for the \cn{bib} command}
+
+The \pkg{amsrefs} package distinguishes between three types of fields:
+\begin{enumerate}
+
+\item
+A \emph{simple} field can appear only once in each record. Some
+examples are \fld{title} and \fld{publisher}.
+
+\item
+A \emph{repeatable} field can appear as many times as necessary. As
+we saw above, \fld{author} is repeatable, as are \fld{editor} and
+\fld{translator}, but we'll see later that not all repeatable fields
+are names.
+
+\item
+Briefly, a \emph{compound} field is one that is made up of a
+collection of subfields, for example:\label{ex:translation}
+\begin{verbatim}
+ \bib{KostrikinS1965}{article}{
+ author={Kostrikin, A. I.},
+ author={\v{S}afarevi\v{c}, I. R.},
+ title={Cartan pseudogroups and Lie $p$-algebras},
+ journal={Dokl. Akad. Nauk SSSR},
+ volume={168},
+ date={1965},
+ pages={740--742},
+ translation={
+ journal={Soviet Math. Dokl.},
+ volume={6},
+ date={1965},
+ pages={715--718}
+ },
+ review={\MR{0199235}}
+ }
+\end{verbatim}
+Here the translation is specified with a compound field so it can have
+its own set of publication fields.
+
+\end{enumerate}
+
+\subsubsection{Simple fields}
+
+The meaning of many of these should be self-evident, so comments will
+be kept to a minimum.
+\begin{description}
+
+\item[accessdate]
+
+Used to specify the date on which a \btype{webpage} was viewed, as
+opposed to the date on which the resource was last modified, which
+would be put in the \fld{date} field.
+
+\item[address]
+
+Usually the address of the publisher or other issuing organization,
+but inside the \fld{conference} compound field (see
+page~\pageref{compound}) it refers to the address of the
+conference.
+
+\item[booktitle]
+
+Used in the \btype{article} type to specify the title of the book in
+which the article appeared. If anything other than a simple book
+title is required, the \fld{book} compound field should be used
+instead.
+
+\item[date]\label{date-format}
+
+Usually the date of publication, except inside the \fld{conference}
+field, where it is the date of the conference (see
+page~\pageref{compound}).
+
+This replaces \BibTeX's \fld{year} and \fld{month} fields. Its value
+should be written in ISO 8601 format, e.g., 1967-02-24. The day
+and/or month can be omitted, so all of the following are valid
+representations of February 24, 1967:
+\begin{verbatim}
+ date={1967-02-24}
+ date={1967-02}
+ date={1967}
+\end{verbatim}
+Using this format allows \pkg{amsrefs} maximum flexibility in
+formatting dates, for example, by allowing month names to be printed
+in full or abbreviated as necessary.
+
+For \qq{Winter}, \qq{Spring}, \qq{Summer}, \qq{Fall}, either use month
+numbers of 13, 14, 15, 16 (respectively) or just put in the text
+before the year:
+\begin{verbatim}
+ date={Summer 1987},
+\end{verbatim}
+For compatibility, \fld{year} is provided as an alias for \fld{date},
+but its use is discouraged.
+
+\item[edition]
+
+For books or reports. If the value of this field is a simple number,
+\cn{bib} will convert it to cardinal form and add \qq{ed.} (or
+alternative text if specified by the bibliography style). Otherwise
+it will be printed as~is.
+
+\item[eprint]
+
+Electronic preprint information such as for \url{www.arXiv.org}. See
+\url{http://xxx.lanl.gov/help/faq/references} for recommended form.
+
+\item[hyphenation]
+
+This corresponds to the Babel package notion of \qq{language}. The
+hyphenation language used for a given \cn{bib} entry is determined
+from various clues, which are checked in the following order:
+\begin{enumerate}
+
+\item
+The Babel language specified by the \fld{hyphenation} field.
+
+\item
+The Babel language specified by the \emph{first word} of the
+\fld{language} field (after lowercasing).
+
+\item
+The current Babel language that was in effect before the \cn{bib}
+command started.
+
+\item
+The current hyphenation patterns of the document, if there are no
+Babel language modules loaded.
+
+\end{enumerate}
+The \fld{hyphenation} field applies to an entire entry. To change the
+Babel language for a single field, see the discussion of the
+\fld{language} attribute on page~\pageref{attributes}.
+
+\nitem[journal]
+
+\item[label]
+
+When the \opt{alphabetic} or \opt{shortalphabetic} options are used,
+\pkg{amsrefs} will usually try to generate the label on its own. If
+necessary, you can override the automatically generated label by
+specifying a \fld{label} field.
+
+\item[language]
+
+Language of the work. The language name should be the printed form,
+not a Babel-style language name, since in principle this field could
+contain more complicated remarks such as \qq{Russian, with French
+abstract}. Cf.~\fld{hyphenation}.
+
+\item[note]
+
+Any additional information that does not fit into one of the other
+fields.
+
+\item[number]
+
+The issue number of the journal for an \btype{article} or the
+technical report number for a \btype{report}.
+
+\item[organization]
+
+The school, university, corporation, or other nonpublisher
+organization that issued the document.
+
+\nitem[pages]
+
+\nitem[part]
+
+\nitem[publisher]
+
+\nitem[series]
+
+%% Let's suppress this at least until we can think of a good
+%% example.
+%%
+%% \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.
+
+\item[status]
+
+Typically used for notes such as \qq{to appear} or \qq{in preparation}
+or \qq{unpublished} with journal articles.
+
+\item[subtitle]
+
+Typically used with a multipart journal article to give a subtitle for
+each part, but it can also be used for books.
+
+\nitem[title]
+
+\item[type]
+
+The type of a thesis, e.g., ``Master's Thesis'' or ``Ph.D. Thesis''.
+
+\nitem[volume]
+
+\item[xref]
+
+This will be explained in section~\ref{xrefs}.
+
+\end{description}
+
+\subsubsection{Repeatable fields}
+
+\begin{description}
+
+\item[author, editor, translator]
+
+The authors, editors, and/or translators of the item. If there are
+other contributors that should be acknowledged, they should be listed
+in \fld{contribution} fields (see page~\pageref{contributors}).
+
+\item[isbn, issn]
+
+An International Standard Book or Serial Number. (These are not
+printed by the standard styles, but are reserved for future use.)
+
+\item[review]
+
+A review number or similar pointer to, for example, \emph{Mathematical
+Reviews} or \emph{Zentralblatt}. You must supply any special markup
+for the number; i.e., you should write
+\begin{verbatim}
+ review={\MR{2015463}}
+\end{verbatim}
+instead of
+\begin{verbatim}
+ review={2015463}
+\end{verbatim}
+
+\end{description}
+
+\subsubsection{Compound fields}\label{compound}
+
+These are the compound fields currently supported by \pkg{amsrefs}.
+
+\begin{description}
+
+\item[book]
+
+This is used for conference articles to make it easier to
+differentiate between an article and the book or proceedings that it
+appeared in. The \fld{book} field can contain any of the following
+subfields: \fld{title}, \fld{part}, \fld{subtitle}, \fld{edition},
+\fld{editor}, \fld{translator}, \fld{contribution}, \fld{series},
+\fld{volume}, \fld{publisher}, \fld{organization}, \fld{address},
+\fld{date}, \fld{note}.
+
+It is often used in conjunction with the \fld{conference} field.
+
+\item[conference]
+
+The \fld{conference} field can contain a \fld{title}, \fld{address},
+and \fld{date}.
+
+\begin{verbatim}
+ \bib{Burkholder1986a}{article}{
+ author={Burkholder, Donald L.},
+ title={Martingales and Fourier analysis in Banach spaces},
+ conference={
+ title={C.I.M.E. Lectures},
+ address={Varenna, Italy},
+ date={1985}
+ },
+ book={
+ series={Lecture Notes in Math.},
+ volume={1206},
+ publisher={Springer-Verlag},
+ address={Berlin and New York},
+ date={1986},
+ },
+ pages={61--108},
+ review={\MR{0864712}}
+ }
+\end{verbatim}
+
+\item[contribution]\label{contributors}
+
+This field can be repeated as many times as necessary to list any
+contributors other than authors, editors, or translators.
+\begin{verbatim}
+ contribution={
+ type={illustrations},
+ author={Gorey, Edward}
+ }
+\end{verbatim}
+which in the default style produces
+\begin{quote}
+ with illustrations by Edward Gorey
+\end{quote}
+Since contributions are potentially complicated, so is the
+\fld{contribution} field:
+\begin{itemize}
+
+\item
+Sometimes it is necessary to add additional material to the \fld{type}
+in order to produce intelligible text:
+\begin{verbatim}
+ contribution={
+ type={an appendix},
+ author={Doe, John}
+ }
+\end{verbatim}
+
+\item
+\pkg{amsrefs} tries very hard to format multiple contributions, each
+of which may have multiple authors, in an appropriate way. However,
+there might be cases where the default rules aren't flexible enough,
+in which case you can instead use the \fld{contribution} field as a
+simple field and format it exactly the way you want:
+\begin{verbatim}
+ contribution={some arbitrary text about contributions}
+\end{verbatim}
+This feature should only be used as a last resort, though.
+
+\end{itemize}
+
+\item[partial]
+
+This is used with the \btype{article} type for multipart articles.
+Like the \fld{contribution} field, it is repeatable. It can contain
+any of the following fields: \fld{part}, \fld{subtitle},
+\fld{contribution}, \fld{journal}, \fld{volume}, \fld{date},
+\fld{number}, \fld{pages}.
+\begin{verbatim}
+ \bib{Zho-fan1972}{article}{
+ author={Zho-fan, Z.},
+ title={Monomials},
+ partial={
+ part={I},
+ journal={Tot. Math.},
+ volume={19},
+ date={1972},
+ pages={335--350}
+ },
+ partial={
+ part={II},
+ journal={Tot. Math.},
+ volume={20},
+ date={1973},
+ pages={19--37}
+ }
+ }
+\end{verbatim}
+
+\item[reprint]
+
+This can be used inside an \btype{article} to indicate another place
+(usually a book) where the article can also be found. It can contain
+any field that the \btype{book} type can.
+\begin{verbatim}
+ \bib{Sokal96}{article}{
+ title={Trangressing the boundaries},
+ subtitle={Toward a transformative hermeneutics of quantum
+ gravity},
+ author={Sokal, Alan},
+ journal={Social Text},
+ volume={46/47},
+ date={1996},
+ pages={217--252},
+ reprint={
+ title={Fashionable Nonsense},
+ subtitle={Postmodern Intellectuals' Abuse of Science},
+ author={Sokal, Alan},
+ author={Bricmont, Jean},
+ publisher={Picador USA},
+ address={New York},
+ date={1998}
+ }
+ }
+\end{verbatim}
+
+\item[translation]
+
+This is the only compound field that can be used with any bibliography
+type. It can contain any field that its parent type can contain. We
+saw an example of this on page~\pageref{ex:translation}.
+
+\end{description}
+
+\subsection{What's in a name?}\label{names}
+
+We saw earlier that names must always be entered in the form ``von
+Last, First, Jr.''\ so that \pkg{amsrefs} can unambiguously determine
+which parts of the name correspond to the surname and which to the
+given name. In this section we will discuss some of the other
+subtleties that come into play with processing names.
+
+The good news is that the vast majority of the time you don't need to
+worry about this section. As long as your names contain only the
+following characters, you should be safe:
+\begin{itemize}
+
+\item
+the 26 ASCII letters, the apostrophe (') and \TeX's tie (\verb|~|) and
+grouping (\verb+{}+) characters,
+
+\item
+one of the following accent commands: \cn{\"} \cn{\'} \cn{\.}\ \cn{\=}
+\cn{\^} \cn{\`} \cn{\~} \cn{\b} \cn{\c} \cn{\d} \cn{\H} \cn{\k}
+\cn{\r} \cn{\t} \cn{\u} \cn{\v}, or
+
+\item
+one of the following special characters: \cn{AE} \cn{ae} \cn{DH}
+\cn{dh} \cn{DJ} \cn{dj} \cn{i} \cn{j} \cn{L} \cn{l} \cn{NG} \cn{ng}
+\cn{OE} \cn{oe} \cn{O} \cn{o} \cn{SS} \cn{ss} \cn{TH} \cn{th}.
+
+\end{itemize}
+If you are using the \pkg{mathscinet} package, any of the special
+characters and accents defined by it can also be used.\footnote{For
+pragmatic purposes, note that the difference between an ``accent'' and
+a ``special character'' is that all the macros identified as accents
+take a single argument, while the ones identified as special
+characters do not take an argument.}
+
+\subsubsection{Grouping multiple physical characters into a single
+ logical character}
+
+Sometimes it's necessary to tell \pkg{amsrefs} to treat two or more
+characters as a single ``logical'' character. For example, consider
+the following names:
+\begin{verbatim}
+ author={Gagarin, Yuri}
+ author={Katzenbach, Nicholas deBelleville}
+\end{verbatim}
+If the \opt{initials} option is in force, \pkg{amsrefs} will shorten
+those names to ``Y. Gagarin'' and ``N. d. Katzenbach''. These are
+both incorrect, the first because ``Yu'' represents the
+transliteration of a single Cyrillic character and the second because
+``deBelleville'' should be shortened to ``deB'', not just~``d''. The
+easiest way to force the correct interpretation is by adding braces,
+as follows:
+\begin{verbatim}
+ author={Gagarin, {Yu}ri}
+ author={Katzenbach, Nicholas {deB}elleville}
+\end{verbatim}
+which tells \pkg{amsrefs} that those characters should be kept
+together, producing the correct results.
+
+Incidentally, if you provide the names in already abbreviated form,
+i.e.,
+\begin{verbatim}
+ author={Gagarin, Yu.}
+ author={Katzenbach, N. deB.}
+\end{verbatim}
+it is not necessary to add the extra braces, since \pkg{amsrefs} will
+not further abbreviate any word that already ends in a period (but the
+extra braces also would do no harm).
+
+\subsubsection{Declaring new accents or special characters}
+
+In some cases it may also be necessary to add a special character or
+accent to the list given above. An accent command can be added to the
+list of acceptable name components by using the \cn{DeclareNameAccent}
+command. In fact, \pkg{amsrefs} contains a declaration like
+\begin{verbatim}
+ \DeclareNameAccent{\"}
+\end{verbatim}
+for each of the text accents listed above.
+
+Declaring a new text symbol is only slightly more complicated:
+\begin{verbatim}
+ \DeclareNameSymbol{\AE}{\ae}
+\end{verbatim}
+This says that \verb+\AE+ and \verb+\ae+ are both allowed as text
+symbols inside names and, furthermore, that \verb|\ae| is the
+lowercase version of~\verb|\AE|.
+
+\section{Package options}
+
+The \pkg{amsrefs} package has a plethora of options.
+
+\subsection{Citation labels}
+
+By default, the items in your bibliography are numbered, as in the
+\bst{plain} \BibTeX\ style. However, three other label styles are
+also supported via the following options:
+\begin{description}
+
+\item[alphabetic]
+
+This generates alphabetic labels similar to the \pkg{alpha} \BibTeX\
+style, consisting of the first letter(s) of each author name plus the
+year of publication.
+
+\item[shortalphabetic]
+
+This generates a shorter alphabetic label using only the first letter
+of each author name.
+
+\item[author-year]
+
+This switches to the popular author-year citation format, similar to
+that described in \emph{The Chicago Manual of Style}. See
+section~\ref{author-year} for more information on this option.
+
+\item[y2k]
+
+When using the \opt{alphabetic} option, normally only the last two
+digits of the year are used in the label. The \opt{y2k} instructs
+\pkg{amsrefs} to use the full year.
+
+\end{description}
+
+\begin{note}
+Since \pkg{amsrefs} leaves the order of the bibliography items up to
+the user, a common mistake when using non-numeric labels (especially
+\opt{shortalphabetic} labels) is to put the items in an order that is
+incompatible with the natural order of the labels. This can result in
+a sequence such as this:
+\begin{biblist}*{labels={shortalphabetic}}
+
+\bib{A}{article}{
+ title={\dots},
+ author={Doe, John},
+}
+
+\bib{C}{article}{
+ title={\dots},
+ author={Doe, John},
+ author={Smith, Jane},
+}
+
+\bib{B}{article}{
+ title={\dots},
+ author={Dunn, John},
+}
+\end{biblist}
+where \pkg{amsrefs} does not automatically replace the first and third
+labels by ``D1'' and ``D2'' as it would if they were consecutive.
+This is because the real error lies in attempting to force the labels
+into an unordered sequence. Readers are entitled to find reference
+``D2'' between references ``D1'' and~``DS'' in the bibliography just
+as they are entitled to find reference~[2] between references [1]
+and~[3].
+
+If \pkg{amsrefs} encounters a situation like this, it will issue a
+warning. There are three ways to resolve the problem:
+\begin{enumerate}
+
+\item
+Rearrange the items in an order that is compatible with the label
+style you have chosen.
+
+\item
+Choose a different label style that is compatible with the order you
+have chosen for the items.
+
+\item
+Use the \fld{label} field to override the automatically-generated
+label and leave your readers to their own devices.
+
+\end{enumerate}
+
+\end{note}
+
+\subsection{Citation sorting and compression}\label{sec:sorting}
+
+When numeric citation labels are being used and \pkg{amsrefs}
+encounters a list of multiple citations (for example,
+\verb|\cites{A,B}| or \verb|\citelist{\cite{A}\cite{B}}|), it will
+normally sort the citation labels and then compress ranges of three or
+more consecutive labels into a range of the form $n$--$m$. For
+example, the list [11, 9, 10, 1, 16, 12] would first be sorted into
+[1, 9, 10, 11, 12, 16] and then compressed into [1, 9--12, 16]. These
+options can be used to modify that behavior.
+
+\begin{description}
+
+\item[non-compressed-cites]
+
+Turn off range compression; citations will still be sorted. Range
+compression is also automatically turned off if \pkg{amsrefs} detects
+that the \pkg{hyperref} package has been loaded.\footnote{In order for
+ this to work correctly, the \pkg{hyperref} package must be loaded
+ \emph{after} the \pkg{amsrefs} package.}
+
+\item[non-sorted-cites]
+
+Turn off range sorting. This also turns off range compression as a
+side-effect.
+
+\end{description}
+
+\subsection{Abbreviations}
+
+These options emulate various aspects of the behavior of the \BibTeX\
+\bst{abbrv} style, but unlike \bst{abbrv}, they can be used with any
+of the citation label styles described above.
+
+\begin{description}
+
+\item[abbrev]
+
+This is equivalent to requesting all four of the following options.
+
+\item[initials]
+
+Replace the given names of all authors, editors, and translators with
+their initials. See section~\ref{names} for further discussion.
+
+\item[short-journals]
+
+Print short form instead of full form for journal names. This works
+only with abbreviations defined with the \cn{DefineJournal} command
+(see section~\ref{abbreviations}).
+
+\item[short-months]
+
+Print short version of month names (e.g., Jan.\ instead of January).
+This works only when you write all dates in ISO~8601 format (see
+page~\pageref{date-format}).
+
+\item[short-publishers]
+
+Print short form instead of full form for publisher names. This works
+only with abbreviations defined with the \cn{DefinePublisher} command
+(see section~\ref{abbreviations}).
+
+\end{description}
+
+\subsection{Miscellaneous options}
+
+\begin{description}
+
+\item[backrefs]
+
+This option causes ``back-references'' to be printed at the end of
+each bibliography entry to show what page it was cited on. This
+option will work only if the \pkg{hyperref} package is installed.
+
+\item[bibtex-style]
+
+By default, \pkg{amsrefs} formats references using the AMS house
+style. The \opt{bibtex-style} option instructs it to use a format that is
+very similar to the one implemented by the standard \BibTeX\ styles
+(\bst{plain}, \bst{alpha}, \bst{abbrv}, and \bst{unsrt}).
+
+\item[citation-order]
+
+This option applies only when using \pkg{amsrefs} in conjunction with
+\BibTeX. Consequently, changing this option will have no effect until
+after the next \bibtex/ run.
+
+The \opt{citation-order} option corresponds to the standard \BibTeX\
+style \bst{unsrt}, where items are printed in the reference list in
+the order in which they are cited in the document.
+
+\item[lite]
+
+Suppress the loading of the following packages, which \pkg{amsrefs}
+will normally automatically load:
+\begin{description}
+
+\item[\pkg{mathscinet}]
+
+Define a number of special characters and accents that are sometimes
+encountered when downloading data from MathSciNet.
+
+\item[\pkg{txtcmds}]
+
+Provide shorthand commands for a number of characters that are usually
+specified via ligatures (e.g., \verb|--| for an en-dash or \verb|?`|
+for ``?`''. Using these ligatures can cause problems if you're using
+fonts other than the Computer Modern Roman family or if you want to
+make it easy to convert your document to, say, HTML\@. \LaTeX\ does
+provide macros for these characters, but their names tend to be rather
+unwieldy (e.g., \cn{textendash} and \cn{textquestiondown}), so
+\pkg{txtcmds} provides shorter names (\cn{ndash} and \cn{qd} in this
+case).
+
+\end{description}
+
+\item[msc-links]
+
+Redefine the \cn{MR} command to create hypertext links to the
+MathSciNet database. This option will work only if the \pkg{hyperref}
+package is installed.
+
+\item[nobysame]
+
+If two or more consecutive bibliography items have the same authors,
+\pkg{amsrefs} will normally replace the author names in the second and
+succeeding entries by a horizontal rule (\hbox to3em{\hrulefill}).
+This option disables this feature, causing the full author names to
+always be printed.
+
+\end{description}
+
+\section{Citing entries: \cn{cite} and friends}
+
+\LaTeX's standard \cn{cite} command has two major shortcomings:
+\begin{enumerate}
+
+\item
+It takes an arbitrary number of arguments, so you can write, for
+example, \cnm{cite}{xx,yy} to get [13, 15]. But this feature does not
+interact well with the optional argument that's used to give a
+targeted citation: \cnom{cite}[Theorem 4.9]{xx} will give you [13,
+Theorem 4.9], but how do you request [13, Theorem 4.9; 15] or [13; 15,
+Theorem 4.9]?
+
+\item
+The optional argument uses the standard \LaTeX\ syntax, which has been
+shown to be errorprone. For example, a common user error is to write
+something like
+\begin{verbatim}
+ \begin{thm}[\cite[Theorem 4.9]{xyz}]
+\end{verbatim}
+(which results in a syntax error) instead of
+\begin{verbatim}
+ \begin{thm}[{\cite[Theorem 4.9]{xyz}}]
+\end{verbatim}
+
+\end{enumerate}
+
+The \pkg{amsrefs} package addresses both of these problems by
+providing separate commands for single and multiple citations and
+implementing a new syntax for optional arguments.
+
+\begin{description}
+
+\item[\cn{cite}]
+
+For backwards compatibility, the old syntax is still supported; so,
+for example, \cnm{cite}{a,b,c} and \verb|\cite[xxx]{...}| work the
+same way they always have. However, for consistency we recommend that
+you use \cn{cite} only for single cites and use \cn{citelist} (or
+\cn{cites}) for multiple citations.
+
+In addition, the square bracket notation \cnom{cite}[...]{...} is also
+deprecated, because a superior alternative is provided:
+\begin{verbatim}
+ \cite{xyz}*{Theorem 4.9}
+\end{verbatim}
+Note that this does not suffer from the syntax problems noted above,
+since
+\begin{verbatim}
+ \begin{thm}[\cite{xyz}*{Theorem 4.9}]
+\end{verbatim}
+does not have the same problems that
+\begin{verbatim}
+ \begin{thm}[\cite[Theorem 4.9]{xyz}]
+\end{verbatim}
+does.
+
+\item[\cn{citelist}]
+
+This is used to group a number of individual \cn{cite} commands into a
+single citation. Among other things, this makes it possible to add an
+optional argument to any of the \cn{cite} commands unambiguously:
+\begin{verbatim}
+ \citelist{\cite{xx} \cite{yy}*{Theorem 4.9} \cite{zz}}
+\end{verbatim}
+\textbf{Note that there is no punctuation or other text between the
+\cn{cite} commands}. Any necessary commas or other punctuation will
+be supplied automatically. Any attempts to supply it by hand will
+backfire.
+
+\item[\cn{cites}]
+
+This is a variant of \cn{citelist}, provided for convenience:
+\begin{verbatim}
+ \cites{aa,bb,cc}
+\end{verbatim}
+is equivalent to
+\begin{verbatim}
+ \citelist{\cite{aa}\cite{bb}\cite{cc}}
+\end{verbatim}
+Note that \cn{cites} does \emph{not} take an optional arguments.
+
+\item[\cn{nocite}]
+
+This continues to work the same way that it does in standard \LaTeX\
+when used with \BibTeX, but see page~\pageref{nocite} for limitations
+when it is used with \cn{bibselect} and \fn{.ltb} files.
+
+\end{description}
+
+When the \opt{author-year} option is used, there are some additional
+citation commands available, as we shall see in the next section.
+
+\subsection{Author-year citation schemes}\label{author-year}
+
+When an author-year citation scheme is used, some further
+complications arise, since different forms of citations are used
+depending on the grammatical context.
+
+The first form is used when the citation serves as a parenthetical
+annotation: i.e., it could be omitted without harming the grammatical
+structure of the sentence containing it. For example:
+\begin{quote}
+The question first arose in systems theory (Rupp and Young, 1977).
+\end{quote}
+
+The second form is like the first but is used when the author name is
+already present as a natural part of the sentence and only the year
+should be parenthesized:
+\begin{quote}
+Rupp and Young (1977) have investigated \dots
+\end{quote}
+Note that as in the first example, the material in parentheses can be
+deleted without changing the meaning of the sentence.
+
+A third form is preferred by some authors when the citation serves as
+a direct object or other nounlike role within its sentence. Consider
+the following example:
+\begin{quote}
+\dots\ for further details, see Rupp and Young (1977).
+\end{quote}
+Although this may appear at first glance identical with the second
+example, it is subtly different, since removing the parenthesized
+material results in
+\begin{quote}
+\dots\ for further details, see Rupp and Young.
+\end{quote}
+which does affect the meaning of the sentence.
+
+Another way of seeing the difference between the second and third
+examples is to consider how those sentences might read if numeric
+labels were being used:
+\begin{quote}
+Rupp and Young [14] have investigated \dots\par
+\dots\ for further details, see [14].
+\end{quote}
+Admittedly, ``see~[14]'' is poor style, but it does highlight the fact
+that in the third example ``Rupp and Young'' is part of the text we
+expect our cite command to generate, while in the second example it is
+not.
+
+%%** ``delegate''???
+
+We delegate \cn{cite} to produce the primary parenthetical form
+``(Author, Year)'' and provide \cn{ycite} (\qq{year cite}) and
+\cn{ocite} (\qq{object cite}) as the other forms. Our three examples
+would thus be coded as follows:
+\begin{verbatim}
+ The question first arose in systems theory \cite{...}.
+
+ Rupp and Young \ycite{...} have investigated
+
+ for further details, see \ocite{...}.
+\end{verbatim}
+For symmetry, a \cn{citeauthor} command, which produces the list of
+authors without the year, is also provided, and plural forms
+\cn{ycites} and \cn{ocites} are provided to mirror \cn{cites}. There
+is also a \cn{citeyear} command that is identical to \cn{ycite} except
+that it suppresses the surrounding parentheses.
+
+Finally, in some author-year styles, if there are three or more
+authors, \cn{cite} and \cn{ocite} will produce abbreviated author
+lists (``Larry et al.''\ instead of ``Larry, Moe, and Curly''). The
+``full'' variants \cn{fullcite} and \cn{fullocite} will always print
+the full list.
+
+\section{Advanced features}
+
+\subsection{Field attributes}\label{attributes}
+
+Sometimes it's necessary to associate some data with a field that is
+not actually part of the data of the field. For example, consider
+Chinese names, which are traditionally written with the family name
+first:
+\begin{quote}
+Li Lian Jie\qquad\emph{not} Li, Lian Jie \emph{or} Lian Jie Li
+\end{quote}
+Unfortunately, if you write
+\begin{verbatim}
+ author={Li, Lian Jie}
+\end{verbatim}
+you will get one of the incorrect forms above. On the other hand, if
+you try to force the correct order by writing
+\begin{verbatim}
+ author={Li Lian Jie}
+\end{verbatim}
+\pkg{amsrefs} will be unable to process the name correctly if, for
+example, the \opt{initials} or \opt{alphabetic} options are requested.
+
+To solve this problem, you can set the \attr{inverted} attribute for a
+given name as follows:
+\begin{verbatim}
+ author={Li, Lian Jie}*{inverted={yes}}
+\end{verbatim}
+As you can see, attributes are given as key-value pairs following the
+the field value and separated by an asterisk. The \attr{inverted}
+attribute can be set on any name.
+
+At present the only other attribute that is supported is
+\attr{language}, which can be set on any field. It's value should be
+a valid Babel language name and will apply only to that field. This
+can be especially useful if you need to change the hyphenation
+patterns or font encoding for a single field:
+\begin{verbatim}
+ \bib{Denecke1982}{article}{
+ author={Denecke, K.},
+ title={Pr\"aprimale Algebren, die arithmetische Variet\"aten
+ erzeugen}*{language={german}},
+ booktitle={Universal Algebra and Applications},
+ series={Banach Center Publ.},
+ volume={9},
+ publisher={PWN},
+ address={Warsaw},
+ date={1982},
+ pages={391--398}
+ }
+\end{verbatim}
+
+\subsection{Cross-references: \cn{bib*} and the \fld{xref} field}
+\label{xrefs}
+
+Distinct bibliography items often share a great deal of common data,
+especially when two or more papers from a single conference are being
+cited:
+\begin{verbatim}
+ \bib{StockmeyerM73}{article}{
+ title={Word Problems Requiring Exponential Time},
+ subtitle={Preliminary Report},
+ author={Stockmeyer, L. J.},
+ author={Meyer, A. R.},
+ pages={1--9},
+ booktitle={Conference Record of Fifth Annual ACM Symposium on
+ Theory of Computing},
+ date={1973},
+ address={Austin, Texas},
+ publisher={ACM}
+ }
+
+ \bib{Kung73}{article}{
+ title={The Computational Complexity of Algebraic Numbers},
+ author={Kung, H. T.},
+ pages={152--159},
+ booktitle={Conference Record of Fifth Annual ACM Symposium on
+ Theory of Computing},
+ date={1973},
+ address={Austin, Texas},
+ publisher={ACM}
+ }
+\end{verbatim}
+To cut down on the amount of text that has to be repeated, you can put
+the common information in a separate entry and then include it via the
+\fld{xref} field, as follows:
+\begin{verbatim}
+ \bib*{STOC5}{book}{
+ title={Conference Record of Fifth Annual ACM Symposium on
+ Theory of Computing},
+ date={1973},
+ address={Austin, Texas},
+ publisher={ACM}
+ }
+
+ \bib{StockmeyerM73}{article}{
+ title={Word Problems Requiring Exponential Time},
+ subtitle={Preliminary Report},
+ author={Stockmeyer, L. J.},
+ author={Meyer, A. R.},
+ pages={1--9},
+ xref={STOC5}
+ }
+
+ \bib{Kung73}{article}{
+ title={The Computational Complexity of Algebraic Numbers},
+ author={Kung, H. T.},
+ pages={152--159},
+ xref={STOC5}
+ }
+\end{verbatim}
+There are a number of things to take note of:
+\begin{enumerate}
+
+\item
+The \texttt{STOC5} entry uses the $*$-variant of the \cn{bib} command.
+The $*$ indicates that this entry is for use in cross-references. It
+cannot be \cn{cite}d independently and will never contribute an item
+to a \env{biblist}. If you do want the conference proceedings to
+appear as a separate item, the easiest way is to create a separate
+\cn{bib} item as follows:
+\begin{verbatim}
+ \bib{STOC5-citable}{book}{
+ xref={STOC5}
+ }
+\end{verbatim}
+
+\item
+All \cn{bib*} records must occur \emph{before} the entry that
+references them.
+
+\item
+Within a \cn{bib*} entry, \emph{all} fields should be treated as
+moving arguments (see section~C.1.3 of the \LaTeX\ manual), so any
+fragile commands should be preceded by \cn{protect}.
+
+\item
+Even though the \texttt{STOC5} record used the \fld{title} field, its
+title showed up as a \fld{booktitle} in the other records. This is
+the only case where a field is renamed when copied from the \cn{bib*}
+record.
+
+\end{enumerate}
+
+\subsection[Compound fields revisited]{Compound fields revisited:
+ compound fields\\ as cross-references}
+
+Earlier we saw how to use compound fields by embedding a set of
+key-value pairs. However, with the exception of the \fld{contribution}
+field, all compound fields can also function as cross-reference
+fields. For example, our example from page~\pageref{ex:translation}
+could equally well have been coded as
+\begin{verbatim}
+ \bib*{KostrikinS1965T}{article}{
+ journal={Soviet Math. Dokl.},
+ volume={6},
+ date={1965},
+ pages={715--718}
+ }
+
+ \bib{KostrikinS1965B}{article}{
+ author={Kostrikin, A. I.},
+ author={\v{S}afarevi\v{c}, I. R.},
+ title={Cartan pseudogroups and Lie $p$-algebras},
+ journal={Dokl. Akad. Nauk SSSR},
+ volume={168},
+ date={1965},
+ pages={740--742},
+ translation={KostrikinS1965T},
+ review={\MR{0199235}}
+ }
+\end{verbatim}
+Whether this is an improvement or not is left as an exercise for the
+reader.
+
+\subsection[Abbreviations: \cn{DefineName} et al.]{Abbreviations:
+ \cn{DefineName}, \cn{DefineJournal},\\ and \cn{DefinePublisher}}
+\label{abbreviations}
+
+The \fld{xref} mechanism is fine when there are several fields that
+you want to group together and refer to as a unit, but what if you
+want a handy abbreviation for a single field, such as an individual
+author name, journal, or publisher? These are also provided.
+After writing
+\begin{verbatim}
+ \DefineName{dmj}{Jones, David M.}
+
+ \DefinePublisher{ams}{AMS}{American Mathematical Society}{Providence}
+
+ \DefineJournal{jams}{0894-0347}
+ {J. Amer. Math. Soc.}
+ {Journal of the American Mathematical Society}
+\end{verbatim}
+you can use these abbrevations as follows:
+\begin{verbatim}
+ author={dmj} (or editor={dmj} or translator={dmj})
+
+ journal={jams}
+
+ publisher={ams}
+\end{verbatim}
+
+The second argument of \cn{DefinePublisher} is the abbreviated form of
+the publisher's name, the third argument is the full name, and the
+fourth will be used as the \fld{address}. If the
+\opt{short-publishers} option is requested, then the abbreviation will
+be used; otherwise the full name will be used.
+
+Similarly, the third argument of \cn{DefineJournal} will be used if
+the \opt{short-journals} option is requested; otherwise the fourth
+argument will be used. (The second argument is the ISSN of the
+journal, which is not currently used, but is included for future use.)
+
+\subsection{Line breaks in the bibliography}
+
+Suppose you need to recommend to \LaTeX\ that it break a line in a
+particular place. Suggesting a line break in the middle of a field
+presents no difficulties: just edit your final \fn{.bbl} file and
+insert a \cn{linebreak} command:
+\begin{verbatim}
+ subtitle={Toward a transformative hermeneutics\linebreak[3] of
+ quantum gravity},
+\end{verbatim}
+But what if you need to force a line break \emph{between} two fields?
+At first blush you might fear that
+\begin{verbatim}
+ subtitle={...hermeneutics of quantum gravity\linebreak[3]},
+\end{verbatim}
+will cause a line break before the comma that \pkg{amsrefs} normally
+inserts after the title:
+\begin{quote}
+\hfill\dots \emph{hermeneutics of quantum gravity}\linebreak[3], Social
+Text\dots
+\end{quote}
+Have no fear; \pkg{amsrefs} will detect this and automatically move
+the comma in front of the line break, as desired:
+\begin{quote}
+\hfill\dots \emph{hermeneutics of quantum gravity},\linebreak[3] Social
+Text\dots
+\end{quote}
+
+\subsection{Defining custom entry types or styles}
+
+See the documentation of \cn{BibSpec} and related commands in ``The
+\pkg{amsrefs} package'' (\fn{amsrefs.pdf}).
+
+\end{document}
diff --git a/macros/latex/contrib/amsrefs/amsrefs.dtx b/macros/latex/contrib/amsrefs/amsrefs.dtx
new file mode 100644
index 0000000000..910ef3d889
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/amsrefs.dtx
@@ -0,0 +1,8389 @@
+% \def\filename{amsrefs.dtx}
+% \def\fileversion{2.14}
+% \def\filedate{2013/03/07}
+%
+% \iffalse meta-comment
+%
+% American Mathematical Society
+% Technical Support
+% Publications Technical Group
+% 201 Charles Street
+% Providence, RI 02904
+% USA
+% tel: (401) 455-4080
+% (800) 321-4267 (USA and Canada only)
+% fax: (401) 331-3842
+% email: tech-support@ams.org
+%
+% Copyright 2001, 2004, 2006, 2007, 2010, 2012, 2013 American Mathematical Society.
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3c
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3c or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is the American Mathematical
+% Society.
+%
+% \fi
+%
+% \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}
+
+\makeatletter
+\DeclareRobustCommand{\fld}{\category@index{field}}
+\DeclareRobustCommand{\btype}{\category@index{entry type}}
+\DeclareRobustCommand{\attr}{\category@index{attribute}}
+\makeatother
+
+%\OnlyDescription
+
+\usepackage{amsrefs}
+\usepackage{multicol}
+
+\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}
+
+% 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}
+\DocInput{amsrefs.dtx}
+\PrintIndex
+\end{document}
+%</driver>
+% \fi
+%
+% \MakeShortVerb{\|}
+%
+% \maketitle
+%
+% \tableofcontents
+%
+% \section{Introduction}
+%
+% The \rpack/ is a \latex/ package for bibliographies that provides an
+% archival data format similar to the format of \bibtex/ database
+% files, but adapted to make direct processing by \latex/ 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 \latex/
+% document. This takes on its greatest significance when archiving
+% documents in \latex/ 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 \latex/ knowledge]
+%
+% All bibliography setup can be done in \latex/; 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''.
+%
+% \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 \latex/
+% 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, \latex/ 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 \latex/
+% 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 \latex/, 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 \latex/ mechanisms.
+%
+% \subsubsection{Normal \latex/ processing of cites}
+%
+% \paragraph{First \latex/ 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 \latex/ 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 \latex/. 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 \latex/ pass}
+%
+% Now the \fn{.bbl} file exists and contains some \cn{bibitem}
+% commands. At \cnm{begin}{document}, \latex/ 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 \latex/.
+% Then \latex/ 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 \latex/ 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 \latex/ pass}
+%
+% Now the \fn{.aux} file contains some \cn{bibcite} commands. Once again,
+% \latex/ reads the \fn{.aux} file when it reaches \cnm{begin}{document}.
+% \begin{enumerate}
+%
+% \item A \cnmm{bibcite}{moo}{Moody} causes \latex/ to define \cs{b@moo}
+% with `Moody' as the replacement text.
+%
+% \item If two \cn{bibcite} commands have the same citation key, \latex/
+% 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, \latex/ 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]
+\ProvidesPackage{amsrefs}[2013/03/07 v2.14]
+% \end{macrocode}
+%
+% \begin{macro}{\amsrefs@warning@nl}
+% \begin{macrocode}
+\def\amsrefs@warning@nl{\PackageWarningNoLine{amsrefs}}
+% \end{macrocode}
+% \end{macro}
+%
+% Backward handling for beta and jpa options.
+% \begin{macrocode}
+\@ifpackagewith{amsrefs}{beta}{%
+ \amsrefs@warning@nl{The beta option is obsolete}%
+}{}
+\@ifpackagewith{amsrefs}{jpa}{%
+ \amsrefs@warning@nl{The jpa option is obsolete}%
+}{}
+% \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
+% \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}{\auto@stringify}
+% \begin{macrocode}
+\def\auto@stringify#1{\def#1{\string#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
+% \latex/-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}
+%
+% \begin{macrocode}
+\DeclareBooleanOption{bibtex-style}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DeclareBooleanOption{msc-links}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\ExecuteOptions{numeric,traditional-quotes,sorted-cites,compressed-cites}
+
+\ProcessOptions\relax
+
+\ProcessExclusiveOptions
+% \end{macrocode}
+%
+% \begin{macrocode}
+\IfOption{backrefs}{%
+ \IfFileExists{backref.sty}{%
+ \RequirePackage{backref}[1999/05/30]
+ }{%
+ \amsrefs@warning@nl{The backrefs option cannot be used^^J%
+ unless the backref package is also installed.^^J%
+ (backref is part of the hyperref package)}%
+ }%
+}{}
+
+\IfOption{msc-links}{%
+ \IfFileExists{hyperref.sty}{%
+ \RequirePackage{hyperref}[1999/07/08]
+ }{
+ \amsrefs@warning@nl{The msc-links option cannot be used^^J%
+ unless the hyperref package is installed}%
+ }%
+}{}
+% \end{macrocode}
+%
+% \subsubsection{The \opt{?} option}
+%
+% \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}{accessdate}
+\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}
+}
+
+\BibSpec{webpage}{%
+ +{} {\PrintAuthors} {author}
+ +{,} { \emph} {title}
+ +{:} { \emph} {subtitle}
+ +{} { \PrintDate} {date}
+ +{,} { \url} {url}
+ +{.} { Accessed \PrintDateField} {accessdate}
+ +{.} { } {note}
+ +{.} {} {transition}
+}
+% \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 \latex/ counter for numbering bibliography items.
+% \begin{macrocode}
+\newcounter{bib}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\DefineSimpleKey{biblist}{prefix}
+\DefineSimpleKey{biblist}{labels}
+% \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}{\biblistfont}
+% \begin{macrocode}
+\newcommand{\biblistfont}{%
+ \normalfont
+ \footnotesize
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\amsrefs@@lbibitem}
+% \begin{macro}{\amsrefs@bibitem}
+% Reference processing at the AMS sometimes results in raw
+% \cs{bibitem} entries being interspersed with \cs{bib} entries in
+% a bibliography. For that to work, we need to modify
+% \cs{@lbibitem} and \cs{@bibitem} to interoperate more smoothly
+% with \pkg{amsrefs}.
+% \begin{macrocode}
+\def\amsrefs@lbibitem[#1]#2{%
+ \begingroup
+ \def\CurrentBib{#2}%
+ \def\thebib{#1}%
+ \@nmbrlistfalse
+ \item\leavevmode
+ \if@filesw
+ {\let\protect\noexpand
+ \immediate\write\@auxout{\string\bibcite{#2}{{#1}{}}}}%
+ \fi
+ \endgroup
+ \ignorespaces
+}
+
+\def\amsrefs@bibitem#1{%
+ \def\CurrentBib{#1}%
+ \item
+ \if@filesw
+ \immediate\write\@auxout{\string\bibcite{#1}{{\the\value{\@listctr}}{}}}%
+ \fi
+ \ignorespaces
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\@biblist}
+% \begin{macrocode}
+\newcommand\@biblist[1][]{%
+ \stepcounter{bib@env}
+ \biblistfont
+ \labelsep .5em\relax
+ \let\@bibitem\amsrefs@bibitem
+ \let\@lbibitem\amsrefs@lbibitem
+ \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
+ \@ifstar{\@biblistsetup}{}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@biblistsetup}
+% \begin{macrocode}
+\newcommand{\@biblistsetup}[1]{%
+ \RestrictedSetKeys{}{biblist}{\the\rsk@toks}{#1}%
+ \rkvIfEmpty{biblist}{prefix}{}{%
+ \let\amsrefs@label@prefix\biblist'prefix
+ }%
+ \rkvIfEmpty{biblist}{labels}{}{%
+ \@ifundefined{amsrefs@option@\biblist'labels}{%
+ \amsrefs@warning{Invalid label style `\biblist'labels`}%
+ }{%
+ \csname amsrefs@option@\biblist'labels\endcsname
+ }%
+ }%
+}
+% \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}}%
+ \global\let\previous@primary\@empty
+ \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}{%
+ \hfill
+ \Hy@raisedlink{\hyper@anchorstart{cite.\CurrentBib}\hyper@anchorend}%
+ [\thebib]%
+}
+% \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]{%
+ \vdef\@tempa{#1}%
+ \edef\@tempa{%
+ \edef\@nx\@tempa{\@nx\@xp\@nx\zap@space\@tempa\space\@nx\@empty}%
+ }%
+ \@tempa
+ \edef\@tempb{%
+ \@nx\@bibdef\@xp\@nx\csname setbib@#2\endcsname{#2}{\@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}%
+ \def\set:bib'book##1##2{\output@inner@xref@{##1}\@empty}%
+ \let\set:bib'conference\set:bib'book
+ \let\set:bib'partial\set:bib'book
+ \let\set:bib'reprint\set:bib'book
+ \let\set:bib'translation\set:bib'book
+}
+
+\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
+ }%
+}
+
+\def\output@inner@xref@#1{%
+ \in@={#1}%
+ \ifin@\else
+ \output@xref@{#1}%
+ \fi
+}
+% \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}{\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@resolve@xrefs
+ \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
+ \@apply\auto@protect\amsrefs@textsymbols
+ \@apply\auto@protect\amsrefs@textaccents
+ \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}
+% Depending on your point of view, this macro either puts the
+% bibitem into a canonical form or, alternatively, it fudges the
+% data to fit our model. Either way, it simplifies formatting the
+% bibliography.
+% \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}
+% Some journals have ``numbers'' but no ``volumes''. AMS house
+% style is to treat the number as volume.
+% \begin{macrocode}
+ \ifx\setbib@@\setbib@article
+ \ifx\bib'volume\@empty
+ \ifx\bib'number\@empty\else
+ \let\bib'volume\bib'number
+ \let\bib'number\@empty
+ \fi
+ \fi
+ \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 \latex/ 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}{\alpha@label@}
+% \begin{macrocode}
+\def\alpha@label@{%
+ \ifx\@empty\bib'label
+ \def\thebib{\CurrentBib}%
+ \else
+ \let\thebib\bib'label
+ \fi
+}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\amsrefs@option@numeric}
+% \begin{macrocode}
+\def\amsrefs@option@numeric{%
+ \let\alpha@label\relax
+ \let\generate@label\relax
+ % \@nmbrlisttrue
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\amsrefs@option@alphabetic}
+% \begin{macrocode}
+\def\amsrefs@option@alphabetic{%
+ \let\alpha@label\alpha@label@
+ \let\generate@label\generate@alphalabel
+ \let\calc@author@part\calc@author@part@
+ \let\@suffix@format\@alph
+ \let\append@label@year\append@label@year@
+ % \@nmbrlistfalse
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\amsrefs@option@shortalphabetic}
+% \begin{macrocode}
+\def\amsrefs@option@shortalphabetic{%
+ \let\alpha@label\alpha@label@
+ \let\generate@label\generate@alphalabel
+ \let\calc@author@part\calc@author@part@short
+ \let\@suffix@format\@arabic
+ \let\append@label@year\@empty
+ % \@nmbrlistfalse
+}
+% \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}{\DuplicateBibKeyWarning}
+% \begin{macrocode}
+\def\DuplicateBibLabelWarning{%
+ \amsrefs@warning{%
+ Duplicate biblabel stem `\current@stem ' detected.\MessageBreakNS
+ This usually means the order of the bibitems\MessageBreakNS
+ is incompatible with the style of labels\MessageBreakNS
+ you are using}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\bibcite@write}
+% \begin{macrocode}
+\def\bibcite@write#1{%
+ \if@filesw
+ \begingroup
+ \let\citesel\citesel@write
+ \csname b@#1\endcsname
+ \endgroup
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\citesel@write}
+% \begin{macrocode}
+\def\citesel@write#1#2#3#4#5{%
+ \toks@{{#3}{#4}}%
+ \immediate\write\@auxout{\string\bibcite{\CurrentBib}{\the\toks@}}%
+}
+% \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{macro}{\bib@div@mark}
+% The AMS document classes automatically take care of the page
+% marks for \cn{section*} and \cn{chapter*}, but for the standard
+% classes, we need to make sure that \cn{@mkboth} gets invoked.
+% \begin{macrocode}
+\let\bib@div@mark\@gobble
+% \end{macrocode}
+% This is verbose, but probably safer than any alternative.
+% \begin{macrocode}
+\@ifclassloaded{amsbook}{}{%
+ \@ifclassloaded{amsart}{}{%
+ \@ifclassloaded{amsproc}{}{%
+ \def\bib@div@mark#1{%
+ \@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}%
+ }%
+ }%
+ }%
+}
+% \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}%
+ \protect\bib@div@mark{#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
+ \ifx\@bibtitlestyle\undefined
+ \protect\section*{#1}%
+ \else
+ \protect\@bibtitlestyle
+ \fi
+ \protect\bib@div@mark{#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 \latex/ 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 \latex/ 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 \latex/ 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\BackCite\@gobble
+ \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}{\amsrefs@bibcite}
+% When processing the \fn{.aux} file at begin-document, this is what
+% \cs{bibcite} will do:
+% \begin{macrocode}
+\def\amsrefs@bibcite#1{\@xp\bibcite@a\csname b@#1\endcsname}
+% \end{macrocode}
+% \end{macro}
+% However, \pkg{hyperref} also redefines \cs{bibcite}, so to avoid
+% conflicts and also ensure that it doesn't matter whether
+% \pkg{amsrefs} or \pkg{hyperref} is loaded first, rather than
+% redefining \cs{bibcite} directly, we redefine it inside the
+% \fn{.aux} file.
+% \begin{macrocode}
+\AtBeginDocument{%
+ \if@filesw
+ \immediate\write\@auxout{%
+ \string\@ifundefined{amsrefs@bibcite}{}{%
+ \string\let\string\bibcite\string\amsrefs@bibcite
+ }%
+ }%
+ \fi
+% \end{macrocode}
+% For good measure, we'll redefine it here as well, even though it
+% really shouldn't matter any longer.
+% \begin{macrocode}
+ \let\bibcite\amsrefs@bibcite
+}
+% \end{macrocode}
+%
+% \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}, \pkg{showkeys} and \pkg{shaderef}
+% support}
+%
+% \begin{macro}{\shade@cite}
+% \begin{macrocode}
+\newcommand{\shade@cite}{\printref}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\format@cite}
+% \begin{macrocode}
+\def\format@cite#1{\shade@cite{\citeform{#1}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ar@hyperlink}
+% \begin{macrocode}
+\def\ar@hyperlink#1{%
+ \hyper@@link[cite]{}{cite.\extr@cite#1}{\format@cite{#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{%
+ \@ifpackageloaded{shaderef}{}{%
+ \let\shade@cite\@firstofone
+ }%
+ \@ifpackageloaded{hyperref}{}{%
+ \def\ar@hyperlink{\format@cite}%
+ \let\hyper@anchorstart\@gobble
+ \let\hyper@anchorend\relax
+ \let\Hy@raisedlink\@firstofone
+ }%
+ \@ifpackageloaded{showkeys}{%
+ \@ifpackagewith{showkeys}{notcite}{%
+ \let\ar@SK@cite\@gobble
+ }{}
+ }{%
+ \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}{\amsrefs@label@prefix}
+% \begin{macrocode}
+\let\amsrefs@label@prefix\@empty
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\thebib}
+% \begin{macrocode}
+\def\thebib{\amsrefs@label@prefix\@arabic\c@bib}
+% \end{macrocode}
+% \end{macro}
+%
+% \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\amsrefs@label@prefix
+% \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}{\calc@author@part@short}
+% \begin{macrocode}
+\def\calc@author@part@short{%
+ \@xp\@multiauthorlabel\@xp{\@tempa}%
+}%
+% \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
+ \else
+ \begingroup
+ \let\name\@firstofone
+ \@apply\auto@stringify\amsrefs@textsymbols
+ \@apply\auto@stringify\amsrefs@textaccents
+ \@ifundefined{amsrefs@stem@\current@stem}{%
+ \expandafter\gdef\csname amsrefs@stem@\current@stem\endcsname{}%
+ }{%
+ \DuplicateBibLabelWarning
+ }%
+ \endgroup
+ \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 comma 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@resolve@xrefs
+ \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@resolve@xrefs
+ \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}{\strip@MRprefix}
+% \begin{macrocode}
+\def\strip@MRprefix#1#2#3#4\@nil{%
+ \def\@tempa{#1#2#3#4}%
+ \if#1M%
+ \if#2R%
+ \def\@tempa{#3#4}%
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MR}
+% \begin{macrocode}
+\def\MR#1{%
+ \relax\ifhmode\unskip\spacefactor3000 \space\fi
+ \begingroup
+ \strip@MRprefix#1\@nil
+ \edef\@tempa{MR\@nx\MRhref{\@tempa}{\@tempa}}%
+ \@xp\endgroup
+ \@tempa
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MRhref}
+% For older versions of some AMS document classes, this patch is
+% needed.
+% \begin{macrocode}
+\providecommand{\MRhref}[2]{#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%
+}
+% \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}{\PrintDateField}
+% \begin{macrocode}
+\newcommand{\PrintDateField}[1]{%
+ \@ifempty{#1}{}{%
+ \begingroup
+ \bib@parsedate{#1}%
+ \print@full@date
+ \endgroup
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\print@full@date}
+% \begin{macrocode}
+\def\print@full@date{%
+ \ifx\bib@month\@empty
+ \else
+ \print@month@day
+ \fi
+ \bib@year
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\print@date}
+% \begin{macrocode}
+\let\print@date\print@full@date
+% \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}%
+ \let\process@citelist\process@citelist@unsorted
+ \amsrefs@option@alphabetic
+}{}
+% \end{macrocode}
+%
+% \subsubsection{The \opt{shortalphabetic} option}
+% \label{opt:shortalphabetic}
+%
+% \begin{macrocode}
+\IfOption{shortalphabetic}{%
+ \def\bibtex@style{amsrs}%
+ \let\process@citelist\process@citelist@unsorted
+ \amsrefs@option@shortalphabetic
+}{}
+% \end{macrocode}
+%
+% \subsubsection{The \opt{backrefs} option}
+% Rather than checking for the \opt{backrefs} option \emph{per se},
+% we check to see if the \pkg{backref} package is loaded. This
+% accomodates authors who load the \pkg{backref} package explicitly
+% but do not pass the \opt{backrefs} option to \pkg{amsrefs}.
+% \begin{macrocode}
+\AtBeginDocument{%
+ \@ifpackageloaded{backref}{%
+ \let\PrintBackRefs\print@backrefs
+ \let\BackCite\back@cite
+% \end{macrocode}
+% The \pkg{backref} package uses \cn{@starttoc} inside
+% \cn{thebibliography} to open and read the \fn{.brf} file. We
+% could do something similar with \cn{biblist}, but it seems
+% cleaner to use \cn{AtBeginDocument}. Unfortunately, \cls{amsart}
+% redefines \cn{@starttoc} in a way that interacts badly with this
+% use. So, we inline the relevant parts of \cn{@starttoc} here.
+% (The group and \cn{makeatletter} are unnecessary at present, but
+% I'll leave them in as future-proofing.)
+% \begin{macrocode}
+ \begingroup
+ \makeatletter
+ \@input{\jobname.brf}%
+ \if@filesw
+ \newwrite\tf@brf
+ \immediate\openout\tf@brf \jobname.brf\relax
+ \fi
+ \endgroup
+ }{}%
+}
+% \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{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{msc-links} option}
+%
+% \begin{macrocode}
+\IfOption{msc-links}{%
+% \end{macrocode}
+% Unless you're using pdf\TeX, links cannot be broken across
+% lines, which causes problems for long-form MR numbers such as
+% ``MR2149145 (2006d:01012)''. To mitigate the problem, we
+% manually break such numbers into two separate links.
+% \begin{macrocode}
+ \@ifundefined{href}{}{%
+ \def\parse@MR#1 (#2)#3\@nil{%
+ \def\MR@url{http://www.ams.org/mathscinet-getitem?mr=#1}%
+ \def\@tempd{#1}%
+ \def\@tempe{#2}%
+ }%
+ \def\MRhref#1#2{%
+ \begingroup
+ \parse@MR#1 ()\@empty\@nil%
+ \href{\MR@url}{\@tempd\vphantom{()}}%
+ \ifx\@tempe\@empty
+ \else
+ \ \href{\MR@url}{(\@tempe)}%
+ \fi
+ \endgroup
+ }%
+ }{}
+}{}
+% \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}{\@biblistsetup}
+% \begin{macrocode}
+\renewcommand{\@biblistsetup}[1]{%
+ \RestrictedSetKeys{}{biblist}{\the\rsk@toks}{#1}%
+ \rkvIfEmpty{biblist}{prefix}{}{%
+ \amsrefs@warning{%
+ The `prefix' biblist option cannot be used\MessageBreak
+ with the author-year option.%
+ }%
+ }%
+ \rkvIfEmpty{biblist}{labels}{}{%
+ \amsrefs@warning{%
+ The `labels' biblist option cannot be used\MessageBreak
+ with the author-year option.%
+ }%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \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}{\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}
+\def\BibLabel{%
+ \Hy@raisedlink{\hyper@anchorstart{cite.\CurrentBib}\relax\hyper@anchorend}%
+}
+% \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}{\citeyear}
+% \begin{macrocode}
+\DeclareRobustCommand{\citeyear}[1]{%
+ \begingroup
+ \let\citeleft\@empty
+ \let\citeright\@empty
+ \star@{\cite@a\citesel@year{#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}
+}
+
+\BibSpec{webpage}{%
+ +{} {\PrintAuthors} {author}
+ +{.} { \PrintDate} {date}
+ +{.} { \emph} {title}
+ +{:} { \emph} {subtitle}
+ +{,} { \url} {url}
+ +{.} { Accessed \PrintDateField} {accessdate}
+ +{.} { } {note}
+ +{.} {} {transition}
+}
+% \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}[2013/03/07 v2.14]
+%\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}
+}
+
+\BibSpec{webpage}{%
+ +{} {\PrintAuthors} {author}
+ +{.} { } {title}
+ +{:} { } {subtitle}
+ +{.} { \PrintDateB} {date}
+ +{.} { \url} {url}
+ +{.} { Accessed \PrintDateField} {accessdate}
+ +{.} { } {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}
+%
+% \Finale
diff --git a/macros/latex/contrib/amsrefs/amsrefs.faq b/macros/latex/contrib/amsrefs/amsrefs.faq
new file mode 100644
index 0000000000..28456522e6
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/amsrefs.faq
@@ -0,0 +1,68 @@
+amsrefs.faq [2007/10/16] American Mathematical Society
+
+Frequently asked questions about the amsrefs package and its companion
+packages.
+
+Suggestions? Please send mail to tech-support@ams.org.
+
+Copyright 2004, 2007, 2008, 2010 American Mathematical Society.
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either version 1.3c
+of this license or (at your option) any later version.
+The latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+and version 1.3c or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is the American Mathematical
+Society.
+
+American Mathematical Society
+Technical Support
+Publications Technical Group
+201 Charles Street
+Providence, RI 02904
+USA
+tel: (401) 455-4080
+ (800) 321-4267 (USA and Canada only)
+fax: (401) 331-3842
+email: tech-support@ams.org
+
+------------------------------------------------------------------------
+1) Where should I look for documentation?
+
+User documentation is found in the file amsrdoc.pdf.
+
+Some example files (cite-xa.tex, cite-xb.tex, cite-xh.tex, cite-xs.tex
+and gktest.ltb) are also provided.
+
+2) How do I define my own bibliography style?
+
+For information on customizing the formatting of references, see
+amsrefs.pdf, especially sections 4, 6.10 and 6.27.
+
+3) I'm trying to use amsrefs with hyperref, but various bad things
+ are happening.
+
+Unlike most packages, which must be loaded before hyperref, amsrefs
+must be loaded *after* hyperref:
+
+ \usepackage{hyperref}
+ \usepackage{amsrefs}
+
+4) When I put
+
+ review={MR0113214 (22 \#4052)},
+
+ in a \bib, there is no space between the review number and the
+ preceding period in the printed output.
+
+You must use the \MR macro to mark MR reviews:
+
+ review={\MR{0113214 (22 \#4052)}},
+
+This will ensure the spacing is correct and also allow you to use the
+msc-links option.
diff --git a/macros/latex/contrib/amsrefs/amsrefs.ins b/macros/latex/contrib/amsrefs/amsrefs.ins
new file mode 100644
index 0000000000..72c25ecbd1
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/amsrefs.ins
@@ -0,0 +1,76 @@
+%% filename: amsrefs.ins
+%% version: 1.01
+%% date: 2013/01/15
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 2010, 2012, 2013 American Mathematical Society.
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+\input docstrip
+
+\askforoverwritefalse
+
+\keepsilent
+
+\preamble
+
+Copyright 2001, 2004, 2006, 2007, 2010, 2012, 2013 American Mathematical Society.
+
+American Mathematical Society
+Technical Support
+Publications Technical Group
+201 Charles Street
+Providence, RI 02904
+USA
+tel: (401) 455-4080
+ (800) 321-4267 (USA and Canada only)
+fax: (401) 331-3842
+email: tech-support@ams.org
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either version 1.3c
+of this license or (at your option) any later version.
+The latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+and version 1.3c or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is the American Mathematical
+Society.
+
+\endpreamble
+
+\usedir{tex/latex/amsrefs}
+
+\generate{%
+ \file{amsrefs.sty}{\from{amsrefs.dtx}{pkg}}
+ \file{amsbst.sty}{\from{amsrefs.dtx}{bst}}
+}
+
+\endbatchfile
diff --git a/macros/latex/contrib/amsrefs/amsrefs.pdf b/macros/latex/contrib/amsrefs/amsrefs.pdf
new file mode 100644
index 0000000000..257890190d
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/amsrefs.pdf
Binary files differ
diff --git a/macros/latex/contrib/amsrefs/amsxport.dtx b/macros/latex/contrib/amsrefs/amsxport.dtx
new file mode 100644
index 0000000000..6160258c8e
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/amsxport.dtx
@@ -0,0 +1,1814 @@
+% \def\filename{amsxport.dtx}
+% \def\fileversion{2.01}
+% \def\filedate{2007/10/01}
+%
+% \iffalse meta-comment
+%
+% American Mathematical Society
+% Technical Support
+% Publications Technical Group
+% 201 Charles Street
+% Providence, RI 02904
+% USA
+% tel: (401) 455-4080
+% (800) 321-4267 (USA and Canada only)
+% fax: (401) 331-3842
+% email: tech-support@ams.org
+%
+% Copyright 2001, 2004, 2010 American Mathematical Society.
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3c
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3c or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is the American Mathematical
+% Society.
+%
+% \fi
+%
+% \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}
+\DocInput{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}{lpad}
+% Warning: The use of |text.length$| here restricts \fn{lpad}'s use
+% to strings that we know do not contain any special characters.
+% Since we only use it for field names, this is ok.
+%
+% \<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 "{vv{ } }{ll{ }}{ ff{ }}{ jj{ }}" format.name$ 't :=
+ ptr numnames = t "others" = AND
+ { "et al" }
+ { t sortify }
+ if$
+ *
+ 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
+%</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 * " " *
+ 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/macros/latex/contrib/amsrefs/amsxport.ins b/macros/latex/contrib/amsrefs/amsxport.ins
new file mode 100644
index 0000000000..8e8373e60e
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/amsxport.ins
@@ -0,0 +1,84 @@
+%% filename: amsxport.ins
+%% version: 1.0
+%% date: 2010/08/13
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 2010 American Mathematical Society.
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+\input docstrip
+
+\askforoverwritefalse
+
+\keepsilent
+
+\preamble
+
+Copyright 2001, 2004, 2010 American Mathematical Society.
+
+American Mathematical Society
+Technical Support
+Publications Technical Group
+201 Charles Street
+Providence, RI 02904
+USA
+tel: (401) 455-4080
+ (800) 321-4267 (USA and Canada only)
+fax: (401) 331-3842
+email: tech-support<at>ams.org
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either version 1.3c
+of this license or (at your option) any later version.
+The latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+and version 1.3c or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is the American Mathematical
+Society.
+
+\endpreamble
+
+% Remove \endinput from postamble
+
+\usepostamble\empty
+
+\generate{
+ \usedir{bibtex/bst/amsrefs}
+ \file{amsrn.bst}{\from{amsxport.dtx}{bst,sort,plain}}
+ \file{amsru.bst}{\from{amsxport.dtx}{bst,plain}}
+ \file{amsra.bst}{\from{amsxport.dtx}{bst,sort,alpha}}
+ \file{amsry.bst}{\from{amsxport.dtx}{bst,sort,alpha,y2k}}
+ \file{amsrs.bst}{\from{amsxport.dtx}{bst,sort,short}}
+ \usedir{bibtex/bib/amsrefs}
+ \file{amsj.bib} {\from{amsxport.dtx}{abbrevs}}
+}
+
+\endbatchfile
diff --git a/macros/latex/contrib/amsrefs/amsxport.pdf b/macros/latex/contrib/amsrefs/amsxport.pdf
new file mode 100644
index 0000000000..075f1a93f9
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/amsxport.pdf
Binary files differ
diff --git a/macros/latex/contrib/amsrefs/changes.pdf b/macros/latex/contrib/amsrefs/changes.pdf
new file mode 100644
index 0000000000..2f60eacafd
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/changes.pdf
Binary files differ
diff --git a/macros/latex/contrib/amsrefs/changes.tex b/macros/latex/contrib/amsrefs/changes.tex
new file mode 100644
index 0000000000..e538529bbd
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/changes.tex
@@ -0,0 +1,519 @@
+% \def\filename{changes.tex}
+% \def\fileversion{1.0}
+% \def\filedate{2004/06/30}
+%
+% American Mathematical Society
+% Technical Support
+% Publications Technical Group
+% 201 Charles Street
+% Providence, RI 02904
+% USA
+% tel: (401) 455-4080
+% (800) 321-4267 (USA and Canada only)
+% fax: (401) 331-3842
+% email: tech-support@ams.org
+%
+% Copyright 2004, 2007, 2010 American Mathematical Society.
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3c
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3c or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is the American Mathematical
+% Society.
+%
+% ====================================================================
+
+\documentclass[11pt]{amsdtx}
+
+%\usepackage[T1]{fontenc}
+
+\usepackage[latin1]{inputenc}
+
+\usepackage{fullpage}
+
+\usepackage{amsrefs}
+
+\MakeShortVerb{\|}
+
+\makeatletter
+
+\def\bysame{%
+ \leavevmode\hbox to3em{\hrulefill}\thinspace
+ \kern\z@
+}
+
+\DeclareRobustCommand{\fld}{\category@index{field}}
+\DeclareRobustCommand{\btype}{\category@index{entry type}}
+
+\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}{}}
+
+\newcounter{changecounter}
+
+\newcommand\change[1][]{%
+ \refstepcounter{changecounter}%
+ \medskip
+ \par
+ \noindent
+ \textbf{Change~\thechangecounter\@ifnotempty{#1}{ [#1]}.}\enskip
+ \ignorespaces
+}
+
+%% \newcommand\bugref[1]{%
+%% [#1]%
+%% }
+
+\newcounter{tableline}[table]
+
+\newcommand{\tbl}{%
+ \refstepcounter{tableline}
+ \thetableline.%
+}
+
+\makeatother
+
+\title{User-Visible Changes to the \pkg{amsrefs} Package, version~2.0}
+
+\author{David M. Jones}
+
+\date{June 30, 2004}
+
+\begin{document}
+
+\maketitle
+
+This document describes some of the user-visible changes made to the
+\pkg{amsrefs} package between version~1.23, the last public release,
+and version~2.0. This list is not exhaustive. Instead, the focus is
+on correct (or at least reasonable) user documents that would produce
+different output when processed under the two versions. In general,
+the changes discussed here fall between the following poles:
+\begin{enumerate}
+
+\item
+Version~1.23 produces results that are subtly wrong. These range from
+things that would go unnoticed by any but the most attentive reader to
+things that, even if noticed, would likely be shrugged off as
+unimportant.
+
+\item
+Version~1.23 produces results that are obviously wrong, i.e., they
+would be obvious under even the most cursory examination of the
+output. In most cases, this means the resulting document would be
+unacceptable.
+
+\end{enumerate}
+
+We don't include the even more severe category of examples where
+version~1.23 generates a fatal error since no document would be
+produced in that case. We also don't include enhancements or new
+features that depend upon new syntax, since such constructs would not
+be expected to be found in version~1.23 documents.
+
+Reference numbers in square brackets refer to bugs reported by users.
+
+\section{The \opt{initials} option}
+
+See table~\ref{tbl:initials_bugs} for illustrations of these changes.
+
+\begin{table}\small
+\caption{Bugs in the \opt{initials} option}
+\label{tbl:initials_bugs}
+\begin{tabular*}{\textwidth}{@{}ll@{\extracolsep{\fill}}l@{\extracolsep{\fill}}l@{}}
+& \textbf{Input} & \textbf{v1.23 output} & \textbf{v2.0 output} \\
+
+\tbl &
+|Doe, J.|
+& J. . Doe
+& J. Doe
+\\
+
+\tbl &
+|Doe, John R.|
+& J. R. . Doe
+& J. R. Doe
+\\
+
+\tbl &
+|Doe, Yu.|
+& Y. . Doe
+& Yu. Doe
+\\
+
+\tbl &
+|Doe, J.~R.|
+& J.~ R. . Doe
+& J. R. Doe
+\\
+
+\tbl &
+|Doe, John~Henry|
+& J. Doe
+& J. H. Doe
+\\
+
+\tbl &
+|Bing, R H| & R H. Bing & R H Bing\\
+
+\tbl &
+|Katzenbach, N. {deB}elleville|
+& @B@@@@@@@@ @@ N. Katzenbach
+& N. deB. Katzenbach
+\\
+
+\tbl &
+|Katzenbach, N. deB.|
+& @ @ @@ N. Katzenbach
+& N. deB. Katzenbach
+\\
+
+\tbl &
+\texttt{Grömov, Mårtin}
+& MÅ. Grömov
+& M. Grömov
+\\
+
+\tbl &
+|Doe, {Yu}ri|
+& Y. Doe
+& Yu. Doe
+
+\end{tabular*}
+\end{table}
+
+\change[B-2005]\label{chng:final_dots}
+When a given name ends in a period, an extra space and period would be
+appended to the name. Lines 1 and~2 in table~\ref{tbl:initials_bugs}
+illustrate the most common cases. Line~3 illustrates a related case
+that is both a bug fix and an enhancement (cf.\ lines 7 and~8):
+initials consisting of multiple characters were not recognized (cf.\
+change~\ref{chng:multi_char_inits}).
+
+\change[B-2005a]
+Ties (|~|) between given names resulted in incorrect output, either
+extra space (line~4) or a dropped initial (line~5). Since \bibtex/
+automatically generates ties, this problem occurs frequently when
+using \bst{amsxport}.
+
+\change
+A name consisting of a single letter would receive an erroneous period
+(line~6).
+
+\change\label{chng:initial_lowercase}
+Names beginning with lowercase letters were handled badly (lines 7
+and~8) (cf.\ change~\ref{chng:multi_char_inits}).
+
+\change
+Extended character sets were not handled well. For example, when
+using T1 fonts, lowercase 8-bit characters were not processed
+correctly (line~9).
+
+\change\label{chng:multi_char_inits}
+There was no way to indicate a multi-character initial
+(line~10). (Cf.\ changes \ref{chng:final_dots}
+and~\ref{chng:initial_lowercase}).
+
+\section{The \fld{xref} field}
+
+\change[B-2009]
+Repeatable fields (such as \fld{editor}) were not inherited via the
+\fld{xref} field. Consider the following example:
+\begin{verbatim}
+ \bib*{icalp77}{proceedings}{
+ editor={Arto Salomaa},
+ editor={Magnus Steinby},
+ title={Automata, Languages and Programming, Fourth Colloquium}
+ }
+
+ \bib{AhoS1977}{article}{
+ title={How Hard is Compiler Code Generation?},
+ author={Alfred V. Aho},
+ author={Ravi Sethi},
+ xref={icalp77},
+ pages={1\ndash 15}
+ }
+\end{verbatim}
+Version~1.23 would produce
+\begin{quote}
+Alfred V. Aho and Ravi Sethi, \emph{How Hard is Compiler Code
+ Generation?}, Automata, Languages and Programming, Fourth
+ Colloquium, pp.~1--15.
+\end{quote}
+(without the editors) instead of
+\begin{quote}
+Alfred V. Aho and Ravi Sethi, \emph{How Hard is Compiler Code
+ Generation?}, Automata, Languages and Programming, Fourth Colloquium
+ (Arto Salomaa and Magnus Steinby, eds.), pp.~1--15.
+\end{quote}
+Other additive keys like \fld{author}, \fld{isbn} and \fld{review}
+would similarly be dropped.
+
+\section{The \opt{alphabetic} option}
+
+%% \change[B-2013]\label{chng:b2013}
+%% A compound citation such as
+%% \begin{verbatim}
+%% \citelist{ \cite{SS75}*{Theorem 1} \cite{TM86}*{Prop. 2} }
+%% \end{verbatim}
+%% used to produce
+%% \begin{quote}
+%% [SS75, Theorem 1, TM86, Prop. 2]
+%% \end{quote}
+%% whereas version~2.0 correctly separates the citations with a
+%% semi-colon instead of a comma:
+%% \begin{quote}
+%% [SS75, Theorem 1; TM86, Prop. 2]
+%% \end{quote}
+
+\change[B-2009]
+In version~1.23, generation of alphabetic labels was done by \bibtex/
+rather than by \fn{amsrefs.sty}. This means that if you did not use
+\bibtex/ to generate your \cs{bib} entries from a \fn{.bib} file,
+\pkg{amsrefs} would use the author's citation key as the alphabetic
+label\footnote{It was also possible for the user to supply a different
+alphabetic label using the \fld{label} field, but this feature was
+undocumented.}. This means that an entry such as
+\begin{verbatim}
+ \bib{D1999}{article}{
+ author={Doe, John~R.},
+ year={1999}
+ }
+\end{verbatim}
+would appear as
+\begin{quote}
+[D1999] John R. Doe (1999).
+\end{quote}
+while if the same entry was generated from a \fn{.bib} file using
+\bst{amsxport}, the entry would appear as
+\begin{quote}
+[Doe99] John R. Doe (1999).
+\end{quote}
+This approach had a number of problems, such as lack of uniformity, so
+in version~2.0, it is \pkg{amsrefs.sty} that generates the alphabetic
+label, not \bibtex/, and the entry above would appear as [Doe99] even
+if \bibtex/ is not used.
+
+\section{Changes to bibliography style}
+
+\change
+A book with both an author and an editor, for example,
+\begin{verbatim}
+ \bib{X}{book}{
+ author={Doe, John},
+ editor={Crow, Jack},
+ title={Book with one author and one editor}
+ }
+\end{verbatim}
+would be formatted as
+\begin{quote}
+ John DoeJack Crow (ed.), \emph{Book with one author and one editor}.
+\end{quote}
+rather than
+\begin{quote}
+ John Doe, \emph{Book with one author and one editor}. Edited by
+ Jack Crow.
+\end{quote}
+
+\change
+Editors did not participate in the automatic \cs{bysame} processing,
+so if you had two books by the same editor, e.g.
+\begin{verbatim}
+ \bib{A}{book}{
+ editor={Crow, Jack},
+ title={First book}
+ }
+
+ \bib{B}{book}{
+ editor={Crow, Jack},
+ title={Second book}
+ }
+\end{verbatim}
+the result would be
+\begin{quote}
+[1] Jack Crow (ed.), \emph{First book}.
+
+[2] Jack Crow (ed.), \emph{Second book}.
+\end{quote}
+instead of
+\begin{quote}
+[1] Jack Crow (ed.), \emph{First book}.
+
+[2] \bysame (ed.), \emph{Second book}.
+\end{quote}
+
+Consider also what happens if we change the |editor| in the first
+entry to |author|:
+\begin{quote}
+[1] Jack Crow, \emph{First book}.
+
+[2] Jack Crow (ed.), \emph{Second book}.
+\end{quote}
+versus
+\begin{quote}
+[1] Jack Crow, \emph{First book}.
+
+[2] \bysame (ed.), \emph{Second book}.
+\end{quote}
+
+\change
+Some changes have been made to punctuation and order of fields to
+bring the \pkg{amsrefs} format into line with the AMS house style.
+
+\section{\cs{cite}-like commands}
+
+\change
+The \cs{ycites}, \cs{ocites}, \cs{fullcite} and \cs{fullocite}
+commands for author-year citations were not implemented in
+version~1.23. Instead, they produced a warning on the terminal and
+then behaved identically to the \cs{cites}, \cs{cite} or \cs{ocite}
+commands. They will be implemented in version~2.0 and thus produce
+different output. Table~\ref{tbl:cites} illustrates the changes.
+
+\begin{table}[hb]\small
+\caption{The \cs{cite}-like commands}\label{tbl:cites}
+\begin{center}
+\begin{minipage}{.9\textwidth}\small
+Consider the following entries:
+\begin{quote}
+ Crow, Jack, John Doe, and John Bull. 1999.\,\dots
+
+ Doe, John. 2000.\,\dots
+\end{quote}
+If the citation keys for the items are ``A'' and~``B'', respectively,
+the various \cs{cite} commands would produce the following:
+
+\begin{tabular*}{\textwidth}{@{}ll@{\extracolsep{\fill}}l@{\extracolsep{\fill}}l@{}}
+& \textbf{Input} & \textbf{v1.23 output} & \textbf{v2.0 output} \\
+
+\tbl &
+|\cite{A}|
+& (Crow et al., 1999)
+& (Crow et al., 1999)
+\\
+
+\tbl &
+|\fullcite{A}|
+& (Crow et al., 1999)
+& (Crow, Doe, and Bull, 1999)
+\\
+
+\tbl &
+|\ocite{A}|
+& Crow et al. (1999)
+& Crow et al. (1999)
+\\
+
+\tbl &
+|\fullocite{A}|
+& Crow et al. (1999)
+& Crow, Doe, and Bull (1999)
+\\
+
+\tbl &
+|\cites{A,B}|
+& (Crow et al., 1999; Doe, 2000)
+& (Crow et al., 1999; Doe, 2000)
+\\
+
+\tbl &
+|\ycites{A,B}|
+& (Crow et al., 1999; Doe, 2000)
+& (1999, 2000)
+\\
+
+\tbl &
+|\ocites{A,B}|
+& (Crow et al., 1999; Doe, 2000)
+& Crow et al. (1999) and Doe (2000)
+\\
+
+\end{tabular*}
+\end{minipage}
+\end{center}
+\end{table}
+
+\change
+Citation-sorting did not always work correctly when there were
+optional arguments involved. So,
+\begin{verbatim}
+ \citelist{\cite{2} \cite{1} \cite{3}}
+\end{verbatim}
+would correctly produce
+\begin{quote}
+ [1--3]
+\end{quote}
+but
+\begin{verbatim}
+ \citelist{\cite{2} \cite{1} \cite{3}*{Theorem 1}}
+\end{verbatim}
+would produce
+\begin{quote}
+ [1, 3, Theorem 1; 2]
+\end{quote}
+instead of
+\begin{quote}
+ [1; 2; 3, Theorem 1]
+\end{quote}
+Note also that version~2.0 correctly switches to using semi-colons
+while version~1.23 erroneously used a comma between the first and
+second items.% (cf.\ change~\ref{chng:b2013}).
+
+\section{The \pkg{inicap} package and \cs{EnglishInitialCaps}}
+
+\change
+
+As of version~2.0, \pkg{amsrefs} no longer attempts to adjust the
+capitalization of book titles. Version~1.23 shipped with a package
+called \pkg{inicap} that provided a function for converting English
+titles from normal upper/lower case to \qq{initial caps} form. For
+example, if an author typed
+\begin{verbatim}
+ booktitle={Group rings, crossed products and Galois theory}
+\end{verbatim}
+\pkg{amsrefs} would automatically adjust it to
+\begin{quote}
+ Group Rings, Crossed Products and Galois Theory
+\end{quote}
+However, \pkg{inicap} is incomplete and produces incorrect results in
+cases like the following:
+\begin{quote}
+\verb+Term rewriting with sharing and memo{\"\i}zation+\hfill\break
+\i Term Rewriting with Sharing and memo\"zation
+
+\medskip
+
+\verb+The \ldq low $M^*$-estimate\rdq\ for covering numbers+\hfill\break
+The \ldq low $M^*$-estimate\rdq\ for Covering Numbers
+\hfill\break(where ``low'' and ``estimate'' should be capitalized)
+
+\end{quote}
+and an example like the following, which uses the \verb+\qq+ command
+that we recommend, would result in a fatal error:
+\begin{quote}
+\verb+The \qq{low $M^*$-estimate} for covering numbers+
+\end{quote}
+
+In addition, this feature was of limited usefulness since it was only
+applied to book titles. Authors should already be accustomed to
+taking full responsibility for the capitalization of book titles since
+\bibtex/ does not alter the capitalization of book titles.
+
+The low utility of the feature does not seem to warrant the effort
+that would be required to make the \pkg{inicap} package robust enough
+for use in a production environment, so we have decided instead to
+deprecate it and remove this functionality from the \pkg{amsrefs}
+package.
+
+\end{document}
diff --git a/macros/latex/contrib/amsrefs/cite-xa.tex b/macros/latex/contrib/amsrefs/cite-xa.tex
new file mode 100644
index 0000000000..4444fd5ce6
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/cite-xa.tex
@@ -0,0 +1,253 @@
+%% filename: cite-xa.tex
+%% version: 1.00
+%% date: 2004/06/30
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 2004, 2010 American Mathematical Society.
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+\documentclass{article}
+\usepackage[author-year]{amsrefs}
+
+\newcommand{\latin}{\emph}
+
+\begin{document}
+
+\title{Evolutionary walks through a land plant morphospace}
+\author{Karl J. Niklas}
+\def\jinfo{Journal of Experimental Botany, Vol. 50, No. 330, pp. 39-52,
+ January 1999, \copyright\ Oxford University Press 1999}
+
+\maketitle
+\section{Introduction}
+
+Wright's protocol has been successfully recast in terms of spatial
+domains containing all (or at least many) of the conceivable
+morphological variants (`morphospaces' \latin{sensu}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%Thomas and Reif, 1993).
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ocite{TR93}).
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+In this paper, I review the construction of a morphospace for early land
+plants
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%(Niklas and Kerchner, 1984; Niklas, 1997a, b)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\cites{NK84,N97-adaptive-walks,N97-effects}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+and show how it can be used \ldots.
+
+\ldots\ horizontally cantilevered branches impose the largest bending
+moments on subtending branches
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%(Niklas, 1992, 1994a).
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\cites{N92,N94-allometry}.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\ldots\ This definition removes the sharp dichotomy said to exist
+between `object' and `process' complexity (i.e. the number of different
+parts in an organic system versus the number of different interactions
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%among them; McShea, 1996).
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+among them \cite{M96}).
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\ldots\ fossil record for Devonian and Carboniferous vascular land
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%plants (Niklas et al., 1980, 1983; Gensel and Andrews, 1984).
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+plants \cites{NTK80,NTK83,GA84}.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\begin{bibsection}
+\begin{biblist}
+
+\bib*{HSW80}{collection}{
+ editor={Hecht, M.},
+ editor={Steere, W.},
+ editor={Wallace, B.},
+ date={1980},
+ title={Evolutionary biology},
+ publisher={Plenum Publishing},
+ address={New York},
+}
+
+\bib{fn95}{article}{
+ author={Farnsworth, K. D.},
+ author={Niklas, K. J.},
+ date={1995},
+ title={Theories of optimization, form and function in branching
+ architectures in plants},
+ journal={Functional Ecology},
+ volume={9},
+ pages={355\ndash 363},
+}
+
+\typeout{}
+\typeout{ [Testing some of the amsrefs warning messages ...]}
+
+\bib{GMW81}{book}{
+ author={Gill, P. E.},
+ author={Murray, W.}
+ author={Wright, M. H.},
+ date={1981},
+ title={Practical optimization},
+ publisher={Academic Press},
+ address={London},
+}
+
+\bib{GA84}{book}{
+ author={Gensel, P. G.},
+ author={Andrews, H. N.},
+ date={1984},
+ title={Plant life in the Devonian},
+ publisher={Praeger Press},
+ address={New York},
+}
+
+\bib{M96}{article}{
+ author={McShea, D. W.},
+ date={1996},
+ title={Metazoan complexity and evolution: is there a trend},
+ journal={Evolution},
+ volume={50},
+ pages={477\ndash 492},
+}
+
+\bib{MWWW73}{book}{
+ author={Meredith, D. D.},
+ author={Wong, K. W.},
+ author={Woodhead, R. W.},
+ author={Wortman, R. H.},
+ date={1973},
+ title={Design and planning of engineering systems},
+ publisher={Prentice-Hall},
+ address={Englewood Cliffs, New Jersey},
+}
+
+\bib{N92}{book}{
+ author={Niklas, K. J.},
+ date={1992},
+ title={Plant biomechanics: an engineering approach to plant form and
+ function},
+ publisher={University of Chicago Press},
+ address={Illinois},
+}
+
+\bib{N94-allometry}{book}{
+ author={Niklas, K. J.},
+ date={1994},
+ title={Plant allometry: the scaling of form and process},
+ publisher={University of Chicago Press},
+ address={Illinois},
+}
+
+\bib{N94-simulation}{article}{
+ author={Niklas, K. J.},
+ date={1994},
+ title={Simulation of organic shape: the roles of phenomenology and
+ mechanism},
+ journal={Journal of Morphology},
+ volume={219},
+ pages={243\ndash 246},
+}
+
+\bib{N97-adaptive-walks}{article}{
+ author={Niklas, K. J.},
+ date={1997},
+ title={Adaptive walks through fitness landscapes for early vascular
+ land plants},
+ journal={American Journal of Botany},
+ volume={84},
+ pages={16\ndash 25},
+}
+
+\bib{N97-effects}{article}{
+ author={Niklas, K. J.},
+ date={1997},
+ title={Effects of hypothetical developmental barriers and abrupt
+ environmental changes on adaptive walks in a computer-generated
+ domain for early vascular land plants},
+ journal={Paleobiology},
+ volume={23},
+ pages={63\ndash 76},
+}
+
+\bib{NK84}{article}{
+ author={Niklas, K. J.},
+ author={Kerchner, V.},
+ date={1984},
+ title={Mechanical and photosynthetic constraints on the evolution of
+ plant shape},
+ journal={Paleobiology},
+ volume={10},
+ pages={79\ndash 101},
+}
+
+\bib{NTK80}{article}{
+ author={Niklas, K. J.},
+ author={Tiffney, B. H.},
+ author={Knoll, A. H.},
+ date={1980},
+ title={Apparent changes in the diversity of fossil plants: a
+ preliminary assessment},
+ xref={HSW80},
+ volume={12},
+ pages={1\ndash 89},
+}
+
+\bib{NTK83}{article}{
+ author={Niklas, K. J.},
+ author={Tiffney, B. H.},
+ author={Knoll, A. H.},
+ date={1983},
+ title={Patterns in vascular land plant diversification},
+ journal={Nature},
+ volume={303},
+ pages={614\ndash 616},
+}
+
+\bib{TR93}{article}{
+ author={Thomas, R. D. K.},
+ author={Reif, W.-E.},
+ % This is just to show what the warning looks like for an empty field:
+ author={},
+ date={1993},
+ title={The skeleton space: a finite set of organic designs},
+ journal={Evolution},
+ volume={47},
+ pages={341\ndash 360},
+}
+
+\end{biblist}
+\end{bibsection}
+
+\end{document}
diff --git a/macros/latex/contrib/amsrefs/cite-xb.tex b/macros/latex/contrib/amsrefs/cite-xb.tex
new file mode 100644
index 0000000000..87646eb51a
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/cite-xb.tex
@@ -0,0 +1,130 @@
+%% filename: cite-xb.tex
+%% version: 1.00
+%% date: 2004/06/30
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 2004, 2010 American Mathematical Society.
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+\documentclass{amsart}
+
+\usepackage{amsrefs}
+
+\newtheorem{thm}{Theorem}[section]
+
+\begin{document}
+
+\title{Citation tests}
+
+\author{Michael Downes}
+
+ The following examples are derived from
+ \emph{Homology manifold bordism} by Heather Johnston and Andrew
+ Ranicki (Trans.\ Amer.\ Math.\ Soc.\ \textbf{352} no 11 (2000), PII: S
+ 0002-9947(00)02630-1).
+
+\bigskip \noindent \rule{\columnwidth}{0.5pt}\par
+
+\setcounter{section}{3}
+
+The results of Johnston \cite{Jo} on homology
+manifolds are extended here. It is not
+possible to investigate transversality by
+geometric methods---as in \cite{Jo} we employ
+bordism and surgery instead.
+
+The proof of transversality is indirect,
+relying heavily on surgery theory\mdash see
+Kirby and Siebenmann \cite{KS}*{III, \S 1},
+Marin \cite{M} and Quinn \cite{Q3}. We shall
+use the formulation in terms of topological
+block bundles of Rourke and Sanderson
+\cite{RS}.
+
+$Q$ is a codimension $q$ subspace by Theorem
+4.9 of Rourke and Sanderson \cite{RS}.
+(Hughes, Taylor and Williams \cite{HTW}
+obtained a topological regular neighborhood
+theorem for arbitrary submanifolds \dots.)
+
+Wall \cite{Wa}*{Chapter 11} obtained a
+codimension $q$ splitting obstruction \dots.
+
+\dots\ following the work of Cohen \cite{Co}
+on $PL$ manifold transversality.
+
+In this case each inverse image is
+automatically a $PL$ submanifold of
+codimension $\sigma$ (Cohen \cite{Co}), so
+there is no need to use $s$-cobordisms.
+
+Quinn \cite{Q2}*{1.1} proved that \dots
+
+\begin{thm}[The additive structure of
+ homology manifold bordism, Johnston
+ \cite{Jo}]
+\dots
+\end{thm}
+
+For $m\geq 5$ the Novikov-Wall surgery theory
+for topological manifolds gives an exact
+sequence (Wall \cite{Wa}*{Chapter 10}.
+
+The surgery theory of topological manifolds
+was extended to homology manifolds in Quinn
+\cites{Q1,Q2} and Bryant, Ferry, Mio
+and Weinberger \cite{BFMW}.
+
+The 4-periodic obstruction is equivalent to
+an $m$-dimensional homology manifold, by
+\cite{BFMW}.
+
+Thus, the surgery exact sequence of
+\cite{BFMW} does not follow Wall \cite{Wa} in
+relating homology manifold structures and
+normal invariants.
+
+\dots\ the canonical $TOP$ reduction
+(\cite{FP}) of the Spivak normal fibration of
+$M$ \dots
+
+\begin{thm}[Johnston \cite{Jo}]
+\dots
+\end{thm}
+
+Actually \cite{Jo}*{(5.2)} is for $m\geq 7$,
+but we can improve to $m\geq 6$ by a slight
+variation of the proof as described below.
+
+(This type of surgery on a Poincar\'e space
+is in the tradition of Lowell Jones
+\cite{Jn}.)
+
+\bibliographystyle{amsxport}
+\bibliography{jr}
+
+\end{document}
diff --git a/macros/latex/contrib/amsrefs/cite-xh.tex b/macros/latex/contrib/amsrefs/cite-xh.tex
new file mode 100644
index 0000000000..d0b50a7284
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/cite-xh.tex
@@ -0,0 +1,143 @@
+%% filename: cite-xh.tex
+%% version: 1.00
+%% date: 2004/06/30
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 2004, 2010 American Mathematical Society.
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+%&pdfelatex
+%% This is intended to be a working example of using the amsrefs
+%% backrefs option in conjunction with hyperref. It works for me using
+%% pdflatex [mjd,2002-01-03]. Cf testbib.tex in the hyperref distrib.
+%%
+%% This is pdfTeX, Version 3.14159-14h-released-20010417 (Web2C 7.3.3.1)
+%% (format=pdflatex 2001.12.21)
+%% Package: hyperref 2000/01/22 v6.69c Hypertext links for LaTeX
+
+\documentclass{article}
+\usepackage{times}
+\usepackage[colorlinks,citecolor=red,pagebackref,hypertexnames=false]{hyperref}
+\usepackage[backrefs]{amsrefs}
+
+\newtheorem{thm}{Theorem}[section]
+
+\providecommand{\MR}{}
+
+\begin{document}
+\title{Testing amsrefs with the hyperref package}
+\author{MJD}
+\maketitle
+
+ The following examples are derived from
+ \emph{Homology manifold bordism} by Heather Johnston and Andrew
+ Ranicki (Trans.\ Amer.\ Math.\ Soc.\ \textbf{352} no 11 (2000), PII: S
+ 0002-9947(00)02630-1).
+
+\setcounter{section}{3}
+\section{Homology manifold bordism}
+
+The results of Johnston \cite{Jo} on homology
+manifolds are extended here. It is not
+possible to investigate transversality by
+geometric methods---as in \cite{Jo} we employ
+bordism and surgery instead.
+
+%Kirby and Siebenmann \cite{KS} (III,\S 1),
+The proof of transversality is indirect,
+relying heavily on surgery theory\mdash see
+Kirby and Siebenmann \cite{KS}*{III, \S 1},
+Marin \cite{M} and Quinn \cite{Q3}. We shall
+use the formulation in terms of topological
+block bundles of Rourke and Sanderson
+\cite{RS}.
+
+$Q$ is a codimension $q$ subspace by Theorem
+4.9 of Rourke and Sanderson \cite{RS}.
+(Hughes, Taylor and Williams \cite{HTW}
+obtained a topological regular neighborhood
+theorem for arbitrary submanifolds \dots.)
+
+%Wall \cite{Wa} (Chapter 11) obtained a
+Wall \cite{Wa}*{Chapter 11} obtained a
+codimension $q$ splitting obstruction \dots.
+
+\dots\ following the work of Cohen \cite{Co}
+on $PL$ manifold transversality.
+
+In this case each inverse image is
+automatically a $PL$ submanifold of
+codimension $\sigma$ (Cohen \cite{Co}), so
+there is no need to use $s$-cobordisms.
+
+%Quinn (\cite{Q2}, 1.1) proved that \dots
+Quinn \cite{Q2}*{1.1} proved that \dots
+
+\begin{thm}[The additive structure of
+ homology manifold bordism, Johnston
+ \cite{Jo}]
+\dots
+\end{thm}
+
+For $m\geq 5$ the Novikov-Wall surgery theory
+for topological manifolds gives an exact
+sequence (Wall \cite{Wa}*{Chapter 10}.
+
+The surgery theory of topological manifolds
+was extended to homology manifolds in Quinn
+\cites{Q1,Q2} and Bryant, Ferry, Mio
+and Weinberger \cite{BFMW}.
+
+The 4-periodic obstruction is equivalent to
+an $m$-dimensional homology manifold, by
+\cite{BFMW}.
+
+Thus, the surgery exact sequence of
+\cite{BFMW} does not follow Wall \cite{Wa} in
+relating homology manifold structures and
+normal invariants.
+
+\dots\ the canonical $TOP$ reduction
+(\cite{FP}) of the Spivak normal fibration of
+$M$ \dots
+
+\begin{thm}[Johnston \cite{Jo}]
+\dots
+\end{thm}
+
+Actually \cite{Jo}*{(5.2)} is for $m\geq 7$,
+but we can improve to $m\geq 6$ by a slight
+variation of the proof as described below.
+
+(This type of surgery on a Poincar\'e space
+is in the tradition of Lowell Jones
+\cite{Jn}.)
+
+\bibliographystyle{amsxport}
+\bibliography{jr}
+
+\end{document}
diff --git a/macros/latex/contrib/amsrefs/cite-xs.tex b/macros/latex/contrib/amsrefs/cite-xs.tex
new file mode 100644
index 0000000000..a4f2eae6e8
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/cite-xs.tex
@@ -0,0 +1,51 @@
+%% filename: cite-xs.tex
+%% version: 1.00
+%% date: 2004/06/30
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 2004, 2010 American Mathematical Society.
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+\documentclass{amsart}
+\usepackage{amsrefs}
+
+\begin{document}
+
+\section{Introduction}
+
+A single cite \cite{MR1451594}
+and a multiple \cites{Weyl,Gould,Rob,MR95f:17013,Ser77}.
+And then with an option in the middle:
+\citelist{\cite{Rob} \cite{Gould} \cite{MR95f:17013}*{Chapter 18}}.
+
+\begin{bibsection}
+\begin{biblist}
+\bibselect{gktest}
+\end{biblist}
+\end{bibsection}
+
+\end{document}
diff --git a/macros/latex/contrib/amsrefs/gktest.ltb b/macros/latex/contrib/amsrefs/gktest.ltb
new file mode 100644
index 0000000000..cad1401a60
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/gktest.ltb
@@ -0,0 +1,472 @@
+%% filename: gktest.ltb
+%% version: 1.00
+%% date: 2004/06/30
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 2004, 2010 American Mathematical Society.
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+\documentclass{amsbook}
+\usepackage{amsrefs}
+\providecommand{\cyr}{}
+\providecommand{\cprime}{\textprime}
+\providecommand{\germ}{\mathfrak }
+
+\begin{document}
+\begin{bibdiv}
+\begin{biblist}
+
+\bib{MR58:27738}{book}{
+ author={Andrews, G.~E.},
+ title={The theory of partitions},
+ publisher={Encyclopedia of Mathematics and its Applications, Vol. 2,
+ Addison-Wesley, Mass.-London-Amsterdam},
+ date={1976},
+}
+
+\bib{MR90b:82001}{book}{
+ author={Baxter, R.~J.},
+ title={Exactly solved models in statistical mechanics},
+ publisher={Academic Press Inc.},
+ address={London},
+ date={1989},
+ ISBN={0-12-083182-1},
+}
+
+\bib{MR1451594}{article}{
+ author={Benkart, G.},
+ author={Kang, S.-J.},
+ author={Melville, D.},
+ title={Quantized enveloping algebras for Borcherds superalgebras},
+ date={1998},
+ ISSN={0002-9947},
+ journal={Trans. Amer. Math. Soc.},
+ volume={350},
+ number={8},
+ pages={3297\ndash 3319},
+}
+
+\bib{MR95d:17023}{article}{
+ author={Benkart, G.},
+ author={Kang, S.-J.},
+ author={Misra, K.~C.},
+ title={Indefinite Kac-Moody algebras of classical type},
+ date={1994},
+ ISSN={0001-8708},
+ journal={Adv. Math.},
+ volume={105},
+ number={1},
+ pages={76\ndash 110},
+}
+
+\bib{MR93d:17017}{article}{
+ author={Chari, V.},
+ author={Pressley, A.},
+ title={Quantum affine algebras},
+ date={1991},
+ ISSN={0010-3616},
+ journal={Comm. Math. Phys.},
+ volume={142},
+ number={2},
+ pages={261\ndash 283},
+}
+
+\bib{MR26:2519}{book}{
+ author={Curtis, Charles~W.},
+ author={Reiner, Irving},
+ title={Representation theory of finite groups and associative algebras},
+ publisher={Interscience Publishers, a division of John Wiley \& Sons, New
+ York-London},
+ date={1962},
+ review={\MR{26 \#2519}},
+}
+
+\bib{Dr86}{incollection}{
+ author={Drinfel$'$d, V.~G.},
+ title={Quantum Groups},
+ date={1987},
+conference={
+ title={Proceedings of the International Congress of Mathematicians},
+ address={Berkeley},
+ date={1986}
+},
+ publisher={American Mathematical Society, Providence},
+ pages={798\ndash 820},
+}
+
+\bib{MR94d:17032}{article}{
+ author={Feingold, A.~J.},
+ author={Frenkel, I.~B.},
+ author={Ries, J.~F.~X.},
+ title={Representations of hyperbolic Kac-Moody algebras},
+ date={1993},
+ ISSN={0021-8693},
+ journal={J. Algebra},
+ volume={156},
+ number={2},
+ pages={433\ndash 453},
+}
+
+\bib{MR84f:17004}{article}{
+ author={Frenkel, I.~B.},
+ author={Kac, V.~G.},
+ title={Basic representations of affine Lie algebras and dual resonance
+ models},
+ date={1981},
+ ISSN={0020-9910},
+ journal={Invent. Math.},
+ volume={62},
+ number={1},
+ pages={23\ndash 66},
+}
+
+\bib{Gould}{article}{
+ author={Gould, M.~D.},
+ author={Zhang, R.~B.},
+ author={Bracken, A.~J.},
+ title={Quantum double construction for graded Hopf algebras},
+ date={1993},
+ journal={Bull. Austral. Math. Soc.},
+ volume={47},
+ pages={353\ndash 375},
+}
+
+\bib{MR1633090}{article}{
+ author={Hong, J.},
+ author={Kang, S.-J.},
+ author={Miwa, T.},
+ author={Weston, R.},
+ title={Mixing of ground states in vertex models},
+ date={1998},
+ ISSN={0305-4470},
+ journal={J. Phys. A},
+ volume={31},
+ number={28},
+ pages={L515\ndash L525},
+}
+
+\bib{Jac1}{book}{
+ author={Jacobson, N.},
+ title={Basic algebra II},
+ publisher={W. H. Freeman and Company},
+ address={San Francisco},
+ date={1980},
+ ISBN={0-7167-1079-X (v. 2)},
+}
+
+\bib{MR98k:17037}{article}{
+ author={Jeong, K.},
+ author={Kang, S.-J.},
+ author={Lee, H.},
+ title={Lie-admissible algebras and Kac-Moody algebras},
+ date={1997},
+ ISSN={0021-8693},
+ journal={J. Algebra},
+ volume={197},
+ number={2},
+ pages={492\ndash 505},
+}
+
+\bib{Joseph}{book}{
+ author={Joseph, A.},
+ title={Quantum groups and their primitive ideals},
+ publisher={Springer-Verlag},
+ address={Berlin},
+ date={1995},
+ ISBN={3-540-57057-8},
+}
+
+\bib{Kac90}{book}{
+ author={Kac, V.~G.},
+ title={Infinite dimensional Lie algebras},
+ edition={3},
+ publisher={Cambridge University Press},
+ address={Cambridge},
+ date={1990},
+ ISBN={0-521-37215-1; 0-521-46693-8},
+}
+
+\bib{KMW}{incollection}{
+ author={Kac, V.~G.},
+ author={Moody, R.~V.},
+ author={Wakimoto, M.},
+ title={On ${E}\sb {10}$},
+ date={1988},
+conference={
+ title={Differential geometrical methods in theoretical physics},
+ address={Como},
+ date={1987}
+},
+ publisher={Kluwer Acad. Publ.},
+ address={Dordrecht},
+ pages={109\ndash 128},
+}
+
+\bib{Ka93-1}{article}{
+ author={Kang, S.-J.},
+ title={Root multiplicities of the hyperbolic Kac-Moody Lie algebra
+ $HA\sp{(1)}\sb 1$},
+ date={1993},
+ ISSN={0021-8693},
+ journal={J. Algebra},
+ volume={160},
+ number={2},
+ pages={492\ndash 523},
+}
+
+\bib{MR94d:17033}{article}{
+ author={Kang, S.-J.},
+ title={On the hyperbolic Kac-Moody Lie algebra $HA\sb 1\sp
+ {(1)}$},
+ date={1994},
+ ISSN={0002-9947},
+ journal={Trans. Amer. Math. Soc.},
+ volume={341},
+ number={2},
+ pages={623\ndash 638},
+}
+
+\bib{MR97e:17041}{incollection}{
+ author={Kang, S.-J.},
+ title={Root multiplicities of graded Lie algebras},
+ date={1996},
+conference={
+ title={Lie algebras and their representations},
+ address={Seoul},
+ date={1995},
+},
+ publisher={Amer. Math. Soc.},
+ address={Providence, RI},
+ pages={161\ndash 176},
+}
+
+\bib{MR1641035}{article}{
+ author={Kang, S.-J.},
+ author={Kashiwara, M.},
+ title={Quantized affine algebras and crystals with core},
+ date={1998},
+ ISSN={0010-3616},
+ journal={Comm. Math. Phys.},
+ volume={195},
+ number={3},
+ pages={725\ndash 740},
+}
+
+\bib{MR93g:17027}{article}{
+ author={Kang, S.-J.},
+ author={Kashiwara, M.},
+ author={Misra, K.~C.},
+ author={Miwa, T.},
+ author={Nakashima, T.},
+ author={Nakayashiki, A.},
+ title={Vertex models and crystals},
+ date={1992},
+ ISSN={0764-4442},
+ journal={C. R. Acad. Sci. Paris S\'er. I Math.},
+ volume={315},
+ number={4},
+ pages={375\ndash 380},
+}
+
+\bib{MR1464137}{article}{
+ author={Kang, S.-J.},
+ author={Kim, M.-H.},
+ title={Borcherds superalgebras and a monstrous Lie superalgebra},
+ date={1997},
+ ISSN={0025-5831},
+ journal={Math. Ann.},
+ volume={307},
+ number={4},
+ pages={677\ndash 694},
+}
+
+\bib{MR95f:17013}{article}{
+ author={Kang, S.-J.},
+ author={Misra, K.~C.},
+ title={Crystal bases and tensor product decompositions of $U\sb q(G\sb
+ 2)$-modules},
+ date={1994},
+ ISSN={0021-8693},
+ journal={J. Algebra},
+ volume={163},
+ number={3},
+ pages={675\ndash 691},
+}
+
+\bib{Kash90}{article}{
+ author={Kashiwara, M.},
+ title={Crystalizing the $q$-analogue of universal enveloping algebras},
+ date={1990},
+ journal={Comm. Math. Phys.},
+ volume={133},
+ pages={249\ndash 260},
+}
+
+\bib{Keng82}{book}{
+ author={Keng, H.~L.},
+ title={Introduction to number theory},
+ publisher={Springer-Verlag},
+ date={1982},
+}
+
+\bib{Wang}{article}{
+ author={Li, W.~L.},
+ title={Classification of generalized Cartan matrices of hyperbolic
+ type},
+ date={1988},
+ journal={Chinese Ann. Math. Ser. B},
+ volume={9},
+ number={1},
+ pages={68\ndash 77},
+}
+
+\bib{MR98a:20041}{incollection}{
+ author={Littelmann, P.},
+ title={An effective method to classify nilpotent orbits},
+ date={1996},
+conference={
+ title={Algorithms in algebraic geometry and applications},
+ address={Santander},
+ year={1994}
+},
+ publisher={Birkh\"auser},
+ address={Basel},
+ pages={255\ndash 269},
+}
+
+\bib{MR2000d:17019}{article}{
+ author={Littelmann, P.},
+ title={Bases canoniques et applications},
+ date={1998},
+ ISSN={0303-1179},
+ journal={Ast\'erisque},
+ number={252},
+ pages={Exp.\ No.\ 847, 5, 287\ndash 306},
+ note={S\'eminaire Bourbaki. Vol.\ 1997/98},
+}
+
+\bib{MR92d:16032}{article}{
+ author={Littelmann, P.},
+ author={Procesi, C.},
+ title={On the Poincar\'e series of the invariants of binary forms},
+ date={1990},
+ ISSN={0021-8693},
+ journal={J. Algebra},
+ volume={133},
+ number={2},
+ pages={490\ndash 499},
+}
+
+\bib{MR92g:20067}{incollection}{
+ author={Littelmann, Peter},
+ title={Good filtrations, decomposition rules and standard monomial
+ theory},
+ date={1991},
+conference={
+ title={Computational aspects of Lie group representations and
+ related topics},
+ address={Amsterdam},
+ date={1990}
+},
+ publisher={Math. Centrum Centrum Wisk. Inform.},
+ address={Amsterdam},
+ pages={89\ndash 106},
+}
+
+\bib{MR92b:14027}{incollection}{
+ author={Littelmann, Peter},
+ author={Procesi, Claudio},
+ title={Equivariant cohomology of wonderful compactifications},
+ date={1990},
+conference={
+ title={Operator algebras, unitary representations, enveloping
+ algebras, and invariant theory},
+ address={Paris},
+ date={1989}
+},
+ publisher={Birkh\"auser Boston},
+ address={Boston, MA},
+ pages={219\ndash 262},
+}
+
+\bib{MR94m:17016}{book}{
+ author={Lusztig, G.},
+ title={Introduction to quantum groups},
+ publisher={Birkh\"auser Boston Inc.},
+ address={Boston, MA},
+ date={1993},
+ ISBN={0-8176-3712-5},
+}
+
+\bib{Nak96}{article}{
+ author={Nakayashiki, A.},
+ title={Fusion of the $q$-vertex operators and its applications
+ to solvable vertex models},
+ date={1996},
+ ISSN={0010-3616},
+ journal={Commun. Math. Phys.},
+ volume={177},
+ number={2},
+ pages={27\ndash 62},
+}
+
+\bib{Rob}{article}{
+ author={Robinson, D.},
+ title={On representations of the symmetric group},
+ date={1938},
+ journal={Amer. J. Math.},
+ volume={60},
+ pages={745\ndash 760},
+}
+
+\bib{Ser77}{book}{
+ author={Serre, J.-P.},
+ title={Linear representations of finite groups},
+ publisher={Springer-Verlag},
+ date={1977},
+}
+
+\bib{Weyl}{book}{
+ author={Weyl, H.},
+ title={Classical groups},
+ edition={2},
+ publisher={Princeton University Press},
+ date={1946},
+}
+
+\bib{Young4}{article}{
+ author={Young, A.},
+ title={On quantitative substitutional analysis IV},
+ date={1929},
+ journal={Proc. Lond. Math. Soc. (2)},
+ volume={31},
+ pages={253\ndash 272},
+}
+
+\end{biblist}
+\end{bibdiv}
+\end{document}
diff --git a/macros/latex/contrib/amsrefs/ifoption.dtx b/macros/latex/contrib/amsrefs/ifoption.dtx
new file mode 100644
index 0000000000..dcb25d8117
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/ifoption.dtx
@@ -0,0 +1,183 @@
+% \def\filename{ifoption.dtx}
+% \def\fileversion{1.02}
+% \def\filedate{2002/03/04}
+%
+% \iffalse meta-comment
+%
+% American Mathematical Society
+% Technical Support
+% Publications Technical Group
+% 201 Charles Street
+% Providence, RI 02904
+% USA
+% tel: (401) 455-4080
+% (800) 321-4267 (USA and Canada only)
+% fax: (401) 331-3842
+% email: tech-support@ams.org
+%
+% Copyright 2001, 2010 American Mathematical Society.
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3c
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3c or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is the American Mathematical
+% Society.
+%
+% \fi
+%
+% \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}
+\DocInput{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/macros/latex/contrib/amsrefs/ifoption.ins b/macros/latex/contrib/amsrefs/ifoption.ins
new file mode 100644
index 0000000000..f08a89d0f6
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/ifoption.ins
@@ -0,0 +1,75 @@
+%% filename: ifoption.ins
+%% version: 1.0
+%% date: 2010/08/13
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 2010 American Mathematical Society.
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+\input docstrip
+
+\askforoverwritefalse
+
+\keepsilent
+
+\preamble
+
+Copyright 2001, 2010 American Mathematical Society.
+
+American Mathematical Society
+Technical Support
+Publications Technical Group
+201 Charles Street
+Providence, RI 02904
+USA
+tel: (401) 455-4080
+ (800) 321-4267 (USA and Canada only)
+fax: (401) 331-3842
+email: tech-support@ams.org
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either version 1.3c
+of this license or (at your option) any later version.
+The latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+and version 1.3c or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is the American Mathematical
+Society.
+
+\endpreamble
+
+\usedir{tex/latex/amsrefs}
+
+\generate{
+ \file{ifoption.sty}{\from{ifoption.dtx}{}}
+}
+
+\endbatchfile
diff --git a/macros/latex/contrib/amsrefs/ifoption.pdf b/macros/latex/contrib/amsrefs/ifoption.pdf
new file mode 100644
index 0000000000..b4c1306c2f
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/ifoption.pdf
Binary files differ
diff --git a/macros/latex/contrib/amsrefs/install.txt b/macros/latex/contrib/amsrefs/install.txt
new file mode 100644
index 0000000000..8fd6c4d031
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/install.txt
@@ -0,0 +1,88 @@
+install.txt for amsrefs 2.12 [2013-01-24]
+
+Copyright 2002-2004, 2010, 2013 American Mathematical Society.
+
+This work may be distributed and/or modified under the conditions
+of the LaTeX Project Public License, either version 1.3c
+of this license or (at your option) any later version.
+The latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+and version 1.3c or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is the American Mathematical
+Society.
+
+American Mathematical Society
+Technical Support
+Publications Technical Group
+201 Charles Street
+Providence, RI 02904
+USA
+tel: (401) 455-4080
+ (800) 321-4267 (USA and Canada only)
+fax: (401) 331-3842
+email: tech-support@ams.org
+
+Preliminary note: The normal destination directory for amsrefs.sty in a
+standard TDS structure is texmf/tex/latex/amsrefs (see step 3 below).
+
+------------------------------------------------------------------------
+If you have a relatively up-do-date TeX system that complies with the
+TeX Directory Structure (TDS) standard, installing according to the
+instructions in section I below is the easiest method. See
+
+ http://www.tug.org/tds/tds.pdf
+
+for details on the TDS standard. If your TeX system does not comply
+with the TDS standard, please contact the manufacturer of your TeX
+system for details on how to install third-party TeX packages.
+
+The first step is to identify the TEXMF folder that contains files used
+by LaTeX. To do this, look for the file article.cls. If you find, e.g.,
+
+ /usr/local/share/texmf/tex/latex/base/article.cls
+
+then we will define TEXMF to mean /usr/local/share/texmf (everything
+before the tex/latex/base part). On a Windows system the file location
+will probably be something like
+
+ c:\sw\texmf\tex\latex\base\article.cls
+
+Then we define TEXMF to mean c:\sw\texmf. In the following instructions,
+wherever you see "TEXMF" substitute the folder name determined in this
+way.
+
+If this terminology does not 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 one of the above addresses.
+
+------------------------------------------------------------------------
+1. Download the following archive file:
+
+ ftp://ftp.ams.org/pub/tex/amsrefs/amsrefs.zip
+
+2. View the following files to assess the effects of the upgrade on
+your system:
+
+ README
+ install.txt (this file)
+ diffs-m.txt
+
+3. Backup the old version of AMS-LaTeX, preferably by moving it out of the
+TEXMF tree.
+
+4. Extract files from the .zip archive using your favorite unzip tool,
+setting the extraction target directory to the texmf root directory.
+
+5. To check the end result, you should find that amsrefs.sty is now in
+the following location (substituting \ or : for / if appropriate):
+
+ TEXMF/tex/latex/amsrefs/amsrefs.sty
+
+Some TeX systems such as TeX Live and MikTeX also use a database to
+keep track of TeX input files. If this database is not updated, your
+TeX system might not find the newly installed files. Consult your TeX
+system's documentation to determine how to update this database.
diff --git a/macros/latex/contrib/amsrefs/jr.bib b/macros/latex/contrib/amsrefs/jr.bib
new file mode 100644
index 0000000000..38e4eef28a
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/jr.bib
@@ -0,0 +1,246 @@
+%% filename: jr.bib
+%% version: 1.00
+%% date: 2004/06/30
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support<at>ams.org
+%%
+%% Copyright 2004, 2010 American Mathematical Society.
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+@article{BFMW,
+ author={J. Bryant and S. Ferry and W. Mio and S. Weinberger},
+ title={Topology of homology manifolds},
+ journal={Ann. of Math.},
+ volume={143},
+ pages={435--467},
+ year={1996},
+ review={\MR{97b:57017}},
+}
+
+@article{Ch,
+ author={T. A. Chapman},
+ title={Simple homotopy theory for {$ANR$}'s},
+ journal={General Topology and its Applications},
+ volume={7},
+ pages={165--174},
+ year={1977},
+ review={\MR{58:18414}},
+}
+
+@article{Co,
+ author={M. Cohen},
+ title={Simplicial structures and transverse cellularity},
+ journal={Ann. of Math.},
+ volume={85},
+ pages={218--245},
+ year={1967},
+ review={\MR{35:1037}},
+}
+
+@incollection{FP,
+ author={S. Ferry and E. K. Pedersen},
+ title={Epsilon surgery theory {I}},
+ booktitle={Novikov Conjectures, Index Theorems and Rigidity,
+ Vol. 2 ({O}berwolfach, 1993)},
+ series={Lond. Math. Soc. Lecture Note Ser.},
+ volume={227},
+ publisher={Cambridge University Press},
+ year={1995},
+ pages={167--226},
+ review={\MR{97g:57044}},
+}
+
+@article{HTW,
+ author={B. Hughes and L. Taylor and B. Williams},
+ title={Manifold approximate fibrations are approximately bundles},
+ journal={Forum Math.},
+ volume={3},
+ pages={309--325},
+ year={1991},
+ review={\MR{92k:57040}},
+}
+
+@article{Jo,
+ author={H. Johnston},
+ title={Transversality for homology manifolds},
+ journal={Topology},
+ volume={38},
+ pages={673--697},
+ year={1999},
+ review={\MR{99k:57048}},
+}
+
+@article{Jn,
+ author={L. Jones},
+ title={Patch spaces: a geometric representation for {P}oincar\'e
+ spaces},
+ journal={Ann. of Math.},
+ volume={97},
+ pages={306--343},
+ year={1973},
+ note={102, 183--185 (1975) \MR{47:4269}; \MR{52:11930}},
+}
+
+@book{KS,
+ author={R. Kirby and L. Siebenmann},
+ title={Foundational essays on topological manifolds, smoothings, and
+ triangulations},
+ series={Ann. of Math. Study},
+ volume={88},
+ publisher={Princeton University Press},
+ year={1977},
+ review={\MR{58:31082}},
+}
+
+@article{LR,
+ author={N. Levitt and A. Ranicki},
+ title={Intrinsic transversality structures},
+ journal={Pacific J. Math.},
+ volume={129},
+ pages={85--144},
+ year={1987},
+ review={\MR{88m:57027}},
+}
+
+@article{M,
+ author={A. Marin},
+ title={La transversalit\'e topologique},
+ language={French},
+ journal={Ann. of Math.},
+ volume={106},
+ pages={269--293},
+ year={1977},
+ review={\MR{57:10707}},
+}
+
+@article{Q1,
+ author={F. Quinn},
+ title={Resolutions of homology manifolds, and the topological
+ characterization of manifolds},
+ journal={Invent. Math.},
+ volume={72},
+ pages={264--284},
+ year={1983},
+ note={Corrigendum \textbf{85} (1986) 653},
+ review={\MR{85b:57023}, \MR{87g:57031}},
+}
+
+@article{Q2,
+ author={F. Quinn},
+ title={An obstruction to the resolution of homology manifolds},
+ journal={Michigan Math. J.},
+ volume={34},
+ pages={284--291},
+ year={1987},
+ review={\MR{88j:57016}},
+}
+
+@article{Q3,
+ author={F. Quinn},
+ title={Topological transversality holds in all dimensions},
+ journal={Bull. Amer. Math. Soc.},
+ volume={18},
+ pages={145--148},
+ year={1988},
+ review={\MR{89c:57016}},
+}
+
+@article{R1,
+ author={A. Ranicki},
+ title={The algebraic theory of surgery {II}. {A}pplications to topology},
+ journal={Proc. Lond. Math. Soc.},
+ volume={40},
+ pages={193--287},
+ year={1980},
+ review={\MR{82f:57024b}},
+}
+
+@book{R2,
+ author={A. Ranicki},
+ title={Exact sequences in the algebraic theory of surgery},
+ series={Mathematical Notes},
+ volume={26},
+ publisher={Princeton University Press},
+ year={1981},
+ review={\MR{82h:57027}},
+}
+
+@book{R3,
+ author={A. Ranicki},
+ title={Algebraic {$L$}--theory and topological manifolds},
+ series={Cambridge Tracts in Mathematics},
+ volume={102},
+ publisher={Cambridge University Press},
+ year={1992},
+ review={\MR{94i:57051}},
+}
+
+@article{RS,
+ author={C. P. Rourke and B. J. Sanderson},
+ title={On topological neighbourhoods},
+ journal={Compositio Math.},
+ volume={22},
+ pages={387--425},
+ year={1970},
+ review={\MR{45:7720}},
+}
+
+@book{Wa,
+ author={C. T. C. Wall},
+ title={Surgery on compact manifolds},
+ edition={2},
+ publisher={Academic Press},
+ year={1970},
+}
+
+@book{Wei,
+ author={S. Weinberger},
+ title={Nonlocally linear manifolds and orbifolds},
+ series={Proc. 1994 Z\"urich ICM},
+ pages={637--647},
+ publisher={Birkh\"auser},
+ year={1995},
+ review={\MR{97g:57028}},
+}
+
+@book{Wein,
+ author={S. Weinberger},
+ title={The topological classification of stratified spaces},
+ series={Chicago Lectures in Mathematics},
+ publisher={University of Chicago Press},
+ year={1994},
+ review={\MR{96b:57024}},
+}
+
+@article{Wes,
+ author={J. West},
+ title={Mapping {H}ilbert cube manifolds to {$ANR$}'s},
+ journal={Ann. of Math.},
+ volume={106},
+ pages={1--18},
+ year={1977},
+ review={\MR{56:9534}},
+}
diff --git a/macros/latex/contrib/amsrefs/manifest.txt b/macros/latex/contrib/amsrefs/manifest.txt
new file mode 100644
index 0000000000..3e71808dfb
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/manifest.txt
@@ -0,0 +1,34 @@
+README
+amsrdoc.pdf
+amsrdoc.tex
+amsrefs.dtx
+amsrefs.faq
+amsrefs.ins
+amsrefs.pdf
+amsxport.dtx
+amsxport.ins
+amsxport.pdf
+changes.pdf
+changes.tex
+cite-xa.tex
+cite-xb.tex
+cite-xh.tex
+cite-xs.tex
+gktest.ltb
+ifoption.dtx
+ifoption.ins
+ifoption.pdf
+install.txt
+jr.bib
+mathscinet.dtx
+mathscinet.ins
+mathscinet.pdf
+pcatcode.dtx
+pcatcode.ins
+pcatcode.pdf
+rkeyval.dtx
+rkeyval.ins
+rkeyval.pdf
+textcmds.dtx
+textcmds.ins
+textcmds.pdf
diff --git a/macros/latex/contrib/amsrefs/mathscinet.dtx b/macros/latex/contrib/amsrefs/mathscinet.dtx
new file mode 100644
index 0000000000..300d6701a3
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/mathscinet.dtx
@@ -0,0 +1,607 @@
+% \def\filename{mathscinet.dtx}
+% \def\fileversion{2.01}
+% \def\filedate{2004/06/30}
+%
+% \iffalse meta-comment
+%
+% American Mathematical Society
+% Technical Support
+% Publications Technical Group
+% 201 Charles Street
+% Providence, RI 02904
+% USA
+% tel: (401) 455-4080
+% (800) 321-4267 (USA and Canada only)
+% fax: (401) 331-3842
+% email: tech-support@ams.org
+%
+% Copyright 2001, 2010 American Mathematical Society.
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3c
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3c or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is the American Mathematical
+% Society.
+%
+% \fi
+%
+% \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}
+\DocInput{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/macros/latex/contrib/amsrefs/mathscinet.ins b/macros/latex/contrib/amsrefs/mathscinet.ins
new file mode 100644
index 0000000000..b6c45c019b
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/mathscinet.ins
@@ -0,0 +1,77 @@
+%% filename: mathscinet.ins
+%% version: 1.0
+%% date: 2010/08/13
+%%
+%% \iffalse meta-comment
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 2010 American Mathematical Society.
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+\input docstrip
+
+\askforoverwritefalse
+
+\keepsilent
+
+\preamble
+
+Copyright 2001, 2010 American Mathematical Society.
+
+American Mathematical Society
+Technical Support
+Publications Technical Group
+201 Charles Street
+Providence, RI 02904
+USA
+tel: (401) 455-4080
+ (800) 321-4267 (USA and Canada only)
+fax: (401) 331-3842
+email: tech-support@ams.org
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either version 1.3c
+of this license or (at your option) any later version.
+The latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+and version 1.3c or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is the American Mathematical
+Society.
+
+\endpreamble
+
+\usedir{tex/latex/amsrefs}
+
+\generate{
+ \file{mathscinet.sty}{\from{mathscinet.dtx}{}}
+}
+
+\endbatchfile
diff --git a/macros/latex/contrib/amsrefs/mathscinet.pdf b/macros/latex/contrib/amsrefs/mathscinet.pdf
new file mode 100644
index 0000000000..70915dae55
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/mathscinet.pdf
Binary files differ
diff --git a/macros/latex/contrib/amsrefs/pcatcode.dtx b/macros/latex/contrib/amsrefs/pcatcode.dtx
new file mode 100644
index 0000000000..948503616b
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/pcatcode.dtx
@@ -0,0 +1,368 @@
+% \def\filename{pcatcode.dtx}
+% \def\fileversion{1.04b}
+% \def\filedate{2007/08/17}
+%
+% \iffalse meta-comment
+%
+% American Mathematical Society
+% Technical Support
+% Publications Technical Group
+% 201 Charles Street
+% Providence, RI 02904
+% USA
+% tel: (401) 455-4080
+% (800) 321-4267 (USA and Canada only)
+% fax: (401) 331-3842
+% email: tech-support@ams.org
+%
+% Copyright 2001, 2010 American Mathematical Society.
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3c
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3c or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is the American Mathematical
+% Society.
+%
+% \fi
+%
+% \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}
+\DocInput{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/macros/latex/contrib/amsrefs/pcatcode.ins b/macros/latex/contrib/amsrefs/pcatcode.ins
new file mode 100644
index 0000000000..2a6d487396
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/pcatcode.ins
@@ -0,0 +1,77 @@
+%% filename: pcatcode.ins
+%% version: 1.0
+%% date: 2010/08/13
+%%
+%% \iffalse meta-comment
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 2010 American Mathematical Society.
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+\input docstrip
+
+\askforoverwritefalse
+
+\keepsilent
+
+\preamble
+
+Copyright 2001, 2010 American Mathematical Society.
+
+American Mathematical Society
+Technical Support
+Publications Technical Group
+201 Charles Street
+Providence, RI 02904
+USA
+tel: (401) 455-4080
+ (800) 321-4267 (USA and Canada only)
+fax: (401) 331-3842
+email: tech-support@ams.org
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either version 1.3c
+of this license or (at your option) any later version.
+The latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+and version 1.3c or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is the American Mathematical
+Society.
+
+\endpreamble
+
+\usedir{tex/latex/amsrefs}
+
+\generate{
+ \file{pcatcode.sty}{\from{pcatcode.dtx}{}}
+}
+
+\endbatchfile
diff --git a/macros/latex/contrib/amsrefs/pcatcode.pdf b/macros/latex/contrib/amsrefs/pcatcode.pdf
new file mode 100644
index 0000000000..686a765c33
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/pcatcode.pdf
Binary files differ
diff --git a/macros/latex/contrib/amsrefs/rkeyval.dtx b/macros/latex/contrib/amsrefs/rkeyval.dtx
new file mode 100644
index 0000000000..271c0694a8
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/rkeyval.dtx
@@ -0,0 +1,1127 @@
+% \def\filename{rkeyval.dtx}
+% \def\fileversion{2.00}
+% \def\filedate{2004/06/28}
+%
+% \iffalse meta-comment
+%
+% American Mathematical Society
+% Technical Support
+% Publications Technical Group
+% 201 Charles Street
+% Providence, RI 02904
+% USA
+% tel: (401) 455-4080
+% (800) 321-4267 (USA and Canada only)
+% fax: (401) 331-3842
+% email: tech-support@ams.org
+%
+% Copyright 2001, 2010 American Mathematical Society.
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3c
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3c or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is the American Mathematical
+% Society.
+%
+% \fi
+%
+% \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}
+\DocInput{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/macros/latex/contrib/amsrefs/rkeyval.ins b/macros/latex/contrib/amsrefs/rkeyval.ins
new file mode 100644
index 0000000000..19948ee9a4
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/rkeyval.ins
@@ -0,0 +1,77 @@
+%% filename: rkeyval.ins
+%% version: 1.0
+%% date: 2010/08/13
+%%
+%% \iffalse meta-comment
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 2010 American Mathematical Society.
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+\input docstrip
+
+\askforoverwritefalse
+
+\keepsilent
+
+\preamble
+
+Copyright 2001, 2010 American Mathematical Society.
+
+American Mathematical Society
+Technical Support
+Publications Technical Group
+201 Charles Street
+Providence, RI 02904
+USA
+tel: (401) 455-4080
+ (800) 321-4267 (USA and Canada only)
+fax: (401) 331-3842
+email: tech-support@ams.org
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either version 1.3c
+of this license or (at your option) any later version.
+The latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+and version 1.3c or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is the American Mathematical
+Society.
+
+\endpreamble
+
+\usedir{tex/latex/amsrefs}
+
+\generate{
+ \file{rkeyval.sty}{\from{rkeyval.dtx}{}}
+}
+
+\endbatchfile
diff --git a/macros/latex/contrib/amsrefs/rkeyval.pdf b/macros/latex/contrib/amsrefs/rkeyval.pdf
new file mode 100644
index 0000000000..920337747f
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/rkeyval.pdf
Binary files differ
diff --git a/macros/latex/contrib/amsrefs/textcmds.dtx b/macros/latex/contrib/amsrefs/textcmds.dtx
new file mode 100644
index 0000000000..074f8300e5
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/textcmds.dtx
@@ -0,0 +1,300 @@
+% \def\filename{textcmds.dtx}
+% \def\fileversion{2.00}
+% \def\filedate{2012/08/02}
+%
+% \iffalse meta-comment
+%
+% American Mathematical Society
+% Technical Support
+% Publications Technical Group
+% 201 Charles Street
+% Providence, RI 02904
+% USA
+% tel: (401) 455-4080
+% (800) 321-4267 (USA and Canada only)
+% fax: (401) 331-3842
+% email: tech-support@ams.org
+%
+% Copyright 2001, 2010 American Mathematical Society.
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3c
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3c or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is the American Mathematical
+% Society.
+%
+% \fi
+%
+% \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}
+\DocInput{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'\q{some text}'& \verb'\lq#1\/\rq'& \q{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}[2012/08/02 v2.00]
+% \end{macrocode}
+%
+% Dashes and inverted beginning-of-sentence punctuation.
+% \begin{macrocode}
+\providecommand{\mdash}{\textemdash\penalty\exhyphenpenalty}
+\providecommand{\ndash}{\textendash\penalty\exhyphenpenalty}
+\providecommand{\qd}{\textquestiondown}
+\providecommand{\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}
+\providecommand{\ldq}{\textquotedblleft}
+\providecommand{\rdq}{\textquotedblright}
+\providecommand{\lsq}{\textquoteleft}
+\providecommand{\rsq}{\textquoteright}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\providecommand{\bul}{\textbullet}%
+\providecommand{\vsp}{\textvisiblespace}%
+\providecommand{\pdc}{\textperiodcentered}%
+\providecommand{\vrt}{\textbar}%
+\providecommand{\cir}{\textasciicircum}%
+\providecommand{\til}{\textasciitilde}%
+\providecommand{\bsl}{\textbackslash}%
+\providecommand{\cwm}{\textcompwordmark}%
+% \end{macrocode}
+%
+% \begin{macrocode}
+\providecommand{\qq}[1]{\ldq#1\/\rdq}
+% \end{macrocode}
+%
+%
+% \begin{macrocode}
+\providecommand{\q}[1]{\lq#1\/\rq}
+% \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{138}
+% \Finale
diff --git a/macros/latex/contrib/amsrefs/textcmds.ins b/macros/latex/contrib/amsrefs/textcmds.ins
new file mode 100644
index 0000000000..e5a09c8846
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/textcmds.ins
@@ -0,0 +1,77 @@
+%% filename: textcmds.ins
+%% version: 1.0
+%% date: 2010/08/13
+%%
+%% \iffalse meta-comment
+%%
+%% American Mathematical Society
+%% Technical Support
+%% Publications Technical Group
+%% 201 Charles Street
+%% Providence, RI 02904
+%% USA
+%% tel: (401) 455-4080
+%% (800) 321-4267 (USA and Canada only)
+%% fax: (401) 331-3842
+%% email: tech-support@ams.org
+%%
+%% Copyright 2010 American Mathematical Society.
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is the American Mathematical
+%% Society.
+%%
+%% ====================================================================
+
+\input docstrip
+
+\askforoverwritefalse
+
+\keepsilent
+
+\preamble
+
+Copyright 2001, 2010 American Mathematical Society.
+
+American Mathematical Society
+Technical Support
+Publications Technical Group
+201 Charles Street
+Providence, RI 02904
+USA
+tel: (401) 455-4080
+ (800) 321-4267 (USA and Canada only)
+fax: (401) 331-3842
+email: tech-support@ams.org
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either version 1.3c
+of this license or (at your option) any later version.
+The latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+and version 1.3c or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is the American Mathematical
+Society.
+
+\endpreamble
+
+\usedir{tex/latex/amsrefs}
+
+\generate{
+ \file{textcmds.sty}{\from{textcmds.dtx}{pkg}}
+}
+
+\endbatchfile
diff --git a/macros/latex/contrib/amsrefs/textcmds.pdf b/macros/latex/contrib/amsrefs/textcmds.pdf
new file mode 100644
index 0000000000..e6aba3ca86
--- /dev/null
+++ b/macros/latex/contrib/amsrefs/textcmds.pdf
Binary files differ