Debian Codegraph @

texmf-dist/source/latex/amsmath/amsbsy.dtx

raw
1 %
2 % \iffalse meta-comment
3 %
4 % Copyright (C) 1995, 1999 American Mathematical Society.
5 % Copyright (C) 2016-2021
6 % LaTeX Project and American Mathematical Society.
7 %
8 % This work may be distributed and/or modified under the
9 % conditions of the LaTeX Project Public License, either version 1.3c
10 % of this license or (at your option) any later version.
11 % The latest version of this license is in
12 % https://www.latex-project.org/lppl.txt
13 % and version 1.3c or later is part of all distributions of LaTeX
14 % version 2005/12/01 or later.
15 %
16 % This work has the LPPL maintenance status `maintained'.
17 %
18 % The Current Maintainer of this work is the LaTeX Project.
19 %
20 % \fi
21 %
22 %\iffalse
23 %<*driver>
24 \documentclass{amsdtx}
25 \def\MaintainedByLaTeXTeam#1{%
26 \begin{center}%
27 \fbox{\fbox{\begin{tabular}{@{}l@{}}%
28 This file is maintained by the \LaTeX{} Project team.\\%
29 Bug reports can be opened (category \texttt{#1}) at\\%
30 \url{https://latex-project.org/bugs/}.\end{tabular}}}\end{center}}
31 \usepackage{amsbsy}
32 \GetFileInfo{amsbsy.sty}
33 \begin{document}
34 \title{The \pkg{amsbsy} package}
35 \author{Frank Mittelbach\and Rainer Sch\"opf\and Michael Downes}
36 \date{Version \fileversion, \filedate}
37 \DocInput{amsbsy.dtx}
38 \end{document}
39 %</driver>
40 %\fi
41 %
42 % \maketitle
43 % \MaintainedByLaTeXTeam{amslatex}
44 %
45 % \MakeShortVerb\|
46 %
47 % \section{Introduction}
48 %
49 % The package \texttt{amsbsy}, first written in 1989, implements a
50 % few commands for producing \textbf{bold} characters in the `normal'
51 % \emph{math version}.
52 % \begin{quote}\em
53 % Note: It is recommended nowadays to use the \pkg{bm} package, which
54 % became available in 1997.
55 % \end{quote}
56 %
57 % If we have bold fonts which contain the character in question then
58 % we will use these fonts to produce the wanted character. But
59 % sometimes math fonts are only available in a certain weight
60 % (e.g.\ the AMS symbol fonts).
61 % \DescribeMacro\pmb
62 % For these cases we provide a command which is called \verb+\pmb+ (an
63 % acronym for \textbf{p}oor \textbf{m}an's \textbf{b}old) with one argument.
64 % The bolder weight is achieved by copying the argument three times in
65 % slightly different positions which is better than nothing but no
66 % match for a real bold font.
67 %
68 % \DescribeMacro\boldsymbol
69 % There also exists the \verb+\boldsymbol+ command which is better in
70 % all cases where bold fonts exists. This command will internally
71 % switch to the corresponding `bold' \emph{math version} typeset its
72 % argument in this version.
73 %
74 % Both commands will preserve the nature of their arguments, i.e.\ if
75 % they get a relational atom their result will again be a relation as
76 % far as \tex/'s mathspacing is concerned.
77 %
78 % Since it is good policy to make at least a small test we try to
79 % typeset the infinity sign ($\infty$) first with \verb+\pmb+ and then
80 % with \verb+\boldsymbol+.
81 % \[
82 % \pmb{\infty} = \boldsymbol{\infty} \quad ?
83 % \]
84 % \MaybeStop{}
85 %
86 % Standard package info.
87 % \begin{macrocode}
88 \NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
89 [1994/12/01]% LaTeX date must December 1994 or later
90 \ProvidesPackage{amsbsy}[1999/11/29 v1.2d Bold Symbols]
91 % \end{macrocode}
92 %
93 % \section{The implementation}
94 %
95 % We need some functions from the \pkg{amsgen} package.
96 % \begin{macrocode}
97 \RequirePackage{amsgen}
98 % \end{macrocode}
99 %
100 %\begin{macro}{\boldsymbol}
101 % In implementing boldsymbol, we must take into account \tex/'s
102 % limitation of only 16 mathgroups (math families, in Knuth's
103 % terminology). If we wanted to maintain mathgroups for both the bold
104 % and non-bold version of each math font, it would not take long to
105 % run out of mathgroups. Therefore what we do instead for a bold
106 % symbol is embed it in an \verb|\hbox|; inside that \verb|\hbox|,
107 % when we start another math formula, we can change all the
108 % mathgroups to their bold equivalents.
109 %
110 % However, to get the correct math style inside the hbox (display,
111 % text, script or scriptscript) we have to use \verb|\mathchoice|.
112 % Since \verb|\mathversion{bold}| has a lot of overhead, and
113 % \verb|\mathchoice| typesets the argument text four times, we would
114 % rather not put the \verb|\mathversion| command inside each
115 % \verb|\hbox| in the \verb|\mathchoice|; on the other hand,
116 % \verb|\mathversion| gives an error message if it's used in math
117 % mode. Therefore if we want to execute \verb|\mathversion{bold}|
118 % before starting the \verb|\mathchoice| we have to temporarily
119 % disable the \verb|\@nomath| error. (The error message is intended
120 % to keep people from accidentally emboldening a preceding part of a
121 % math formula, since only the mathgroups defined at the end of a
122 % math formula will determine the fonts used in that formula; but we
123 % are going to typeset our bold symbol not in the current formula but
124 % in an embedded formula, so that this danger doesn't apply here.)
125 % \begin{macrocode}
126 \DeclareRobustCommand{\boldsymbol}[1]{%
127 % \end{macrocode}
128 % Start a group to localize the change of \verb|\@nomath|:
129 % \begin{macrocode}
130 \begingroup
131 % \end{macrocode}
132 % Disable \verb|\@nomath| so that we don't have to leave math
133 % mode before executing \verb|\mathversion|:
134 % \begin{macrocode}
135 \let\@nomath\@gobble \mathversion{bold}%
136 % \end{macrocode}
137 % \cs{math@atom} is a test macro which looks at its argument and
138 % produces a math atom of the proper class.
139 % \begin{macrocode}
140 \math@atom{#1}{%
141 % \end{macrocode}
142 % Although it is tempting to use \verb|\text| here, to save some
143 % main memory, that caused a bug in the past due to some internal
144 % interactions with \verb|\mathversion|.
145 % \begin{macrocode}
146 \mathchoice%
147 {\hbox{$\m@th\displaystyle#1$}}%
148 {\hbox{$\m@th\textstyle#1$}}%
149 {\hbox{$\m@th\scriptstyle#1$}}%
150 {\hbox{$\m@th\scriptscriptstyle#1$}}}%
151 % \end{macrocode}
152 % End the group we started earlier.
153 % \begin{macrocode}
154 \endgroup}
155 % \end{macrocode}
156 % \end{macro}
157 %
158 % \begin{macro}{\math@atom}
159 % The macro \verb+\math@atom+ looks at its argument and produce a
160 % correct math atom, i.e.\ a primitive like \verb+\mathopen+.
161 % Until the day we have a real implementation for all cases we use
162 % the \verb+\binrel@+ command from \amstex/ which can distinguish
163 % between binary, relation and ord atoms.
164 % \begin{macrocode}
165 \def\math@atom#1#2{%
166 \binrel@{#1}\binrel@@{#2}}
167 % \end{macrocode}
168 % \end{macro}
169 %
170 % \begin{macro}{\pmb}
171 % Poor man's bold command, works by typesetting multiple copies of
172 % the given argument with small offsets.
173 % \begin{macrocode}
174 \DeclareRobustCommand{\pmb}{%
175 \ifmmode\else \expandafter\pmb@@\fi\mathpalette\pmb@}
176 % \end{macrocode}
177 %
178 % \cs{pmb@@} is called by \cn{pmb} in the non-math-mode case.
179 % Discard the first two arguments which are for the math-mode case.
180 % \begin{macrocode}
181 \def\pmb@@#1#2#3{\leavevmode\setboxz@h{#3}%
182 \dimen@-\wdz@
183 \kern-.5\ex@\copy\z@
184 \kern\dimen@\kern.25\ex@\raise.4\ex@\copy\z@
185 \kern\dimen@\kern.25\ex@\box\z@
186 }
187 % \end{macrocode}
188 %
189 % \begin{macrocode}
190 \newdimen\pmbraise@
191 % \end{macrocode}
192 % Note: because of the use of \cs{mathpalette}, if \cs{pmb@} is applied to a
193 % single math italic character (or a single character from some other
194 % slanted math font), the italic correction will be added. This will
195 % cause subscripts to fall too far away from the character in some
196 % cases, e.g., $\pmb{T}_1$ or $\pmb{\mathcal{T}}_1$.
197 % \begin{macrocode}
198 \def\pmb@#1#2{\setbox8\hbox{$\m@th#1{#2}$}%
199 \setboxz@h{$\m@th#1\mkern.5mu$}\pmbraise@\wdz@
200 \binrel@{#2}%
201 \dimen@-\wd8 %
202 \binrel@@{%
203 \mkern-.8mu\copy8 %
204 \kern\dimen@\mkern.4mu\raise\pmbraise@\copy8 %
205 \kern\dimen@\mkern.4mu\box8 }%
206 }
207 % \end{macrocode}
208 % \end{macro}
209 %
210 % \begin{macrocode}
211 \def\binrel@#1{\begingroup
212 \setboxz@h{\thinmuskip0mu
213 \medmuskip\m@ne mu\thickmuskip\@ne mu
214 \setbox\tw@\hbox{$#1\m@th$}\kern-\wd\tw@
215 ${}#1{}\m@th$}%
216 % \end{macrocode}
217 % The \cn{noexpand} here should be unnecessary, but just in case
218 % \ldots
219 % \begin{macrocode}
220 \edef\@tempa{\endgroup\let\noexpand\binrel@@
221 \ifdim\wdz@<\z@ \mathbin
222 \else\ifdim\wdz@>\z@ \mathrel
223 \else \relax\fi\fi}%
224 \@tempa
225 }
226 % \end{macrocode}
227 % For completeness, assign a default value for \cs{binrel@@}.
228 % \begin{macrocode}
229 \let\binrel@@\relax
230 % \end{macrocode}
231 %
232 % The usual \cs{endinput} to ensure that random garbage at the end of
233 % the file doesn't get copied by \fn{docstrip}.
234 % \begin{macrocode}
235 \endinput
236 % \end{macrocode}
237 %
238 % \CheckSum{131}
239 % \Finale