summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkxl/s-math-tweaks.mkxl
blob: 8a70d431fccbbfdb3867d6fb0e78f418d3dfd089 (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
%D \module
%D   [      file=s-math-atoms.mksl,
%D        version=2022.02.13,
%D          title=\CONTEXT\ Style File,
%D       subtitle=Show Math Atom Spacing,
%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.

%D This is just a quick and dirty overview.

\startmodule[math-tweaks]

\unprotect

\starttexdefinition protected showmathfonttweaks_text_accent #1
    \bTR
        \bTD[width=7em,align=flushleft,style=mono] #1 \eTD
        \bTD \m {\showglyphs \getvalue{#1}{i}  } \eTD
        \bTD \m {\showglyphs \getvalue{#1}{I}  } \eTD
        \bTD \m {\showglyphs \getvalue{#1}{x}  } \eTD
        \bTD \m {\showglyphs \getvalue{#1}{X}  } \eTD
        \bTD \m {\showglyphs \getvalue{#1}{xx} } \eTD
        \bTD \m {\showglyphs \getvalue{#1}{XX} } \eTD
    \eTR
\stoptexdefinition

\starttexdefinition protected showmathfonttweaks_wide_accent #1
    \bTR
        \bTD[width=7em,align=flushleft,style=mono] #1 \eTD
        \bTD \m {\showglyphs \getvalue{#1}{i}     } \eTD
        \bTD \m {\showglyphs \getvalue{#1}{I}     } \eTD
        \bTD \m {\showglyphs \getvalue{#1}{x}     } \eTD
        \bTD \m {\showglyphs \getvalue{#1}{X}     } \eTD
        \bTD \m {\showglyphs \getvalue{#1}{xx}    } \eTD
        \bTD \m {\showglyphs \getvalue{#1}{XX}    } \eTD
        \bTD \m {\showglyphs \getvalue{#1}{xxxxx} } \eTD
        \bTD \m {\showglyphs \getvalue{#1}{XXXXX} } \eTD
    \eTR
\stoptexdefinition

\starttexdefinition protected showmathfonttweaks_prime #1
    \bTR
        \bTD \type{#1} \eTD
        \bTD \m {\showglyphs #1} \eTD
    \eTR
\stoptexdefinition

\starttexdefinition protected showmathfonttweaks_bracer #1
    \bTR
        \bTD \type{#1} \eTD
        \bTD \m {\showglyphs \getvalue{#1}{x}     } \eTD
        \bTD \m {\showglyphs \getvalue{#1}{xxxxx} } \eTD
        \bTD \m {\showglyphs \getvalue{#1}{X}     } \eTD
        \bTD \m {\showglyphs \getvalue{#1}{XXXXX} } \eTD
    \eTR
\stoptexdefinition

\starttexdefinition protected showmathfonttweaks

    \startsubject[title=text accents]
        \startlinecorrection
            \bTABLE[align=middle,offset=1ex]
                \showmathfonttweaks_text_accent{grave}
                \showmathfonttweaks_text_accent{bar}
                \showmathfonttweaks_text_accent{acute}
                \showmathfonttweaks_text_accent{hat}
                \showmathfonttweaks_text_accent{check}
                \showmathfonttweaks_text_accent{breve}
                \showmathfonttweaks_text_accent{dot}
                \showmathfonttweaks_text_accent{ring}
                \showmathfonttweaks_text_accent{tilde}
                \showmathfonttweaks_text_accent{ddot}
                \showmathfonttweaks_text_accent{dddot}
            \eTABLE
        \stoplinecorrection
    \stopsubject

    \startsubject[title=wide accents]
        \startlinecorrection
            \bTABLE[align=middle,offset=1ex]
                \showmathfonttweaks_wide_accent{widegrave}
                \showmathfonttweaks_wide_accent{widebar}
                \showmathfonttweaks_wide_accent{wideacute}
                \showmathfonttweaks_wide_accent{widehat}
                \showmathfonttweaks_wide_accent{widecheck}
                \showmathfonttweaks_wide_accent{widebreve}
                \showmathfonttweaks_wide_accent{widedot}
                \showmathfonttweaks_wide_accent{widering}
                \showmathfonttweaks_wide_accent{widetilde}
                \showmathfonttweaks_wide_accent{wideddot}
                \showmathfonttweaks_wide_accent{widedddot}
            \eTABLE
        \stoplinecorrection
    \stopsubject

    \startsubject[title=primes]
        \startlinecorrection
            \bTABLE[align=flushleft,offset=1ex]
                \showmathfonttweaks_prime{x'}
                \showmathfonttweaks_prime{x''}
                \showmathfonttweaks_prime{x'''}
                \showmathfonttweaks_prime{X'}
                \showmathfonttweaks_prime{X''}
                \showmathfonttweaks_prime{X'''}
                \showmathfonttweaks_prime{x'}
                \showmathfonttweaks_prime{x'^2}
                \showmathfonttweaks_prime{x'_2}
                \showmathfonttweaks_prime{x'^2_2}
                \showmathfonttweaks_prime{x'}
                \showmathfonttweaks_prime{x^2'}
                \showmathfonttweaks_prime{x_2'}
                \showmathfonttweaks_prime{x^2_2'}
            \eTABLE
        \stoplinecorrection
    \stopsubject

    \startsubject[title=bracers]
        \startlinecorrection
            \bTABLE[align=flushleft,offset=1ex]
                \showmathfonttweaks_bracer{overbrace}
                \showmathfonttweaks_bracer{underbrace}
                \showmathfonttweaks_bracer{overbracket}
                \showmathfonttweaks_bracer{underbracket}
                \showmathfonttweaks_bracer{overparent}
                \showmathfonttweaks_bracer{underparent}
                \showmathfonttweaks_bracer{overbar}
                \showmathfonttweaks_bracer{underbar}
                \showmathfonttweaks_bracer{overline}
                \showmathfonttweaks_bracer{underline}
            \eTABLE
        \stoplinecorrection
    \stopsubject

    \startsubject[title=whatever]
        \startlinecorrection
            \bTABLE[align=flushleft,offset=1ex]
                \bTR
                    \bTD \m{\mfunction{máx}}\eTD
                \eTR
            \eTABLE
        \stoplinecorrection
    \stopsubject
\stoptexdefinition

\starttexdefinition protected showmathalphabettweaks_check_flush #1
    \dontleavehmode
    \hbox \bgroup
        \smallinfofont
        \setstrut
        \lower \dimexpr\dp\scratchbox+\ht\strutbox\relax \hbox to \wd\scratchbox\bgroup
            \hss
            \strut
            \hexnumber{#1}
            \hss
        \egroup
        \hskip-\wd\scratchbox
        \box\scratchbox
    \egroup
\stoptexdefinition

\starttexdefinition protected showmathalphabettweaks_check_scripts
    \subscript     1
    \superscript   2
    \subprescript  3
    \superprescript4
\stoptexdefinition

\starttexdefinition protected showmathalphabettweaks_check_hat #1
    \setbox\scratchbox\ruledhbox {
        \im {
            \resetmathattributes
            \widehat{\Uchar#1}
            \showmathalphabettweaks_check_scripts
       }
    }
    \showmathalphabettweaks_check_flush{#1}
\stoptexdefinition

\starttexdefinition protected showmathalphabettweaks_check_fences #1
    \setbox\scratchbox\ruledhbox {
        \im {
            \resetmathattributes
            \left(
                \Uchar#1
                \showmathalphabettweaks_check_scripts
            \right)
        }
    }
    \showmathalphabettweaks_check_flush{#1}
\stoptexdefinition

\starttexdefinition protected showmathalphabettweaks_check #1#2
   \startsubsubsubject[title=#1]
       \traverseblock {#1} {
         \begingroup
         \showglyphs
         \showfontitalics
         \showfontkerns
         #2{##1}%
         \endgroup
         \space\space
       }
       \removeunwantedspaces
   \stopsubsubsubject
\stoptexdefinition

\starttexdefinition protected showmathalphabettweaks_all #1
    \startsubsubject[title={Numbers}]
        \showmathalphabettweaks_check{digits normal}#1
        \showmathalphabettweaks_check{digits bold}#1
        \showmathalphabettweaks_check{digits sansserif normal}#1
        \showmathalphabettweaks_check{digits sansserif bold}#1
        \showmathalphabettweaks_check{digits monospace}#1
        \showmathalphabettweaks_check{digits doublestruck}#1
    \stopsubsubject
    \startsubsubject[title={Lowercase}]
        \showmathalphabettweaks_check{lowercase normal}#1
        \showmathalphabettweaks_check{lowercase italic}#1
        \showmathalphabettweaks_check{lowercase bold}#1
        \showmathalphabettweaks_check{lowercase bold italic}#1
        \showmathalphabettweaks_check{lowercase sansserif normal}#1
        \showmathalphabettweaks_check{lowercase sansserif italic}#1
        \showmathalphabettweaks_check{lowercase sansserif bold}#1
        \showmathalphabettweaks_check{lowercase sansserif bolditalic}#1
        \showmathalphabettweaks_check{lowercase monospace}#1
        \showmathalphabettweaks_check{lowercase fraktur}#1
        \showmathalphabettweaks_check{lowercase bold fraktur}#1
        \showmathalphabettweaks_check{lowercase script}#1
        \showmathalphabettweaks_check{lowercase bold script}#1
        \showmathalphabettweaks_check{lowercase doublestruck}#1
        \showmathalphabettweaks_check{lowercase greek normal}#1
        \showmathalphabettweaks_check{lowercase greek italic}#1
        \showmathalphabettweaks_check{lowercase greek bold}#1
        \showmathalphabettweaks_check{lowercase greek bold italic}#1
      % \showmathalphabettweaks_check{lowercase greek sansserif normal}#1
      % \showmathalphabettweaks_check{lowercase greek sansserif italic}#1
        \showmathalphabettweaks_check{lowercase greek sansserif bold}#1
        \showmathalphabettweaks_check{lowercase greek sansserif bolditalic}#1
    \stopsubsubject
    \startsubsubject[title={Uppercase}]
        \showmathalphabettweaks_check{uppercase normal}#1
        \showmathalphabettweaks_check{uppercase italic}#1
        \showmathalphabettweaks_check{uppercase bold}#1
        \showmathalphabettweaks_check{uppercase bolditalic}#1
        \showmathalphabettweaks_check{uppercase sansserif normal}#1
        \showmathalphabettweaks_check{uppercase sansserif italic}#1
        \showmathalphabettweaks_check{uppercase sansserif bold}#1
        \showmathalphabettweaks_check{uppercase sansserif bolditalic}#1
        \showmathalphabettweaks_check{uppercase monospace}#1
        \showmathalphabettweaks_check{uppercase fraktur}#1
        \showmathalphabettweaks_check{uppercase bold fraktur}#1
        \showmathalphabettweaks_check{uppercase script}#1
        \showmathalphabettweaks_check{uppercase bold script}#1
        \showmathalphabettweaks_check{uppercase doublestruck}#1
        \showmathalphabettweaks_check{uppercase greek normal}#1
        \showmathalphabettweaks_check{uppercase greek italic}#1
        \showmathalphabettweaks_check{uppercase greek bold}#1
        \showmathalphabettweaks_check{uppercase greek bolditalic}#1
        \showmathalphabettweaks_check{uppercase greek sansserif bold}#1
        \showmathalphabettweaks_check{uppercase greek sansserif bolditalic}#1
    \stopsubsubject
\stoptexdefinition

\starttexdefinition protected showmathaccenttweaks
    \showmathalphabettweaks_all\showmathalphabettweaks_check_hat
\stoptexdefinition

\starttexdefinition protected showmathfencetweaks
    \showmathalphabettweaks_all\showmathalphabettweaks_check_fences
\stoptexdefinition

\starttexdefinition protected showmathmiddletweaks
    \dostepwiserecurse {5} {75} {1} {
        $\left\{
         \mathatom class \mathconstructcode \bgroup \vcenter \bgroup \hbox \bgroup
          \blackrule
            [\c!height=\dimexpr##1pt/2\relax,
             \c!depth=\dimexpr##1pt/2\relax,
             \c!width=\emwidth,
             \c!color=darkblue]%
        \egroup \egroup \egroup
        \middle|
      % \begingroup\darkblue\scriptscriptstyle\mathtt{##1}\endgroup
        \right)$
        \space
    }
    \removeunwantedspaces
\stoptexdefinition

\protect

\stopmodule

\continueifinputfile{s-math-tweaks.mkxl}

\setuplayout
  [tight]

\setuphead
  [chapter]
  [style=\bfd]

\setuphead
  [section]
  [style=\bfc]

\setuphead
  [subsection]
  [style=\bfb]

\setuphead
  [subsubsection]
  [before=\blank,
   style=\bfa]

% \enabletrackers[math.tweaks]

\starttext

%     \definefontfeature[mathextra][compose=yes]

    \doifelse {\getdocumentargument{bodyfont}} {} {

%         \setupbodyfont[cambria,10pt]   \starttitle[title=\fontclass] \showmathfonttweaks \stoptitle
%          \setupbodyfont[modern]         \starttitle[title=\fontclass] \showmathfonttweaks \stoptitle
%         \setupbodyfont[pagella]        \starttitle[title=\fontclass] \showmathfonttweaks \stoptitle
%         \setupbodyfont[termes]         \starttitle[title=\fontclass] \showmathfonttweaks \stoptitle
%         \setupbodyfont[bonum]          \starttitle[title=\fontclass] \showmathfonttweaks \stoptitle
%         \setupbodyfont[schola]         \starttitle[title=\fontclass] \showmathfonttweaks \stoptitle
%         \setupbodyfont[lucidaot,10pt]  \starttitle[title=\fontclass] \showmathfonttweaks \stoptitle
%         \setupbodyfont[ebgaramond]     \starttitle[title=\fontclass] \showmathfonttweaks \stoptitle
%         \setupbodyfont[stixtwo]        \starttitle[title=\fontclass] \showmathfonttweaks \stoptitle

%         \setupbodyfont[bonum]          \starttitle[title=\fontclass] \showmathaccenttweaks \stoptitle

%         \setupbodyfont[bonum]          \starttitle[title=\fontclass] \showmathfencetweaks \stoptitle
        \setupbodyfont[bonum]          \starttitle[title=\fontclass] \showmathmiddletweaks \stoptitle
%         \setupbodyfont[modern]          \starttitle[title=\fontclass] \showmathfencetweaks \stoptitle

    } {

        \normalexpanded{\setupbodyfont[\getdocumentargument{bodyfont},12pt]}
        \showmathfonttweaks
        \showmathaccenttweaks
        \showmathfencetweaks
        \showmathmiddletweaks
    }

\stoptext