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
|
%D \module
%D [ file=math-acc,
%D version=2013.07.31,
%D title=\CONTEXT\ Math Macros,
%D subtitle=Accents,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%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 Math Macros / Accents}
% There are probably errors ... too distracted by amazing (piano) music videos running
% on top of scite ... so: experimental code.
\unprotect
% This module permits overloading of accents so that we can do fancy things. The
% implementation is similar to stackers. By default accenst are defined in a simple
% way. Contrary to extensibles accents cannot grow indefinitely. Alas the
% implementation of accents is different too, in the sense that they are
% prepositioned i.e. are already raised. (In my opinion for no real reason as they
% need to adapt anyway).
%
% $ \ruledhbox{$H$} \hat{H} \ruledhbox{$\widehat{H}$} \widehat{H} $
%
% One alternative is:
%
% \definemathoverextensible [top] [hoed] ["FE302]
% \definemathoverextensible [top] [slang] ["FE303]
%
% $ \hoed{H} \ruledhbox{$\hoed{H}$} \ruledhbox{$\hoed{\tf H}$} \slang{H} $
%
% But that nills the italic correction (and I'm in nood to mess with that again).
%
% \definemathaccents [myaccents] [color=darkred]
% \definemathtopaccent [myaccents] [mywidehat] ["0302]
%
% $ \hat{H} \widehat{H} \mywidehat{H} $
% A first variant (kept for educational purposed):
%
% \installcorenamespace{mathaccents}
%
% \installcommandhandler \??mathaccents {mathaccent} \??mathaccents
%
% \let\setupmathaccents\setupmathaccent
%
% \setupmathaccents
% [\c!top=,
% \c!bottom=,
% \c!mathstyle=,
% \c!color=,
% \c!command=\v!yes]
%
% \appendtoks
% \edef\p_top_bottom{\namedmathaccentparameter\currentmathaccent\c!top\namedmathaccentparameter\currentmathaccent\c!bottom}%
% \ifx\p_top_bottom\empty\else
% \edef\p_command{\mathaccentparameter\c!command}%
% \ifx\p_command\v!yes
% \setuevalue\currentmathaccent{\math_accent{\currentmathaccent}}%
% \fi
% \fi
% \to \everydefinemathaccent
%
% \def\math_accented_color_do_push{\pushcolor[\p_math_accent_color]}
% \let\math_accented_color_do_pop \popcolor
%
% \unexpanded\def\math_accent#1#2%
% {\begingroup
% \edef\currentmathaccent{#1}%
% \edef\p_math_accent_top {\mathaccentparameter\c!top}%
% \edef\p_math_accent_bottom{\mathaccentparameter\c!bottom}%
% \edef\p_math_accent_color {\mathaccentparameter\c!color}%
% \startusemathstyleparameter\mathaccentparameter
% \ifx\p_math_accented_color\empty
% \let\math_accented_color_do_pop\donothing
% \else
% \let\math_accented_color_do_pop\popcolor
% \math_accented_color_do_push
% \fi
% \ifx\p_math_accent_top\empty
% \ifx\p_math_accent_bottom\empty
% \else
% \Umathaccent bottom \fam\zerocount\p_math_accent_bottom
% \fi
% \else
% \ifx\p_math_accent_bottom\empty
% \Umathaccent \fam\zerocount\p_math_accent_top
% \else
% \Umathaccent both \fam\zerocount\p_math_accent_top
% \fam\zerocount\p_math_accent_bottom
% \fi
% \fi
% {\popcolor#2}%
% \stopusemathstyleparameter
% \endgroup}
%
% \definemathaccent [myaccents] [\c!color=red]
% \definemathaccent [mywidehat] [myaccents] [\c!top="0302]
\installcorenamespace{mathaccents}
\installcommandhandler \??mathaccents {mathaccents} \??mathaccents
\setupmathaccents
[\c!top=,
\c!bottom=,
\c!mathstyle=,
\c!color=,
\c!command=\v!yes]
\definemathaccents
[\v!both]
\definemathaccents
[\v!top]
[\v!both]
\definemathaccents
[\v!bottom]
[\v!both]
\unexpanded\def\definemathtopaccent {\dotripleempty \math_accents_define_top }
\unexpanded\def\definemathbottomaccent{\dotripleempty \math_accents_define_bottom}
\unexpanded\def\definemathdoubleaccent{\doquadrupleempty\math_accents_define_double}
\def\math_accents_define_top[#1][#2][#3]% class name top
{\ifthirdargument
\setuevalue{#2}{\math_accents_make_double {#1}\plusone{\number#3}\zerocount}%
\else
\setuevalue{#1}{\math_accents_make_double\noexpand\currentmathaccents\plusone{\number#2}\zerocount}%
\fi}
\def\math_accents_define_bottom[#1][#2][#3]% class name bottom
{\ifthirdargument
\setuevalue{#2}{\math_accents_make_double {#1}\plustwo\zerocount{\number#3}}%
\else
\setuevalue{#1}{\math_accents_make_double\noexpand\currentmathaccents\plustwo\zerocount{\number#2}}%
\fi}
\def\math_accents_define_double[#1][#2][#3][#4]% class name top bottom
{\iffourthargument
\setuevalue{#2}{\math_accents_make_double {#1}\plusthree{\number#3}{\number#4}}%
\else
\setuevalue{#1}{\math_accents_make_double\noexpand\currentmathaccents\plusthree{\number#2}{\number#3}}%
\fi}
\def\math_accents_color_push_yes
{\pushcolor[\p_math_accent_color]%
\let\math_accents_color_pop\popcolor}
\def\math_accents_color_push_nop
{\let\math_accents_color_pop\donothing}
\unexpanded\def\math_accents_make_double#class#kind#top#bottom#content%
{\begingroup
\edef\currentmathaccents {#class}%
\edef\p_math_accent_color{\mathaccentsparameter\c!color}%
\startusemathstyleparameter\mathaccentsparameter
\ifx\p_math_accent_color\empty
\math_accents_color_push_nop
\else
\math_accents_color_push_yes
\fi
\ifcase#kind\or
\Umathaccent \fam\zerocount#top
\or
\Umathaccent bottom \fam\zerocount#bottom
\or
\Umathaccent both \fam\zerocount#top
\fam\zerocount#bottom
\fi
{\math_accents_color_pop#content}%
\stopusemathstyleparameter
\endgroup}
\protect \endinput
|