The amsfonts package

Frank Mittelbach Rainer Schöpf Michael Downes

Version 2.2e, 1997/09/17

1 Introduction

The package amsfonts makes some of the math fonts from the AMSFonts package usable within L^{A}TEX. For wholesale substitution of Euler math, see Frank Jensen’s euler package.

Provide package info.

  \NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
  [1994/06/01]% LaTeX date must June 1994 or later
  \ProvidesPackage{amsfonts}[1997/09/17 v2.2e]

2 Package options

2.1 The psamsfonts option The ‘psamsfonts’ option is intended to mean that the Y&Y/Blue Sky Research PostScript versions of the AMSFonts should be used. In that font set, the only .tfm files provided below size 10 are 5 and 7, rather than 5,6,7,8,9. This means that if the standard .fd files are used, any attempt to use 6,8,9 point math will result in error messages about missing .tfm files. In order to ensure that the proper fontshape statements are used for the PS case, we load them immediately. Otherwise the .fd files would be auto-loaded when L^{A}TEX encounters the first math formula in a document, and the standard auto-loading mechanisms don’t provide a way [that I know of—mjd,7-Oct-1994] to choose the ‘57’ varieties of the .fd files.

  \DeclareOption{psamsfonts}{%
    \ifnum\cmex@opt=7 \def\cmex@opt{10}%
    \else \def\cmex@opt{0}\fi
    \DeclareFontFamily{U}{msa}{}%
    \DeclareFontShape{U}{msa}{m}{n}{<-6>msam5<6-8>msam7<8->msam10}{}%
    \DeclareFontFamily{U}{msb}{}%
    \DeclareFontShape{U}{msb}{m}{n}{<-6>msbm5<6-8>msbm7<8->msbm10}{}%
    \DeclareFontFamily{U}{euf}{}%
    \DeclareFontShape{U}{euf}{m}{n}{<-6>eufm5<6-8>eufm7<8->eufm10}{}%
    \DeclareFontShape{U}{euf}{b}{n}{<-6>eufb5<6-8>eufb7<8->eufb10}{}%
  }

2.2 Font definitions for cmex The AMSFonts distribution provides some extra sizes of the cmex font; these will not be used by L^{A}TEX unless we change the font definition that refers to cmex. However, when the Y&Y/Blue Sky Research PostScript versions of the AMS-Fonts are used, there is only cmex10, and no smaller sizes. Because of complications in the order of option processing, we use a flag that will be set to ‘0’ by the psamsfonts option, and initialize it to ‘1’. This means that sizes 7–9 of cmex will be used, unless the psamsfonts option is in effect. There’s probably a better way to do this (submit your suggestions please to tech-support@math.ams.org) but I don’t see anything obvious at the moment [mjd,1995/01/31]. If the flag is already defined, then we assume that it was set by an earlier load of amsmath, and we don’t override its value.

  \@ifundefined{cmex@opt}{\def\cmex@opt{1}}{}

Process the options for this package.

  \ProcessOptions\relax

Processing the cmex7 and cmex10 options is a little tricky because of different possible loading orders for amsmath and amsfonts. The package amsmath sets the \cmex@opt flag to 7 or 10, and the package amsfonts sets the flag to 1 or 0.

  \ifnum\cmex@opt=1 \relax
    \DeclareFontShape{OMX}{cmex}{m}{n}{<-8>cmex7<8>cmex8<9>cmex9%
      <10><10.95><12><14.4><17.28><20.74><24.88>cmex10}{}%
    \expandafter\let\csname OMX/cmex/m/n/10\endcsname\relax
  \else
    \ifnum\cmex@opt=10 % need to override cmex7 fontdef from amsmath

Force reloading of the OMX/cmex font definition file.

      \begingroup
      \expandafter\let\csname OMX+cmex\endcsname\relax
      \fontencoding{OMX}\fontfamily{cmex}%
      \try@load@fontshape
      \endgroup

The cmex10 font gets special preload handling in the building of the L^{A}TEX format file, need an extra bit here to work around that.

      \expandafter\let\csname OMX/cmex/m/n/10\endcsname\relax
      \def\cmex@opt{0}%
    \fi
  \fi

3 Miscellaneous

In case the amsfonts package is used apart from the amsmath package, we need to define the following functions. Note: we don’t use \providecommand because the June 94 release of L^{A}TEX doesn’t support the * option for non-long commands and we don’t want to assume [at this time—1995/01/30] that all users have upgraded to the December 94 release.

  \@ifundefined{@mathmeasure}{%
    \def\@mathmeasure#1#2#3{\setbox#1\hbox{\frozen@everymath\@emptytoks

      \m@th$#2#3$}}
  }{}

\newtoks was still outer in early releases of L^{A}TEX2e, so we need to take a little extra care here.

  \@ifundefined{@emptytoks}{\csname newtoks\endcsname\@emptytoks}{}

4 Preparing to use the extra math fonts

We declare the encoding schemes for two AMS math symbol fonts. U encoding with \noaccents@ for math is already provided in base NFSS

The AMS symbol fonts will be assigned via \DeclareSymbolFont since most of their characters are accessed with the \mathchardef primitive. This means that these fonts are loaded for the particular size whenever a size or version switch is requested by the user. At the present time bold forms of these fonts don’t exist. So there are no overriding \SetSymbolFont commands for mathversion ‘bold’.

  \DeclareSymbolFont{AMSa}{U}{msa}{m}{n}
  \DeclareSymbolFont{AMSb}{U}{msb}{m}{n}

The next constructs are symbols that work the same in text or math. They are built the hard way using \hexnumber@\sym.... Also, for compatibility with both June 1994 and December 1994 releases of L^{A}TEX we avoid the use of

\DeclareTextSymbol here.
  \@ifundefined{yen}{%
    \edef\yen{\noexpand\mathhexbox{\hexnumber@\symAMSa}55}
  }{}
  \@ifundefined{checkmark}{%
    \edef\checkmark{\noexpand\mathhexbox{\hexnumber@\symAMSa}58}
  }{}
  \@ifundefined{circledR}{%
    \edef\circledR{\noexpand\mathhexbox{\hexnumber@\symAMSa}72}
  }{}
  \@ifundefined{maltese}{%
    \edef\maltese{\noexpand\mathhexbox{\hexnumber@\symAMSa}7A}
  }{}

We now define a few symbols which reside in the msam and msbm fonts The \catcode change is to ensure that the double-quote character is not active (which at one time was a problem when something like german.sty was used).

  \begingroup \catcode`\"=12
  \DeclareMathDelimiter\ulcorner{\mathopen} {AMSa}{"70}{AMSa}{"70}
  \DeclareMathDelimiter\urcorner{\mathclose}{AMSa}{"71}{AMSa}{"71}
  \DeclareMathDelimiter\llcorner{\mathopen} {AMSa}{"78}{AMSa}{"78}
  \DeclareMathDelimiter\lrcorner{\mathclose}{AMSa}{"79}{AMSa}{"79}

The next two definitions redefine the \widehat and \widetilde command to use a special accent if their argument is suitably wide. (In plain TEX these commands can produce three different accents depending on the size of the argument.) The current implementation will tend to give wrong results (tilde or hat symbol too wide) if these accents are used in script or scriptscript math style.

But making that part work properly is too much effort given the limitations of TEX 3.x.

\xdef\widehat#1{\noexpand\@mathmeasure\z@\textstyle{#1}%
  \noexpand\ifdim\noexpand\wd\z@>\tw@ em%
  \mathaccent"0\hexnumber@\symAMSb 5B{#1}%
  \noexpand\else\mathaccent"0362{#1}\noexpand\fi}
%
\xdef\widetilde#1{\noexpand\@mathmeasure\z@\textstyle{#1}%
  \noexpand\ifdim\noexpand\wd\z@>\tw@ em%
  \mathaccent"0\hexnumber@\symAMSb 5D{#1}%
  \noexpand\else\mathaccent"0365{#1}\noexpand\fi}

Now we define two special arrows which are built with special characters from the first symbol font.

\DeclareMathSymbol\dabar@{\mathord}{AMSa}{"39}
\xdef\dashrightarrow{\mathrel{\dabar@\dabar@
                              \mathchar"0\hexnumber@\symAMSa 4B}}%
\xdef\dashleftarrow{\mathrel{\mathchar"0\hexnumber@\symAMSa 4C\dabar@
                              \dabar@}}%
%
\global\let\dasharrow\dashrightarrow

To avoid using too many control sequence names by defining all new symbols provided with the two fonts, we defined so far only symbols which are not assigned via \mathchardef. The majority however will be only defined if the user calls the amssymb documentstyle option or by explicitly defining symbols

using the \DeclareMathSymbol macro.

Finally we test the \DeclareMathSymbol command by redefining the Plain TEX symbols which where made up from different characters (and thus could not change sizes properly) but are now available as real characters. Note that we have to make them undefined first otherwise \DeclareMathSymbol will complain that they are already defined.

\global\let\rightleftharpoons\undefined
\DeclareMathSymbol\rightleftharpoons{\mathrel}{AMSa}{"0A}
\global\let\angle\undefined
\DeclareMathSymbol\angle            {\mathord}{AMSa}{"5C}
\global\let\hbar\undefined
\DeclareMathSymbol\hbar             {\mathord}{AMSb}{"7E}
\global\let\sqsubset\undefined
\DeclareMathSymbol\sqsubset         {\mathrel}{AMSa}{"40}
\global\let\sqsupset\undefined
\DeclareMathSymbol\sqsupset         {\mathrel}{AMSa}{"41}
\global\let\mho\undefined
\DeclareMathSymbol\mho              {\mathord}{AMSb}{"66}

Now we close the group so that " will get its old \catcode back.

\endgroup

5. DEFINING ⟨MATH ALPHABET IDENTIFIERS⟩ 5

5 Defining ⟨math alphabet identifiers⟩

\mathfrak The Fraktur alphabet will be accessed by the command \mathfrak inside of

math mode.

  \DeclareMathAlphabet\mathfrak{U}{euf}{m}{n}
  \SetMathAlphabet\mathfrak{bold}{U}{euf}{b}{n}

\mathbb The AMS symbol font B contains the blackboard bold math alphabet. There is

only a single weight of this alphabet so it is used in all math versions.

  \DeclareSymbolFontAlphabet{\mathbb}{AMSb}

5.1 Setting up the fonts for correct accents in math There are a few ⟨math alphabets⟩ which don’t have any or enough accents for math in the corresponding fonts. For example the \mathbb ⟨math alphabet identifier⟩ comes from a symbol font with none of the normal accents in the correct places. AMS-TEX has a sophisticated solution for this problem: all math accents are defined in a way that the font where the accents are taken from depends on the current value of a macro called \accentclass@. To support this idea ⟨math alphabet identfier⟩ which come with their own accents should set this macro to the number 7 (variable family in the speech if the TEXbook) all others should set it to 0 so that the accents are taken from the ⟨math group⟩ zero in the current math version.

There is a \DeclareFontEncodingDefaults macro which declares such defaults. For the amsfonts package we set this default in the following way. This information will be ignored unless the amstex package is also loaded.

  \DeclareFontEncodingDefaults{\relax}{\def\accentclass@{7}}

6 Some backward compatibility definitions

The following commands are provided for compatibility with pre-1995 versions of

the amsfonts package. If a \documentclass command is used the \@obsolete

function will issue a warning saying that the command is obsolete.

Upgraded to robust commands. [bnb, 1996/09/29]

\frak \Bbb \bold
  \DeclareRobustCommand\frak[1]{%
    {\@subst@obsolete{amsfonts}\frak\mathfrak{#1}}}
  \DeclareRobustCommand\Bbb[1]{%
    {\@subst@obsolete{amsfonts}\Bbb\mathbb{#1}}}
  \DeclareRobustCommand\bold[1]{%
    {\@subst@obsolete{amsfonts}\bold\mathbf{#1}}}

The \newsymbol command has different syntax than \DeclareMathSymbol so it cannot use the direct substitution function \@subst@obsolete.

  \begingroup \catcode`\"=12 \relax
  \gdef\newsymbol#1#2#3#4#5{%
    \@obsolete{amsfonts}\newsymbol\DeclareMathSymbol
    \@ifdefinable#1{%
       \edef\next@

       {\ifcase #2 \or
          \hexnumber@\symAMSa\or
          \hexnumber@\symAMSb\fi}%
     \ifx\next@\@empty
       \PackageError{amsfonts}{\Invalid@@\newsymbol}\@ehd%
     \else
      \global\mathchardef#1"#3\next@#4#5
     \fi}}
\endgroup

\@obsolete This command gives a warning on the first use that the command given as second arg is deprecated/obsolete, with the third arg recommended as a substitute. In compatibility mode we just continue silently.

\long\def\@gobblethree#1#2#3{}
\if@compatibility
  \let\@obsolete\@gobblethree
\else
  \def\@obsolete#1#2#3{\PackageWarning{#1}{%
    Obsolete command \protect#2; \protect#3 should be used instead}}%
\fi

\@subst@obsolete For obsolete commands that have a substitute command.

\def\@subst@obsolete#1#2#3{\@obsolete{#1}#2#3\gdef#2{#3}#2}

First we load the symbols under the official AMS names and then define the L^{A}TEX names via \let unless they are already defined (which probably means that the lasy fonts are defined).

\begingroup \catcode`\"=12
\DeclareMathSymbol\square           {\mathord}{AMSa}{"03}
\DeclareMathSymbol\lozenge          {\mathord}{AMSa}{"06}
\DeclareMathSymbol\vartriangleright {\mathrel}{AMSa}{"42}
\DeclareMathSymbol\vartriangleleft  {\mathrel}{AMSa}{"43}
\DeclareMathSymbol\trianglerighteq  {\mathrel}{AMSa}{"44}
\DeclareMathSymbol\trianglelefteq   {\mathrel}{AMSa}{"45}
\DeclareMathSymbol\rightsquigarrow  {\mathrel}{AMSa}{"20}

Check if the latexsym package has already been loaded

\@ifpackageloaded{latexsym}{\@tempswafalse}{\@tempswatrue}
\if@tempswa
  \global\let\Box\square
  \global\let\Diamond\lozenge
  \global\let\leadsto\rightsquigarrow

\lhd and its relatives look like \vartriangleleft and its relatives, but the math atom types are different (according to the L^{A}TEX book). So we need to issue different \DeclareMathSymbol statements.

  \global\let\lhd\@@undefined
  \global\let\unlhd\@@undefined
  \global\let\rhd\@@undefined
  \global\let\unrhd\@@undefined

6. SOME BACKWARD COMPATIBILITY DEFINITIONS 7

\DeclareMathSymbol\lhd     {\mathbin}{AMSa}{"43}
\DeclareMathSymbol\unlhd   {\mathbin}{AMSa}{"45}
\DeclareMathSymbol\rhd     {\mathbin}{AMSa}{"42}
\DeclareMathSymbol\unrhd   {\mathbin}{AMSa}{"44}

No equivalent of the \Join symbol in lasy is available in msam or msbm so we make do with a composite of two characters.

\xdef\Join{\mathrel{\mathchar"0\hexnumber@\symAMSb 6F\mkern-13.8mu%
\mathchar"0\hexnumber@\symAMSb 6E}}
\fi
\endgroup

The usual \endinput to ensure that random garbage at the end of the file doesn’t get copied by docstrip.

\endinput