math-toy.mkxl /size: 1723 b    last modification: 2024-01-16 09:02
1%D \module
2%D   [       file=math-toy,
3%D        version=2020.08.31,
4%D          title=\CONTEXT\ Math Macros,
5%D       subtitle=Toy math,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\writestatus{loading}{ConTeXt Math Macros / Toy}
15
16\unprotect
17
18%D Just an example:
19%D
20%D \starttyping
21%D \enabletrackers[math.toysymbol]
22%D
23%D \definemathtoysymbol[Plus] [binary]  [+]
24%D \definemathtoysymbol[Minus][binary]  [-]
25%D \definemathtoysymbol[Equal][relation][=]
26%D
27%D $\dorecurse{199}{x_{#1} \ifodd#1\relax\Plus\else\Minus\fi} x_{200} \Equal n$ \blank
28%D \stoptyping
29
30\permanent\tolerant\protected\def\definemathtoysymbol[#1]#*[#2]#*[#3]%
31  {\ifarguments\or\or\or
32     \protected\instance\edefcsname#1\endcsname{\math_toy_define_symbol_indeed{\mathcodechecked{#2}}{#3}}%
33   \fi}
34
35\protected\def\math_toy_define_symbol_traced#1#2%
36  {\normalexpanded{\discretionary class #1 %
37     {$\givenmathstyle\the\mathstyle \darkred   #2$}%
38     {$\givenmathstyle\the\mathstyle \darkblue  #2$}%
39     {$\givenmathstyle\the\mathstyle \darkgreen #2$}}}
40
41\protected\def\math_toy_define_symbol_normal#1#2%
42  {\normalexpanded{\discretionary class #1 %
43     {$\givenmathstyle\the\mathstyle #2$}%
44     {$\givenmathstyle\the\mathstyle #2$}%
45     {$\givenmathstyle\the\mathstyle #2$}}}
46
47\installtextracker
48  {math.toysymbol}
49  {\let\math_toy_define_symbol_indeed\math_toy_define_symbol_traced}
50  {\let\math_toy_define_symbol_indeed\math_toy_define_symbol_normal}
51
52\let\math_toy_define_symbol_indeed\math_toy_define_symbol_normal
53
54\protect
55