summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/amsfonts/amsfonts.dtx
blob: 3b450023a5c1129e2f0b8eaf83436f6b4ec8581f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
%%% ====================================================================
%%% @LaTeX-file{
%%%   filename        = "amsfonts.dtx",
%%%   version         = "2.2f",
%%%   date            = "2001/10/25",
%%%   time            = "11:51:34 EDT",
%%%   checksum        = "12894 459 2125 19071",
%%%   author          = "American Mathematical Society",
%%%   copyright       = "Copyright 2001 American Mathematical Society,
%%%                      all rights reserved.  Copying of this file is
%%%                      authorized only if either:
%%%                      (1) you make absolutely no changes to your copy,
%%%                      including name; OR
%%%                      (2) if you do make changes, you first rename it
%%%                      to some other name.",
%%%   address         = "American Mathematical Society,
%%%                      Technical Support,
%%%                      Publications Technical Group,
%%%                      P. O. Box 6248,
%%%                      Providence, RI 02940,
%%%                      USA",
%%%   telephone       = "401-455-4080 or (in the USA and Canada)
%%%                      800-321-4AMS (321-4267)",
%%%   FAX             = "401-331-3842",
%%%   email           = "tech-support@ams.org (Internet)",
%%%   codetable       = "ISO/ASCII",
%%%   keywords        = "latex, amslatex, ams-latex, amsfonts, msam,
%%%                      msbm, eufm, blackboard bold",
%%%   supported       = "yes",
%%%   abstract        = "This file is part of the AMSFonts distribution.
%%%                      It provides easy access in \LaTeXe{} to certain
%%%                      math fonts for extra math symbols, fraktur
%%%                      letters, and blackboard bold letters. See the
%%%                      AMSFonts user's guide for more information.",
%%%   docstring       = "The checksum field above contains a CRC-16
%%%                      checksum as the first value, followed by the
%%%                      equivalent of the standard UNIX wc (word
%%%                      count) utility output of lines, words, and
%%%                      characters.  This is produced by Robert
%%%                      Solovay's checksum utility.",
%%% }
%%% ====================================================================
% \iffalse
%<*driver>
\documentclass{amsdtx}
\begin{document}
\title{The \pkg{amsfonts} package}
\author{Frank Mittelbach\\Rainer Sch\"opf\\Michael Downes}
\date{Version \fileversion, \filedate}
\hDocInput{amsfonts.dtx}
\end{document}
%</driver>
% \fi
%
% \maketitle
%
% \MakeShortVerb\|
%
% \section{Introduction}
%
%    The package \pkg{amsfonts} makes some of the math fonts from the
%    AMSFonts package usable within \latex/. For wholesale substitution
%    of Euler math, see Frank Jensen's \pkg{euler} package.
%
% \StopEventually{}
%
%    Provide package info.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
[1994/12/01]% LaTeX date must be December 1994 or later
\ProvidesPackage{amsfonts}[2001/10/25 v2.2f]
%    \end{macrocode}
%
% \section{Package options}
%
% \subsection{The \opt{psamsfonts} option}
%
%    The \opt{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 \fn{.tfm} files provided below size 10 are
%    5 and 7, rather than 5,6,7,8,9. This means that if the standard
%    \fn{.fd} files are used, any attempt to use 6,8,9 point math will
%    result in error messages about missing \fn{.tfm} files. In order to
%    ensure that the proper \fn{.fd} files are used for the PS case, we
%    load them immediately. Otherwise the \fn{.fd} files would be
%    auto-loaded when \LaTeX{} 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 \fn{.fd} files.
%    \begin{macrocode}
\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}{}%
}
%    \end{macrocode}
%
% \subsection{Font definitions for \fn{cmex}}
%    The AMSFonts distribution provides some extra sizes of the
%    \fn{cmex} font; these will not be used by \latex/ unless we change
%    the font definition that refers to \fn{cmex}. However, when the
%    Y\&Y/Blue Sky Research PostScript versions of the AMSFonts are
%    used, there is only \fn{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 \opt{psamsfonts} option, and initialize
%    it to `1'. This means that sizes 7--9 of \fn{cmex} will be used,
%    unless the \opt{psamsfonts} option is in effect. There's probably a
%    better way to do this (please submit your suggestions to
%    \fn{tech-support@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 \pkg{amsmath}, and
%    we don't override its value.
%    \begin{macrocode}
\@ifundefined{cmex@opt}{\def\cmex@opt{1}}{}
%    \end{macrocode}
%
%    Process the options for this package.
%    \begin{macrocode}
\ProcessOptions\relax
%    \end{macrocode}
%
%    Processing the \opt{cmex7} and \opt{cmex10} options is a little tricky
%    because of different possible loading orders for \pkg{amsmath} and
%    \pkg{amsfonts}. The package \pkg{amsmath} sets the \cs{cmex@opt}
%    flag to 7 or 10, and the package \pkg{amsfonts} sets the flag to 1
%    or 0.
%    \begin{macrocode}
\ifnum\cmex@opt=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
%    \end{macrocode}
%    Force reloading of the OMX/cmex font definition file.
%    \begin{macrocode}
    \begingroup
    \expandafter\let\csname OMX+cmex\endcsname\relax
    \fontencoding{OMX}\fontfamily{cmex}%
    \try@load@fontshape
    \endgroup
%    \end{macrocode}
%    The \fn{cmex10} font gets special preload handling in the building
%    of the \latex/ format file; we need an extra bit here to work around
%    that.
%    \begin{macrocode}
    \expandafter\let\csname OMX/cmex/m/n/10\endcsname\relax
    \def\cmex@opt{0}%
  \fi
\fi
%    \end{macrocode}
%
% \section{Miscellaneous}
%    In case the \pkg{amsfonts} package is used apart from the
%    \pkg{amsmath} package, we need to define the following functions.
%    \begin{macrocode}
\providecommand*{\@mathmeasure}[3]{%
  \setbox#1\hbox{\frozen@everymath\@emptytoks\m@th$#2#3$}}
%    \end{macrocode}
%    \cs{newtoks} was still outer in early releases of \LaTeXe, so
%    we need to take a little extra care here.
%    \begin{macrocode}
\@ifundefined{@emptytoks}{\csname newtoks\endcsname\@emptytoks}{}
%    \end{macrocode}
%
% \section{Preparing to use the extra math fonts}
%
%    We declare the encoding schemes for two AMS math symbol fonts.
%    \texttt{U} encoding with \cs{noaccents@} for math is already
%    provided in base NFSS.
%
%    The AMS symbol fonts will be assigned via \cs{DeclareSymbolFont}
%    since most of their characters are accessed with the \cs{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 \cs{SetSymbolFont} commands for
%    mathversion `bold'.
%    \begin{macrocode}
\DeclareSymbolFont{AMSa}{U}{msa}{m}{n}
\DeclareSymbolFont{AMSb}{U}{msb}{m}{n}
%    \end{macrocode}
%
%    The next constructs are symbols that work the same in text or math.
%    They are built the hard way using |\hexnumber@\sym...|.
%    We can't use \cs{DeclareTextSymbol} since it only specifies the
%    font by its encoding, which, being \texttt{U} for both \fn{msam}
%    \fn{msbm}, is ambiguous.
%    \begin{macrocode}
\@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}
}{}
%    \end{macrocode}
%
%    We now define a few symbols which reside in the \fn{msam} and \fn{msbm}
%    fonts. The \cs{catcode} change is to ensure that the double-quote
%    character is not active (which at one time was a problem when something
%    like \fn{german.sty} was used).
%    \begin{macrocode}
\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}
%    \end{macrocode}
%
%    The next two definitions redefine the \cn{widehat} and
%    \cn{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.
%    \begin{macrocode}
\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}
%    \end{macrocode}
%    Now we define two special arrows which are built with special
%    characters from the first symbol font.
%    \begin{macrocode}
\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
%    \end{macrocode}
%    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 \cs{mathchardef}. The majority
%    however will be defined only if the user loads the \fn{amssymb}
%    package or explicitly defines symbols using the
%    \cs{DeclareMathSymbol} macro.
%
%    Finally we test the \cs{DeclareMathSymbol} command by redefining the
%    \PlainTeX{} symbols which were 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 \cs{DeclareMathSymbol} will complain that they are
%    already defined.
%    \begin{macrocode}
\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}
%    \end{macrocode}
%
%    Include a few common symbols which are both in \fn{msam} or \fn{msbm}
%    and also in \fn{lasy}, which might have been loaded already, so it
%    is a good idea to make them undefined.
%    \begin{macrocode}
\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}
%    \end{macrocode}
%
%    Now we close the group so that |"| will get its old \cs{catcode}
%    back.
%    \begin{macrocode}
\endgroup
%    \end{macrocode}
%
% \section{Defining \protect\meta{math alphabet identifiers}}
%
% \begin{macro}{\mathfrak}
%    The Fraktur alphabet will be accessed by the command
%    \cn{mathfrak} inside of math mode.
%    \begin{macrocode}
\DeclareMathAlphabet{\mathfrak}{U}{euf}{m}{n}
\SetMathAlphabet{\mathfrak}{bold}{U}{euf}{b}{n}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\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.
%    \begin{macrocode}
\DeclareSymbolFontAlphabet{\mathbb}{AMSb}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Setting up the fonts for correct accents in math}
%
%    There are a few \meta{math alphabets} which don't have any or
%    enough accents for math in the corresponding fonts. For example the
%    \cn{mathbb} \meta{math alphabet identifier} comes from a symbol font
%    with none of the normal accents in the correct places. \AmSTeX{}
%    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
%    \cs{accentclass@}. To support this idea \meta{math alphabet
%    identfiers} which come with their own accents should set this macro
%    to the number \texttt{7} (variable family in the terminology of the
%    \TeX{}book); all others should set it to \texttt{0} so that the accents
%    are taken from the \meta{math group} zero in the current \emph{math
%    version}.
%
%    There is a \cs{DeclareFontEncodingDefaults} macro which declares such
%    defaults. For the \pkg{amsfonts} package we set this default in the
%    following way. This information will be ignored unless the \pkg{amsmath}
%    package is also loaded.
%    \begin{macrocode}
\DeclareFontEncodingDefaults{\relax}{\def\accentclass@{7}}
%    \end{macrocode}
%
% \section{Some backward compatibility definitions}
%
%    The following commands are provided for compatibility with pre-1995
%    versions of the \pkg{amsfonts} package. If a \cn{documentclass}
%    command is used the \cs{@obsolete} function will issue a warning
%    saying that the command is obsolete.
%
%    Upgraded to robust commands. [bnb, 1996/09/29]
% \begin{macro}{\frak}
% \begin{macro}{\Bbb}
% \begin{macro}{\bold}
%    \begin{macrocode}
\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}}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%    The \cs{newsymbol} command has different syntax than
%    \cs{DeclareMathSymbol} so it cannot use the direct substitution
%    function \cs{@subst@obsolete}.
%    \begin{macrocode}
\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
%    \end{macrocode}
%
%  \begin{macro}{\@obsolete}
%    This command gives a warning on the first use that the command given
%    as second argument is deprecated/obsolete, with the third argument
%    recommended as a substitute. In compatibility mode we just continue
%    silently.
%    \begin{macrocode}
\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
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\@subst@obsolete}
%    For obsolete commands that have a substitute command.
%    \begin{macrocode}
\def\@subst@obsolete#1#2#3{\@obsolete{#1}#2#3\gdef#2{#3}#2}
%    \end{macrocode}
%  \end{macro}
%
%    First we load the symbols under the official AMS names and then
%    define the \latex/ names via \cs{let} unless they are already
%    defined (which probably means that the \fn{lasy} fonts are defined).
%    \begin{macrocode}
\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}
%    \end{macrocode}
%    Check if the \pkg{latexsym} package has already been loaded
%    \begin{macrocode}
\@ifpackageloaded{latexsym}{\@tempswafalse}{\@tempswatrue}
\if@tempswa
  \global\let\Box\square
  \global\let\Diamond\lozenge
  \global\let\leadsto\rightsquigarrow
%    \end{macrocode}
%    \cn{lhd} and its relatives look like \cn{vartriangleleft} and its
%    relatives, but the math atom types are different (according to the
%    \latex/ book). So we need to issue different \cs{DeclareMathSymbol}
%    statements.
%    \begin{macrocode}
  \global\let\lhd\@@undefined
  \global\let\unlhd\@@undefined
  \global\let\rhd\@@undefined
  \global\let\unrhd\@@undefined
  \DeclareMathSymbol{\lhd}     {\mathbin}{AMSa}{"43}
  \DeclareMathSymbol{\unlhd}   {\mathbin}{AMSa}{"45}
  \DeclareMathSymbol{\rhd}     {\mathbin}{AMSa}{"42}
  \DeclareMathSymbol{\unrhd}   {\mathbin}{AMSa}{"44}
%    \end{macrocode}
%    No equivalent of the \cn{\Join} symbol in \fn{lasy} is available in
%    \fn{msam} or \fn{msbm} so we make do with a composite of two characters.
%    \begin{macrocode}
\xdef\Join{\mathrel{\mathchar"0\hexnumber@\symAMSb 6F\mkern-13.8mu%
  \mathchar"0\hexnumber@\symAMSb 6E}}
\fi
\endgroup
%    \end{macrocode}
%
%    The usual \cn{endinput} to ensure that random garbage at the end of
%    the file doesn't get copied by \fn{docstrip}.
%    \begin{macrocode}
\endinput
%    \end{macrocode}
%
% \changes{v1.2beta}{1994/10/25}{Made every@math@size code explicitly global}
% \changes{v1.2}{1994/12/08}{Exported non-font stuff elsewhere}
% \changes{v2.2}{1995/01/05}{Moved square, Box, etc to compat-only section}
% \changes{v2.2a}{1995/01/30}{Added missing def for @mathmeasure}
% \changes{v2.2b}{1995/02/01}{Dealt with cmex font complications}
%
% \CheckSum{373}
% \Finale