supp-mat.mkxl /size: 5859 b    last modification: 2024-01-16 09:03
1%D \module
2%D   [       file=supp-mat,
3%D        version=1998.09.10,
4%D          title=\CONTEXT\ Support Macros,
5%D       subtitle=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%D For practical reasons, I decided to move some math things to a support module.
15%D There is nothing spectacular here. It may move back to math-ini.
16
17\writestatus{loading}{ConTeXt Support Macros / Math}
18
19\unprotect
20
21%D \macros
22%D   {mathematics, math, nomathematics, startmathmode}
23%D
24%D The \type {$} can be both an begin and end math character. This can lead to
25%D confusing and errorprone situations when macros insert \type {$}. When for
26%D instance we have defined:
27%D
28%D \starttyping
29%D \def\MyPlus{$\,+\,$}
30%D \stoptyping
31%D
32%D the sequence \type{$x^2 \MyPlus y^2 = r^2$} will expand to:
33%D
34%D \starttyping
35%D $x^2 $\,+\,$ y^2 = r^2$
36%D \stoptyping
37%D
38%D Here the \type {\,} are given outside math mode and \TEX\ will definitely
39%D complain about this. A more save definition would have been:
40%D
41%D \starttyping
42%D \def\MyPlus{\mathematics{\,+\,}}
43%D \stoptyping
44%D
45%D Which is implemented (in \type{syst-ini.mkiv}) as:
46
47% \permanent\protected\def\Ucheckedstartdisplaymath
48%   {\ifinner
49%      \ifhmode
50%        \normalUstartmath
51%        \let\Ucheckedstopdisplaymath\normalUstopmath
52%      \else
53%        \normalUstartdisplaymath
54%        \let\Ucheckedstopdisplaymath\normalUstopdisplaymath
55%      \fi
56%    \else
57%      \normalUstartdisplaymath
58%      \let\Ucheckedstopdisplaymath\normalUstopdisplaymath
59%    \fi}
60%
61% \aliased\let\Ucheckedstopdisplaymath\relax
62
63\aliased\let\startimath\Ustartmath
64\aliased\let\stopimath \Ustopmath
65\aliased\let\startdmath\Ustartdisplaymath  % \Ucheckedstartdisplaymath
66\aliased\let\stopdmath \Ustopdisplaymath   % \Ucheckedstopdisplaymath
67
68\permanent\protected\def\mathematics#1{\relax         \ifmmode#1\else\normalstartimath#1\normalstopimath\fi}
69%permanent\protected\def\displaymath#1{\noindent      \ifmmode#1\else\normalstartdmath#1\normalstopdmath\fi}
70%permanent\protected\def\inlinemath #1{\dontleavehmode\ifmmode#1\else\normalstartimath#1\normalstopimath\fi}
71\permanent\protected\def\textmath   #1{\dontleavehmode\ifmmode#1\else\begingroup\everymath\emptytoks\normalstartimath#1\normalstopimath\endgroup\fi} % \mathsurround\zeropoint
72
73\aliased\let\stopmathmode\relax
74
75\permanent\protected\def\startmathmode % nested variant
76  {\relax\ifmmode
77     \begingroup
78     \enforced\let\stopmathmode\endgroup
79   \else
80     \normalstartimath
81     \enforced\let\stopmathmode\normalstopimath
82   \fi}
83
84\permanent\protected\def\nomathematics#1%
85  {\relax\ifmmode\hbox{#1}\else#1\fi}
86
87\aliased\let\m   \mathematics % \mathematics will be overloaded later
88\aliased\let\math\mathematics % \mathematics will be overloaded later
89
90%D \macros
91%D   {displaymathematics,inlinemathematics,automathematics}
92%D
93%D We no longer support native displaymath, which is no big deal because already
94%D for many years we abandoned it. We therefore also default differently now. We
95%D signal \LUAMETATEX\ that the double dollar mode actually has to be inline
96%D display math anyway.
97
98\ifdefined\strc_formulas_start_formula \else
99   \def\strc_formulas_start_formula{\normalstartdmath}
100   \def\strc_formulas_stop_formula {\normalstopdmath }
101\fi
102
103\permanent\protected\def\displaymathematics#1{\relax\ifmmode#1\else\strc_formulas_start_formula{}#1\strc_formulas_stop_formula\fi}
104\permanent\protected\def\inlinemathematics   {\dontleavehmode\mathematics}
105%permanent\protected\def\automathematics     {\relax\ifhmode\expandafter\inlinemathematics\else\expandafter\displaymathematics\fi}
106
107\aliased\let\displaymath\displaymathematics % we no longer support native displaymath
108\aliased\let\inlinemath \inlinemathematics  % we no longer support native displaymath
109
110% better, esp when used in bTABLE ... eTABLE
111
112\permanent\protected\def\automathematics
113  {\relax
114   \ifhmode
115     \expandafter\inlinemathematics
116   \orelse\ifintable
117     \expandafter\inlinemathematics
118   \else
119     \expandafter\displaymathematics
120   \fi}
121
122%D \macros
123%D   {dimension, nodimension}
124%D
125%D The next few macros are used for typesetting dimensions in such a way that
126%D spacing is acceptable. I won't spend much words on these macros, because they
127%D will be overloaded in the units module.
128%D
129%D REPLACED (keep commented):
130
131% \newsignal\dimensionsignal
132%
133% \mutable\def\dimensiontypeface  {\tf}
134% \mutable\def\dimensionhalfspace {\,}
135%
136% \aliased\let\dodimensionsignal\relax
137%
138% \permanent\protected\def\dimension#1%
139%   {\pushmacro\dodimensionsignal
140%    \enforced\gdef\dodimensionsignal{\kern\dimensionsignal}%
141%    \ifzeropt\lastskip
142%      \ifzeropt\lastkern
143%        \ifmmode
144%          \mathematics{\dimensionhalfspace\dimensionhalfspace\dimensiontypeface#1}%
145%        \else
146%          \mathematics{\dimensiontypeface#1}%
147%        \fi
148%      \orelse\ifdim\lastkern=\dimensionsignal
149%        \mathematics{\dimensionhalfspace\dimensiontypeface#1}%
150%      \else
151%        \unkern\mathematics{\dimensionhalfspace\dimensionhalfspace\dimensiontypeface#1}%
152%      \fi
153%    \else
154%      \unskip\mathematics{\dimensionhalfspace\dimensionhalfspace\dimensiontypeface#1}%
155%    \fi
156%    \dodimensionsignal
157%    \popmacro\dodimensionsignal}
158%
159% \permanent\protected\def\nodimension#1%
160%   {\unskip#1\enforced\glet\dodimensionsignal\relax}
161
162% experiment, not yet to be used
163
164% \protected\def\displaybreak
165%   {\ifhmode
166%      \removeunwantedspaces
167%      \ifcase\raggedstatus\hfill\fi
168%      \strut\penalty-9999 % \break fails on case (3)
169%    \fi}
170%
171% \def\startdisplay{\displaybreak\ignorespaces\startpacked}
172% \def\stopdisplay {\stoppacked\displaybreak\ignorespaces}
173
174\protect \endinput
175