%%% ====================================================================
%%% @LaTeX-doc-source-file{
%%%   filename  = "mathscinet.dtx",
%%%   version   = "2.01",
%%%   date      = "2004/06/30",
%%%   time      = "12:00:17 EDT",
%%%   author    = "Michael J Downes and David M. Jones",
%%%   address   = "American Mathematical Society,
%%%                Publications Technical Group,
%%%                PO Box 6248,
%%%                Providence, RI 02940,
%%%                USA",
%%%   email     = "tech-support@ams.org",
%%%   URL       = "http://www.ams.org/",
%%%   abstract  = "",
%%%   checksum  = "34681 595 2175 20194",
%%%   docstring = "The checksum field, produced by Robert Solovay's
%%%                checksum utility, gives CRC-16 checksum, lines,
%%%                words, and characters.",
%%%  }
%%% ====================================================================
%%%
% \iffalse
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\documentclass[draft]{amsdtx}

\usepackage{mathscinet}

\newcommand{\uchar}[1]{{\small \texttt{U+#1}}}

\newcommand{\enc}{\texttt}

\newenvironment{chartable}{%
    \begin{tabular}{%
        l@{\extracolsep{1em}}%
        l@{\extracolsep{1em}}%
        r@{\extracolsep{2em}}%
        l@{\extracolsep{1em}}%
        l@{\extracolsep{1em}}%
        r}%
}{%
    \end{tabular}%
}

\makeatletter

\DeclareTextCommandDefault{\xudot}{\@underaccent\@empty{'137}}

\makeatother

\MakeShortVerb{\|}

\begin{document}
\title{The \pkg{mathscinet} package}
\author{American Mathematical Society}
\date{Version \fileversion, \filedate}
\hDocInput{mathscinet.dtx}
\end{document}
%</driver>
% \fi
%
% \maketitle
% \section{Introduction}
%
%    The \pkg{mathscinet} packages provides definitions for certain
%    commands that occasionally occur in bibliographic data exported
%    from MathSciNet and that are not provided by \latex/.
%
%    \textbf{Warning:} Although the macros provided in this package
%    are probably acceptable if all you need to do is format an entry
%    downloaded from MathSciNet, they should probably not be used for
%    other purposes.  In general, if you are trying to typeset
%    material in any languages that require these characters, you are
%    better off using specialized fonts and encodings for those
%    languages.
%
%    All Unicode character references are taken from \emph{The Unicode
%    Standard, Version~3.0} (Addison-Wesley, 2000).
%
% \StopEventually{}
%
% \section{Implementation}
%    Standard declaration of package name and date.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mathscinet}[2002/04/17 v1.05]
\RequirePackage{textcmds}\relax
%    \end{macrocode}
%
%    \begin{macro}{\setboxz@h}
%    A useful abbreviation borrowed from \pkg{amsgen}.
%    \begin{macrocode}
\providecommand\setboxz@h{\setbox\z@\hbox}
%    \end{macrocode}
%    \end{macro}
%
%    \subsection{Math font commands}
%
%    \begin{macro}{\bold}
%    \begin{macro}{\scr}
%    These are simple aliases of core \latex/ commands.
%    \begin{macrocode}
\providecommand{\bold}{\mathbf}
\providecommand{\scr}{\mathcal}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%
%    \begin{macro}{\germ}
%    Since this doesn't correspond to a core \latex/ command, we
%    generate an error if no appropriate definition is available.
%    \begin{macrocode}
\AtBeginDocument{%
    \@ifundefined{mathfrak}{%
        \providecommand{\germ}{%
            \PackageError{mathscinet}{To use the \string\germ\space
                command, please load the amsfonts package}\@ehc
        }%
    }{%
        \providecommand{\germ}{\mathfrak}%
    }%
}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\romsup}
%    \begin{macro}{\asup}
%    The \cs{tsup} command comes from the \pkg{textcmds} package.
%    \begin{macrocode}
\providecommand{\romsup}{\tsup}
\providecommand{\asup}{\tsup}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%
%    \begin{macro}{\hslash}
%    Planck's constant over~$2\pi$:~$\hslash$ (\uchar{210F}).
%
%    If the \pkg{amssymb} package isn't loaded, we just want this to
%    be an alias for |\hbar|, which is defined in the \latex/ kernel
%    (and then redefined by the \pkg{amssymb} package).  If the
%    \pkg{amssymb} package is loaded, we want to use its definition
%    of~|\hslash|.  To prevent problems if \pkg{amsrefs} is loaded
%    before \pkg{amssymb}, we defer our definition of \cn{hslash}
%    until after all packages have been loaded.
%    \begin{macrocode}
\AtBeginDocument{\providecommand{\hslash}{\hbar}}
%    \end{macrocode}
%    \end{macro}
%
%    \subsection{Arabic transliteration}
%
%    \begin{macro}{\rasp}
%    Transliteration of the Arabic letter \emph{hamza}
%    (\uchar{0621}):~\rasp\ (\uchar{02BE}).
%    \begin{macrocode}
\ProvideTextCommandDefault{\rasp}{\leavevmode\raise.45ex\hbox{$\rhook$}}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\lasp}
%    Transliteration of the Arabic letter \emph{ain}
%    (\uchar{0639}):~\lasp\ (\uchar{02BF}).
%    \begin{macrocode}
\ProvideTextCommandDefault{\lasp}{\leavevmode\raise.45ex\hbox{$\lhook$}}
%    \end{macrocode}
%    \end{macro}
%
%    \subsection{Latin Extended-A (\texttt{latin1}) characters}
%
%    These are based on Barbara Beeton's definitions from
%    \fn{amsclass.dtx}.
%
%    \begin{macro}{\Dbar}
%    Latin capital letter D with stroke:~\Dbar\ (\uchar{0110}).  In the
%    T1 encoding, we just use |\DJ|; otherwise we fake it.
%    \begin{macrocode}
\ProvideTextCommand{\Dbar}{T1}{\DJ}

\ProvideTextCommandDefault{\Dbar}{%
    \leavevmode\lower.5ex\rlap{\hskip-.07em\accent"16}D%
}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\dbar}
%    Latin lower letter~d with stroke:~\dbar\ (\uchar{0111}).  In the
%    T1 encoding, we just use |\dj|; otherwise we fake it.
%    \begin{macrocode}
\ProvideTextCommand{\dbar}{T1}{\dj}
%    \end{macrocode}
%    If it looks like this is a small-caps font, we adjust the spacing
%    appropriately.
%    \begin{macrocode}
\ProvideTextCommandDefault{\dbar}{%
    \begingroup
        \edef\@tempa{\scdefault}%
        \ifx\@tempa\f@shape
            \dimen@-.75ex
            \dimen@i-.08em
        \else
            \dimen@.02ex
            \dimen@i.1em
        \fi
        \leavevmode\raise\dimen@\rlap{\hskip\dimen@i\char"16}d%
    \endgroup
}
%    \end{macrocode}
%    \end{macro}
%
%    \subsection{Cyrillic transliteration}
%
%    \begin{macro}{\cprime}
%    Transliteration of the Cyrillic letter soft sign
%    (\uchar{042C}):~\cprime.
%    \begin{macrocode}
\ProvideTextCommandDefault{\cprime}{\tprime}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\cdprime}
%    Transliteration of the Cyrillic letter hard sign
%    (\uchar{042A}):~\cdprime.
%    \begin{macrocode}
\ProvideTextCommandDefault{\cdprime}{\tprime\tprime}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\bud}
%    Ditto.
%    \begin{macrocode}
\ProvideTextCommandDefault{\bud}{\cdprime}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\cydot}
%    Vertically centered dot.
%    \begin{macrocode}
\ProvideTextCommandDefault{\cydot}{\leavevmode\raise.4ex\hbox{.}}
%    \end{macrocode}
%    \end{macro}
%
%    \subsection{Miscellaneous diacritics (aka Frankenstein's\\
%    diacritics)}
%
%    \begin{macro}{\save@sf}
%    When putting together an accented character from bits and pieces,
%    the |\spacefactor| of the base character often gets lost in the
%    shuffle.  We use essentialy the same technique as |\add@accent|
%    to save and restore the spacefactor, but we wrap in in a pair of
%    macros for convenience.
%    \begin{macrocode}
\def\save@sf{%
    \ifmmode\else\global\mathchardef\accent@spacefactor\spacefactor\fi
}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\restore@sf}
%    And here's the corresponding restore.
%    \begin{macrocode}
\def\restore@sf{\ifmmode\else\spacefactor\accent@spacefactor\fi}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\@underaccent}
%    This is perhaps the most interesting macro in this package (which
%    admittedly isn't saying much). It attempts to convert a character
%    (usually one of the standard above-letter diacritics like~\"{})
%    into an underhanging diacritic (like~\dudot{\hbox to
%    .5em{\hss}}).  This is similar in spirit to the way that the
%    \enc{OT1} \cn{b} command converts a macron into a bar-under
%    accent, or the way that \cn{d} converts a period into an
%    underhanging dot.  However, the technique used here is a little
%    more complicated and, hopefully, a little more general, in the
%    sense of requiring fewer ad-hoc parameters.  It only contains one
%    magic constant (.2\,ex), which seems to provide reasonable
%    results for all of the Computer Modern fonts.
%
%    The basic algorithm is as follows:
%
%    \begin{enumerate}
%
%    \item
%    Create a box~$B$ containing the base character at its natural
%    height, depth, and width.
%
%    \item
%    Create a box~$d$ consisting of the diacritic centered in a space
%    equal to the width of~$B$.
%
%    \item
%    Lower box~$d$ by the sum of its height (to bring the top of~$d$
%    down to the baseline) plus the depth of $B$ (to bring the top
%    of~$d$ down to the bottom of~$B$) plus .2\,ex (to provide the
%    spacing between the bottom of the letter and the top of the
%    diacritic).  Call the new box~$d'$.
%
%    \item
%    Create a new box~$C$ by superimposing boxes $B$ and~$d'$.
%
%    \item
%    If the height of~$d$ was greater than 1\,ex, reset the depth of
%    box~$C$ to the sum of the depth of~$B$ and 1\,ex less than the
%    height of~$d$.  (See the appendix for a discussion of this step.)
%
%    \end{enumerate}
%
%    \begin{macrocode}
\def\@underaccent#1#2#3{%
    \leavevmode
    \begingroup
        \ifmmode\let\@mathtoggle$\else\let\@mathtoggle\relax\fi
        \setboxz@h{\@mathtoggle#3\save@sf\@mathtoggle}%
        \setbox\@ne\hb@xt@\wd\z@{%
            \hss\fontshape\updefault\rmfamily#1\char#2\hss
        }%
        \dimen@\ht\@ne
        \advance\dimen@\dp\z@
        \advance\dimen@.2ex
        \setboxz@h{\lower\dimen@\rlap{\copy\@ne}\unhbox\z@}%
        \ifdim\ht\@ne>1ex
            \advance\dimen@-1.2ex
            \dp\z@\dimen@
        \fi
        \box\z@
        \restore@sf
    \endgroup
}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\utilde}
%    Tilde below (\uchar{0330}):
%
%    \begin{chartable}
%    |\utilde{E}|   & \utilde{E}    & \uchar{1E1A} &
%    |\utilde{e}|   & \utilde{e}    & \uchar{1E1B} \\
%    |\utilde{I}|   & \utilde{I}    & \uchar{1E2C} &
%    |\utilde{i}|   & \utilde{i}    & \uchar{1E2D} \\
%    |\utilde{U}|   & \utilde{U}    & \uchar{1E74} &
%    |\utilde{u}|   & \utilde{u}    & \uchar{1E75}
%    \end{chartable}
%    \begin{macrocode}
\DeclareTextCommandDefault{\utilde}{\@underaccent\@empty{`\~}}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\uarc}
%    Breve below (\uchar{032E}):
%
%    \begin{chartable}
%    |\uarc{H}| & \uarc{H}  & \uchar{1E2A} &
%    |\uarc{h}| & \uarc{h}  & \uchar{1E2B}
%    \end{chartable}
%    \begin{macrocode}
\DeclareTextCommandDefault{\uarc}{\@underaccent\@empty{'025}}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\lfhook}
%    Comma below (\uchar{0326}):
%
%    \begin{chartable}
%    |\lfhook{S}|   & \lfhook{S}    & \uchar{0218} &
%    |\lfhook{s}|   & \lfhook{s}    & \uchar{0219} \\
%    |\lfhook{T}|   & \lfhook{T}    & \uchar{021A} &
%    |\lfhook{t}|   & \lfhook{t}    & \uchar{021B}
%    \end{chartable}
%    \begin{macrocode}
\DeclareTextCommandDefault{\lfhook}{\@underaccent\supsize{`\,}}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\dudot}
%    Diaeresis below (\uchar{0324}):
%
%    \begin{chartable}
%    |\dudot{U}|   & \dudot{U}    & \uchar{1E72} &
%    |\dudot{u}|   & \dudot{u}    & \uchar{1E73}
%    \end{chartable}
%    \begin{macrocode}
\DeclareTextCommandDefault{\dudot}{\@underaccent\@empty{'177}}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\udot}
%    Dot below (\uchar{0323}): There are two options for implementing
%    this: either map to the standard \cn{d} accent or define using
%    \cs{@underaccent}.  If we choose the former, we have two
%    problems: (a)~when applied to capital letters, the standard
%    \enc{T1} and \enc{OT1} implementations of~|\d| produce
%    \cs{spacefactor}s of~1000 instead of~999, and (b)~the
%    underspacing of the \cs{udot} accent will differ from that of the
%    \cs{dudot} accent:~\udot{x}\dudot{x}.  On the other hand, if we
%    choose the latter, course, \cn{d} and \cn{udot} will
%    differ:~\d{x}\xudot{x}.
%    Neither solution appeals, but it's easier to stick with~\cs{d},
%    so that's what I'll do.
%    \begin{macrocode}
\DeclareTextCommandDefault{\udot}{\d}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\polhk}
%    Ogonek (Polish hook) (\uchar{0328}):
%
%    \begin{chartable}
%    |\polhk{A}| & \polhk{A} & \uchar{0104} &
%    |\polhk{a}| & \polhk{a} & \uchar{0105} \\
%    |\polhk{E}| & \polhk{E} & \uchar{0118} &
%    |\polhk{e}| & \polhk{e} & \uchar{0119} \\
%    |\polhk{I}| & \polhk{I} & \uchar{012E} &
%    |\polhk{i}| & \polhk{i} & \uchar{012F} \\
%    |\polhk{U}| & \polhk{U} & \uchar{0172} &
%    |\polhk{u}| & \polhk{u} & \uchar{0173} \\
%    |\polhk{O}| & \polhk{O} & \uchar{01EA} &
%    |\polhk{o}| & \polhk{o} & \uchar{01EB}
%    \end{chartable}
%
%    The \enc{T1} and \enc{OT4} encodings implement the |\k| accent,
%    so we just use it for most characters, although we will
%    supplement them later with
%    \begin{macrocode}
\DeclareTextCommand{\polhk}{OT4}{\k}
\DeclareTextCommand{\polhk}{T1}{\k}
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareTextCommand{\polhk}{OT1}[1]{\TextSymbolUnavailable{\k{#1}}#1}
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareTextCompositeCommand{\polhk}{OT1}{a}{\msc@ogonek {.6}{.07} a}
\DeclareTextCompositeCommand{\polhk}{OT1}{A}{\msc@ogonek {.6}{.07} A}
\DeclareTextCompositeCommand{\polhk}{OT1}{e}{\msc@ogonek   0 {.06} e}
\DeclareTextCompositeCommand{\polhk}{OT1}{E}{\msc@ogonek{.35}{.07} E}
\DeclareTextCompositeCommand{\polhk}{OT1}{i}{\msc@ogonek {.2}{.07} i}
\DeclareTextCompositeCommand{\polhk}{OT1}{I}{\msc@ogonek {.2}{.07} I}
\DeclareTextCompositeCommand{\polhk}{OT1}{u}{\msc@ogonek {.6}{.07} u}
\DeclareTextCompositeCommand{\polhk}{OT1}{U}{\msc@ogonek   0 {.05} U}
\DeclareTextCompositeCommand{\polhk}{OT1}{o}{\msc@ogonek   0 {.07} o}
\DeclareTextCompositeCommand{\polhk}{OT1}{O}{\msc@ogonek   0 {.05} O}
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareTextCompositeCommand{\polhk}{T1}{i}{\msc@ogonek@a   0  i}
\DeclareTextCompositeCommand{\polhk}{T1}{I}{\msc@ogonek@a   0  I}
\DeclareTextCompositeCommand{\polhk}{T1}{u}{\msc@ogonek@a {.6} u}
\DeclareTextCompositeCommand{\polhk}{T1}{U}{\msc@ogonek@a   0  U}
\DeclareTextCompositeCommand{\polhk}{T1}{o}{\msc@ogonek@a   0  o}
\DeclareTextCompositeCommand{\polhk}{T1}{O}{\msc@ogonek@a   0  O}
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareTextCompositeCommand{\polhk}{OT4}{i}{\msc@ogonek {.2}{.07} i}
\DeclareTextCompositeCommand{\polhk}{OT4}{I}{\msc@ogonek {.2}{.07} I}
\DeclareTextCompositeCommand{\polhk}{OT4}{u}{\msc@ogonek {.6}{.07} u}
\DeclareTextCompositeCommand{\polhk}{OT4}{U}{\msc@ogonek   0 {.05} U}
\DeclareTextCompositeCommand{\polhk}{OT4}{o}{\msc@ogonek   0 {.07} o}
\DeclareTextCompositeCommand{\polhk}{OT4}{O}{\msc@ogonek   0 {.05} O}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\msc@ogonek}
%    \begin{macrocode}
\def\msc@ogonek#1#2#3{%
    \begingroup
        \setboxz@h{#3\save@sf}%
        \dimen@\wd\z@
        \ooalign{%
            \unhbox\z@\crcr
            \hidewidth
                \setboxz@h{\kern#1\dimen@\supsize$\lhook$}%
                \dimen@\ht\z@
                \advance\dimen@-#2ex\relax
                \lower\dimen@\box\z@
            \hidewidth
        }%
        \restore@sf
    \endgroup
}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\msc@ogonek@a}
%    \begin{macrocode}
\def\msc@ogonek@a#1#2{%
    \begingroup
        \ooalign{%
            #2\save@sf\crcr
            \hidewidth
                \raise0.02ex\hbox{\kern#1ex\char'014}%
            \hidewidth
        }%
        \restore@sf
    \endgroup
}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\soft}
%    Polish `soft' letters T, D, L:
%
%    \begin{chartable}
%    |\soft{T}| & \soft{T} & \uchar{0164} &
%    |\soft{t}| & \soft{t} & \uchar{0165} \\
%    |\soft{D}| & \soft{D} & \uchar{010E} &
%    |\soft{d}| & \soft{d} & \uchar{010f} \\
%    |\soft{L}| & \soft{L} & \uchar{013B} &
%    |\soft{l}| & \soft{l} & \uchar{013C}
%    \end{chartable}
%    \begin{macrocode}
\DeclareTextCommand{\soft}{OT4}{\v}
\DeclareTextCommand{\soft}{T1}{\v}
\DeclareTextCommand{\soft}{OT1}{\v}

\DeclareTextCompositeCommand{\soft}{OT1}{t}{\msc@soft{t}\@ne{.5ex}}
\DeclareTextCompositeCommand{\soft}{OT1}{d}{\msc@soft{d}{.925}{.95ex}}
\DeclareTextCompositeCommand{\soft}{OT1}{l}{\msc@soft{l}{.95}{.4ex}}
\DeclareTextCompositeCommand{\soft}{OT1}{L}{\msc@soft{L}{.975}{.8ex}}

\DeclareTextCompositeCommand{\soft}{OT4}{t}{\msc@soft{t}\@ne{.5ex}}
\DeclareTextCompositeCommand{\soft}{OT4}{d}{\msc@soft{d}{.925}{.95ex}}
\DeclareTextCompositeCommand{\soft}{OT4}{l}{\msc@soft{l}{.95}{.4ex}}
\DeclareTextCompositeCommand{\soft}{OT4}{L}{\msc@soft{L}{.975}{.8ex}}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\msc@soft}
%    \begin{macrocode}
\def\msc@soft#1#2#3{%
    \leavevmode
    \begingroup
        \setboxz@h{#1}%
        \raise#2\ht\z@\rlap{\kern#3\supsize,}\unhbox\z@
    \endgroup
}
%    \end{macrocode}
%    \end{macro}
%
%    \section*{\raggedright Appendix: Plumbing the depths of
%    underhanging diacritics: Notes on the magic constant 0.2\,ex and
%    an exegesis of certain obscure corners of the \cn{@underaccent}
%    macro}
%
%    \tex/ assumes that a combining accent can be superimposed
%    directly on top of any character whose height is 1\,ex.  If the
%    actual height of the base character differs from 1\,ex, the
%    accent is shifted up or down to maintain the same vertical
%    separation.  Put another way, subtracting 1\,ex from the height
%    of a combining accent tells us how much a character's height is
%    increased when that accent is added.  Call this
%    distance~$\delta$.
%
%    This distance can be analyzed into two pieces: $\delta = \sigma +
%    \eta$, where $\sigma$ is the separation between the top of
%    the base character and the \emph{bottom} of the accent, and
%    $\eta$ is the height of the bounding box of the accent.
%
%    If we now consider moving the accent to the bottom of a
%    character, we have a new relation $\delta' = \sigma' + \eta$,
%    where $\sigma'$ is the distance between the bottom of the base
%    and the \emph{top} of the accent, and $\delta'$ is the amount by
%    which the depth of the base character is increased.
%
%    If the placement of the underhanging version of an accent were
%    strictly symmetrical with the overhanging version, then we would
%    have $\sigma' = \sigma$ and thus $\delta' = \delta$.  However, the
%    placement is not symmetric since for aesthetic reasons we have
%    chosen to set $\sigma' = .2\,\mathrm{ex}$, which seems in general
%    to be a little less than the corresponding~$\sigma$.
%    Unfortunately, this means we can't calculate~$\delta'$ accurately
%    since there is no way to deduce $\eta$ (or, equivalently,
%    $\sigma$) from the font metric information available to us
%    within~\TeX.\footnote{By exploiting symmetries present in some
%    fonts, one can calculate $\eta$ for some of the accents in those
%    fonts, but this doesn't help us much since both $\sigma$
%    and~$\eta$ vary between accents.}
%
%    This leaves us in a bit of a bind, since it means there is no way
%    to calculate the depth accurately.  In despair, I've decided just
%    to pretend that $\delta' = \delta$ for now.
%
%    \subsection*{Finis}
%
%    The usual \cs{endinput} to ensure that random garbage at the end of
%    the file doesn't get copied by \fn{docstrip}.
%    \begin{macrocode}
\endinput
%    \end{macrocode}
%
% \CheckSum{365}
% \Finale
