summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/supp-mat.mkxl
blob: c3c69593aff4bbb3601e53b37f686f95d6bc463f (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
%D \module
%D   [       file=supp-mat,
%D        version=1998.09.10,
%D          title=\CONTEXT\ Support Macros,
%D       subtitle=Math,
%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 For practical reasons, I decided to move some math things to a support module.
%D There is nothing spectacular here. It may move back to math-ini.

\writestatus{loading}{ConTeXt Support Macros / Math}

\unprotect

%D \macros
%D   {mathematics, math, nomathematics, startmathmode}
%D
%D The \type {$} can be both an begin and end math character. This can lead to
%D confusing and errorprone situations when macros insert \type {$}. When for
%D instance we have defined:
%D
%D \starttyping
%D \def\MyPlus{$\,+\,$}
%D \stoptyping
%D
%D the sequence \type{$x^2 \MyPlus y^2 = r^2$} will expand to:
%D
%D \starttyping
%D $x^2 $\,+\,$ y^2 = r^2$
%D \stoptyping
%D
%D Here the \type {\,} are given outside math mode and \TEX\ will definitely
%D complain about this. A more save definition would have been:
%D
%D \starttyping
%D \def\MyPlus{\mathematics{\,+\,}}
%D \stoptyping
%D
%D Which is implemented (in \type{syst-ini.mkiv}) as:

% \permanent\protected\def\Ucheckedstartdisplaymath
%   {\ifinner
%      \ifhmode
%        \normalUstartmath
%        \let\Ucheckedstopdisplaymath\normalUstopmath
%      \else
%        \normalUstartdisplaymath
%        \let\Ucheckedstopdisplaymath\normalUstopdisplaymath
%      \fi
%    \else
%      \normalUstartdisplaymath
%      \let\Ucheckedstopdisplaymath\normalUstopdisplaymath
%    \fi}
%
% \aliased\let\Ucheckedstopdisplaymath\relax

% \let\normalsuper\Usuperscript % obsolete
% \let\normalsuber\Usubscript   % obsolete

\aliased\let\startimath\Ustartmath
\aliased\let\stopimath \Ustopmath
\aliased\let\startdmath\Ustartdisplaymath  % \Ucheckedstartdisplaymath
\aliased\let\stopdmath \Ustopdisplaymath   % \Ucheckedstopdisplaymath

\permanent\protected\def\mathematics#1{\relax         \ifmmode#1\else\normalstartimath#1\normalstopimath\fi}
%permanent\protected\def\displaymath#1{\noindent      \ifmmode#1\else\normalstartdmath#1\normalstopdmath\fi}
%permanent\protected\def\inlinemath #1{\dontleavehmode\ifmmode#1\else\normalstartimath#1\normalstopimath\fi}
\permanent\protected\def\textmath   #1{\dontleavehmode\ifmmode#1\else\begingroup\everymath\emptytoks\normalstartimath#1\normalstopimath\endgroup\fi} % \mathsurround\zeropoint

\aliased\let\stopmathmode\relax

\permanent\protected\def\startmathmode % nested variant
  {\relax\ifmmode
     \begingroup
     \enforced\let\stopmathmode\endgroup
   \else
     \normalstartimath
     \enforced\let\stopmathmode\normalstopimath
   \fi}

\permanent\protected\def\nomathematics#1%
  {\relax\ifmmode\hbox{#1}\else#1\fi}

\aliased\let\m   \mathematics % \mathematics will be overloaded later
\aliased\let\math\mathematics % \mathematics will be overloaded later

%D \macros
%D   {displaymathematics,inlinemathematics,automathematics}
%D
%D We no longer support native displaymath, which is no big deal because already
%D for many years we abandoned it. We therefore also default differently now. We
%D signal \LUAMETATEX\ that the double dollar mode actually has to be inline
%D display math anyway.

\ifdefined\strc_formulas_start_formula \else
   \def\strc_formulas_start_formula{\normalstartdmath}
   \def\strc_formulas_stop_formula {\normalstopdmath }
\fi

\permanent\protected\def\displaymathematics#1{\relax\ifmmode#1\else\strc_formulas_start_formula{}#1\strc_formulas_stop_formula\fi}
\permanent\protected\def\inlinemathematics   {\dontleavehmode\mathematics}
%permanent\protected\def\automathematics     {\relax\ifhmode\expandafter\inlinemathematics\else\expandafter\displaymathematics\fi}

\aliased\let\displaymath\displaymathematics % we no longer support native displaymath
\aliased\let\inlinemath \inlinemathematics  % we no longer support native displaymath

% better, esp when used in bTABLE ... eTABLE

\permanent\protected\def\automathematics
  {\relax
   \ifhmode
     \expandafter\inlinemathematics
   \orelse\ifintable
     \expandafter\inlinemathematics
   \else
     \expandafter\displaymathematics
   \fi}

%D \macros
%D   {dimension, nodimension}
%D
%D The next few macros are used for typesetting dimensions in such a way that
%D spacing is acceptable. I won't spend much words on these macros, because they
%D will be overloaded in the units module.
%D
%D REPLACED (keep commented):

% \newsignal\dimensionsignal
%
% \mutable\def\dimensiontypeface  {\tf}
% \mutable\def\dimensionhalfspace {\,}
%
% \aliased\let\dodimensionsignal\relax
%
% \permanent\protected\def\dimension#1%
%   {\pushmacro\dodimensionsignal
%    \enforced\gdef\dodimensionsignal{\kern\dimensionsignal}%
%    \ifzeropt\lastskip
%      \ifzeropt\lastkern
%        \ifmmode
%          \mathematics{\dimensionhalfspace\dimensionhalfspace\dimensiontypeface#1}%
%        \else
%          \mathematics{\dimensiontypeface#1}%
%        \fi
%      \orelse\ifdim\lastkern=\dimensionsignal
%        \mathematics{\dimensionhalfspace\dimensiontypeface#1}%
%      \else
%        \unkern\mathematics{\dimensionhalfspace\dimensionhalfspace\dimensiontypeface#1}%
%      \fi
%    \else
%      \unskip\mathematics{\dimensionhalfspace\dimensionhalfspace\dimensiontypeface#1}%
%    \fi
%    \dodimensionsignal
%    \popmacro\dodimensionsignal}
%
% \permanent\protected\def\nodimension#1%
%   {\unskip#1\enforced\glet\dodimensionsignal\relax}

% experiment, not yet to be used

% \protected\def\displaybreak
%   {\ifhmode
%      \removeunwantedspaces
%      \ifcase\raggedstatus\hfill\fi
%      \strut\penalty-9999 % \break fails on case (3)
%    \fi}
%
% \def\startdisplay{\displaybreak\ignorespaces\startpacked}
% \def\stopdisplay {\stoppacked\displaybreak\ignorespaces}

\aliased\let\superscript     \Usuperscript
\aliased\let\subscript       \Usubscript
\aliased\let\primescript     \Uprimescript
\aliased\let\nosuperscript   \Unosuperscript
\aliased\let\nosubscript     \Unosubscript
\aliased\let\superprescript  \Usuperprescript
\aliased\let\subprescript    \Usubprescript
\aliased\let\nosuperprescript\Unosuperprescript
\aliased\let\nosubsprecript  \Unosubprescript

\protect \endinput