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
|
%D \module
%D [ file=font-bfm,
%D version=2003.11.25,
%D title=\CONTEXT\ Font Macros,
%D subtitle=Mixed Normal and Bold Math,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
\writestatus{loading}{Context Font Macros / Mixed Bold Math Support}
%D The following example demonstrates how to use normal, bold, and mixed
%D normal|/|bold math. Since not everyone has the Lucida on his|/|her
%D machine we don't show the result.
%D
%D \starttyping
%D \setupformulas
%D [method=bold]
%D
%D \definetypeface [mainface] [rm] [serif] [lucida] [default] [encoding=texnansi]
%D \definetypeface [mainface] [tt] [mono] [lucida] [default] [encoding=texnansi]
%D \definetypeface [mainface] [ss] [sans] [lucida] [default] [encoding=texnansi]
%D \definetypeface [mainface] [mm] [math] [lucida] [default] [encoding=texnansi]
%D \definetypeface [mainface] [mm] [bfmath] [lucida] [default] [encoding=texnansi]
%D
%D \definetypeface [boldmath] [rm] [serif] [lucida] [default] [encoding=texnansi]
%D \definetypeface [boldmath] [tt] [mono] [lucida] [default] [encoding=texnansi]
%D \definetypeface [boldmath] [ss] [sans] [lucida] [default] [encoding=texnansi]
%D \definetypeface [boldmath] [mm] [boldmath] [lucida] [default] [encoding=texnansi]
%D
%D \switchtobodyfont[mainface]
%D
%D \startlines
%D $\mainface x=10 \Gamma \Delta \alpha \delta \zeta$
%D $\boldmath x=10 \Gamma \Delta \alpha \delta \zeta$
%D \stoplines
%D
%D \startformula
%D x=12=\fontbody \Gamma \Delta \alpha \delta \zeta
%D \stopformula
%D
%D \startformula[mainface]
%D x=12=\fontbody \Gamma \Delta \alpha \delta \zeta
%D \stopformula
%D
%D \startformula[boldmath]
%D x=12=\fontbody \Gamma \Delta \alpha \delta \zeta
%D \stopformula
%D
%D \startformula[boldmath,8pt]
%D x=8=\fontbody \Gamma \Delta \alpha \delta \zeta
%D \stopformula
%D
%D \startformula[boldmath,12pt,small]
%D x=12s=\fontbody \Gamma \Delta \alpha \delta \zeta
%D \stopformula
%D
%D \startformula[boldmath,small]
%D x=s=\fontbody \Gamma \Delta \alpha \delta \zeta
%D \stopformula
%D
%D \startformula[boldmath,10pt]
%D x=10=\fontbody \Gamma \Delta \alpha \delta \zeta
%D \stopformula
%D
%D \startformula[boldmath,11pt,small]
%D x=11s=\fontbody \Gamma \Delta \alpha \delta \zeta
%D \stopformula
%D
%D \startformula[boldmath,9pt]
%D x=9=\fontbody \Gamma \Delta \alpha \delta \zeta
%D \stopformula
%D
%D \startlines
%D \formula{1=2x}
%D \formula[boldmath]{1=2x}
%D \formula[mainface]{1=2x}
%D \formula[mainface]{1 \theta \Gamma = \bfm 1 \beta \hbox{\sl test}\Gamma \alpha ' x x}
%D \formula[mainface]{1 \theta \Gamma = {\bfm 1 \beta \hbox{\sl test}\Gamma \alpha ' x} x}
%D \stoplines
%D \stoptyping
\unprotect
%D \TEX\ has some hard wired expectations about where to look for
%D certain characters. This means that we cannot overload the families
%D 0 upto~3. Also, since we use C upto~F for math as well, we are left
%D with the range 4 upto~B.
\chardef\mrbffam\itfam \edef\c!mrbf{\c!mr\c!bf} \let\hexmrbffam\hexitfam % 4 it
\chardef\exbffam\slfam \edef\c!exbf{\c!ex\c!bf} \let\hexexbffam\hexslfam % 5 sl
\chardef\mibffam\bffam \edef\c!mibf{\c!mi\c!bf} \let\hexmibffam\hexbffam % 6 bf
\chardef\sybffam\nnfam \edef\c!sybf{\c!sy\c!bf} \let\hexsybffam\hexnnfam % 7 nn
\chardef\mabffam\bsfam \edef\c!mabf{\c!ma\c!bf} \let\hexmabffam\hexbsfam % 8 bs
\chardef\mbbffam\bifam \edef\c!mbbf{\c!mb\c!bf} \let\hexmbbffam\hexbifam % 9 bi
\chardef\mcbffam\scfam \edef\c!mcbf{\c!mc\c!bf} \let\hexmcbffam\hexscfam % A sc
\chardef\mdbffam\scfam \edef\c!mdbf{\c!mc\c!bf} \let\hexmdbffam\hexscfam % B tf % tricky
%D The next bunch of code looks horrible and tricky but one has to keep in
%D mind that because \TEX\ makes several passes over the math list we need to
%D make sure that grouping is handled well. Later assignments to a family
%D overload previous ones, the last one counts.
\newtoks \boldmathstrategies
\newtoks \boldsymbstrategies
\appendtoks
\dosetmathfamily\mrbffam\textface\scriptface\scriptscriptface\c!mrbf\mrfallback
\dosetmathfamily\mibffam\textface\scriptface\scriptscriptface\c!mibf\empty
\dosetmathfamily\sybffam\textface\scriptface\scriptscriptface\c!sybf\empty
\dosetmathfamily\exbffam\textface\textface \textface \c!exbf\empty
\dosetmathfamily\mabffam\textface\scriptface\scriptscriptface\c!mabf\empty
\dosetmathfamily\mbbffam\textface\scriptface\scriptscriptface\c!mbbf\empty
\dosetmathfamily\mcbffam\textface\scriptface\scriptscriptface\c!mcbf\empty
\to \boldmathstrategies
\appendtoks
\dosetskewchar\mifam\defaultskewcharmi
\dosetskewchar\syfam\defaultskewcharsy
\to \boldmathstrategies
\appendtoks
\dosetsymbfamily\mrbffam\textface\scriptface\scriptscriptface\c!mrbf
\dosetsymbfamily\mibffam\textface\scriptface\scriptscriptface\c!mibf
\dosetsymbfamily\sybffam\textface\scriptface\scriptscriptface\c!sybf
\dosetsymbfamily\exbffam\textface\textface \textface \c!exbf
\dosetsymbfamily\mabffam\textface\scriptface\scriptscriptface\c!mabf
\dosetsymbfamily\mbbffam\textface\scriptface\scriptscriptface\c!mbbf
\dosetsymbfamily\mcbffam\textface\scriptface\scriptscriptface\c!mcbf
\to \boldsymbstrategies
%D Here comes the real mess (due to semi||global settings en multiple
%D passes over the math list once the input is expanded.
\newevery \everyboldfacemath \relax
\chardef \boldfacemathmethod \zerocount
\appendtoks
\ifcase\boldfacemathmethod \else \the\boldmathstrategies \fi
\to \mathstrategies
\appendtoks
\ifcase\boldfacemathmethod \else \the\boldsymbstrategies \fi
\to \symbstrategies
\appendtoks
\let\mrfam\mrbffam \let\c!mr\c!mrbf \let\hexmrfam\hexmrbffam
\let\mifam\mibffam \let\c!mi\c!mibf \let\hexmifam\hexmibffam
\let\syfam\sybffam \let\c!sy\c!sybf \let\hexsyfam\hexsybffam
\let\exfam\exbffam \let\c!ex\c!exbf \let\hexexfam\hexexbffam
\let\mafam\mabffam \let\c!ma\c!mabf \let\hexmafam\hexmabffam
\let\mbfam\mbbffam \let\c!mb\c!mbbf \let\hexmbfam\hexmbbffam
\let\mcfam\mcbffam \let\c!mc\c!mcbf \let\hexmcfam\hexmcbffam
\to \everyboldfacemath
\appendtoks
\let\mathsubfamily\c!bf
\to \everyboldfacemath
\appendtoks
\synchronizemath \aftergroup\synchronizemath
\to \everyboldfacemath
%D \macros
%D {boldfacemath, bfm, autoboldfacemath}
%D
%D These are the user commands, with \type {\bfm} being the most comfortable.
\def\boldfacemath {\ifcase\boldfacemathmethod\else\the\everyboldfacemath\fi}
\def\bfm {\boldfacemath} % no \let, so that we can redefine
\def\autoboldfacemath{\appendtoks\ifcase\boldfacemathmethod\else\let\bf\boldfacemath\fi\to\everymathematics}
%D We hook this feature into the formula mechanism.
\setupformulas
[\c!method=\v!normal]
\appendtoks
\doifelse{\formulaparameter\c!method}\v!bold
{\chardef\boldfacemathmethod\plusone}
{\chardef\boldfacemathmethod\zerocount}%
\to \everysetupformulas
%D Of course this only works when bfmath fonts are set up (see example at
%D the top of this file) and bold math is enabled:
%D
%D \starttyping
%D \setupformulas
%D [method=bold]
%D \stoptyping
\protect \endinput
|