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
|
% \section{\DTXCURR --- Epilogue}
%
% \begin{macrocode}
%<*package&(XE|LU)>
% \end{macrocode}
%
% Lots of little things to tidy up.
%
% \subsection{Resolving Greek symbol name control sequences}
%
% \begin{macro}{\@@_resolve_greek:}
% This macro defines \cmd\Alpha\dots\cmd\omega\ as their corresponding
% Unicode (mathematical italic) character. Remember that the mapping
% to upright or italic happens with the mathcode definitions, whereas these macros
% just stand for the literal Unicode characters.
% \begin{macrocode}
\AtBeginDocument{\@@_resolve_greek:}
\cs_new:Npn \@@_resolve_greek:
{
\clist_map_inline:nn
{
Alpha,Beta,Gamma,Delta,Epsilon,Zeta,Eta,Theta,Iota,Kappa,Lambda,
alpha,beta,gamma,delta,epsilon,zeta,eta,theta,iota,kappa,lambda,
Mu,Nu,Xi,Omicron,Pi,Rho,Sigma,Tau,Upsilon,Phi,Chi,Psi,Omega,
mu,nu,xi,omicron,pi,rho,sigma,tau,upsilon,phi,chi,psi,omega,
varTheta,varsigma,vartheta,varkappa,varrho,varpi,varepsilon,varphi
}
{
\tl_set:cx {##1} { \exp_not:c { mit ##1 } }
\tl_set:cx {up ##1} { \exp_not:N \symup \exp_not:c { ##1 } }
\tl_set:cx {it ##1} { \exp_not:N \symit \exp_not:c { ##1 } }
}
}
% \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Unicode radicals}
%
% Make sure \cs{Uroot} is defined in the case where the \LaTeX{}
% kernel doesn't make it available with its native name.
% \begin{macrocode}
%<*LU>
\cs_if_exist:NF \Uroot
{ \cs_new_eq:NN \Uroot \luatexUroot }
%</LU>
% \end{macrocode}
%
% \begin{macrocode}
\AtBeginDocument{\@@_redefine_radical:}
\cs_new:Nn \@@_redefine_radical:
%<*XE>
{
\@ifpackageloaded { amsmath } { }
{
% \end{macrocode}
% \begin{macro}{\r@@t}
% \darg{A mathstyle (for \cmd\mathpalette)}
% \darg{Leading superscript for the sqrt sign}
% A re-implementation of \LaTeX's hard-coded n-root sign using the appropriate \cmd\fontdimen s.
% \begin{macrocode}
\cs_set_nopar:Npn \r@@@@t ##1 ##2
{
\hbox_set:Nn \l_tmpa_box
{
\c_math_toggle_token
\m@th
##1
\sqrtsign { ##2 }
\c_math_toggle_token
}
\@@_mathstyle_scale:Nnn ##1 { \kern }
{ \fontdimen 63 \l_@@_font }
\box_move_up:nn
{
(\box_ht:N \l_tmpa_box - \box_dp:N \l_tmpa_box)
* \number \fontdimen 65 \l_@@_font / 100
}
{ \box_use:N \rootbox }
\@@_mathstyle_scale:Nnn ##1 { \kern }
{ \fontdimen 64 \l_@@_font }
\box_use_clear:N \l_tmpa_box
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
}
}
%</XE>
%<*LU>
{
\@ifpackageloaded { amsmath } { }
{
% \end{macrocode}
% \begin{macro}{\root}
% Redefine this macro for \LuaTeX, which provides us a nice primitive to use.
% \begin{macrocode}
\cs_set:Npn \root ##1 \of ##2
{
\Uroot \l_@@_radical_sqrt_tl { ##1 } { ##2 }
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
}
}
%</LU>
% \end{macrocode}
%
% \subsubsection{Active fractions}
% Active fractions can be setup independently of any maths font definition;
% all it requires is a mapping from the Unicode input chars to the relevant
% \LaTeX\ fraction declaration.
%
% \begin{macrocode}
\cs_new:Npn \@@_define_active_frac:Nw #1 #2/#3
{
\char_set_catcode_active:N #1
\@@_char_gmake_mathactive:N #1
\tl_rescan:nn
{
\catcode`\_=11\relax
\catcode`\:=11\relax
}
{
\cs_gset:Npx #1
{
\bool_if:NTF \l_@@_smallfrac_bool {\exp_not:N\tfrac} {\exp_not:N\frac}
{#2} {#3}
}
}
}
% \end{macrocode}
% These are redefined for each math font selection in case the |active-frac|
% feature changes.
% \begin{macrocode}
\cs_new:Npn \@@_setup_active_frac:
{
\group_begin:
\@@_define_active_frac:Nw ^^^^2189 0/3
\@@_define_active_frac:Nw ^^^^2152 1/{10}
\@@_define_active_frac:Nw ^^^^2151 1/9
\@@_define_active_frac:Nw ^^^^215b 1/8
\@@_define_active_frac:Nw ^^^^2150 1/7
\@@_define_active_frac:Nw ^^^^2159 1/6
\@@_define_active_frac:Nw ^^^^2155 1/5
\@@_define_active_frac:Nw ^^^^00bc 1/4
\@@_define_active_frac:Nw ^^^^2153 1/3
\@@_define_active_frac:Nw ^^^^215c 3/8
\@@_define_active_frac:Nw ^^^^2156 2/5
\@@_define_active_frac:Nw ^^^^00bd 1/2
\@@_define_active_frac:Nw ^^^^2157 3/5
\@@_define_active_frac:Nw ^^^^215d 5/8
\@@_define_active_frac:Nw ^^^^2154 2/3
\@@_define_active_frac:Nw ^^^^00be 3/4
\@@_define_active_frac:Nw ^^^^2158 4/5
\@@_define_active_frac:Nw ^^^^215a 5/6
\@@_define_active_frac:Nw ^^^^215e 7/8
\group_end:
}
\@@_setup_active_frac:
% \end{macrocode}
%
% \subsection{Synonyms and all the rest}
%
% These are symbols with multiple names. Eventually to be taken care of
% automatically by the maths characters database.
% \begin{macrocode}
\protected\def\to{\rightarrow}
\protected\def\le{\leq}
\protected\def\ge{\geq}
\protected\def\neq{\ne}
\protected\def\triangle{\mathord{\bigtriangleup}}
\protected\def\bigcirc{\mdlgwhtcircle}
\protected\def\circ{\vysmwhtcircle}
\protected\def\bullet{\smblkcircle}
\protected\def\mathyen{\yen}
\protected\def\mathsterling{\sterling}
\protected\def\diamond{\smwhtdiamond}
\protected\def\emptyset{\varnothing}
\protected\def\hbar{\hslash}
\protected\def\land{\wedge}
\protected\def\lor{\vee}
\protected\def\owns{\ni}
\protected\def\gets{\leftarrow}
\protected\def\mathring{\ocirc}
\protected\def\lnot{\neg}
\protected\def\longdivision{\longdivisionsign}
% \end{macrocode}
% These are somewhat odd: (and their usual Unicode uprightness does not match their amssymb glyphs)
% \begin{macrocode}
\protected\def\backepsilon{\upbackepsilon}
\protected\def\eth{\matheth}
% \end{macrocode}
% These are names that are `frozen' in HTML but have dumb names:
% \begin{macrocode}
\protected\def\dbkarow {\dbkarrow}
\protected\def\drbkarow{\drbkarrow}
\protected\def\hksearow{\hksearrow}
\protected\def\hkswarow{\hkswarrow}
% \end{macrocode}
%
% Due to the magic of OpenType math, big operators are automatically
% enlarged when necessary. Since there isn't a separate unicode glyph for
% `small integral', I'm not sure if there is a better way to do this:
% \begin{macrocode}
\protected\def\smallint{\mathop{\textstyle\int}\limits}
% \end{macrocode}
%
% \begin{macro}{\underbar}
% \begin{macrocode}
\cs_set_eq:NN \latexe_underbar:n \underbar
\renewcommand\underbar
{
\mode_if_math:TF \mathunderbar \latexe_underbar:n
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\colon}
% Define \cs{colon} as a mathpunct `|:|'.
% This is wrong: it should be \unichar{003A} {colon} instead!
% We hope no-one will notice.
% \begin{macrocode}
\@ifpackageloaded{amsmath}
{
% define their own colon, perhaps I should just steal it. (It does look much better.)
}
{
\cs_set_protected:Npn \colon
{
\bool_if:NTF \g_@@_literal_colon_bool {:} { \mathpunct{:} }
}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\digamma}
% \begin{macro}{\Digamma}
% I might end up just changing these in the table.
% \begin{macrocode}
\protected\def\digamma{\updigamma}
\protected\def\Digamma{\upDigamma}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \paragraph{Symbols}
% \begin{macrocode}
\cs_set_protected:Npn \| {\Vert}
% \end{macrocode}
% \cs{mathinner} items:
% \begin{macrocode}
\cs_set_protected:Npn \mathellipsis {\mathinner{\unicodeellipsis}}
\cs_set_protected:Npn \cdots {\mathinner{\unicodecdots}}
% \end{macrocode}
%
% \begin{macrocode}
\cs_set_eq:NN \@@_text_slash: \slash
\cs_set_protected:Npn \slash
{
\mode_if_math:TF {\mathslash} {\@@_text_slash:}
}
% \end{macrocode}
%
% \subsubsection{\cs{not}}
% \label{sec:negations}
%
% The situation of \cs{not} symbol is currently messy, in Unicode it is defined
% as a combining mark so naturally it should be treated as a math accent,
% however neither Lua\TeX\ nor \XeTeX\ correctly place it as it needs special
% treatment compared to other accents, furthermore a math accent changes the
% spacing of its nucleus, so \cs{not=} will be spaced as an ordinary not
% relational symbol, which is undesired.
%
% Here modify \cs{not} to a macro that tries to use predefined negated symbols,
% which would give better results in most cases, until there is more robust
% solution in the engines.
%
% This code is based on an answer to a TeX -- Stack Exchange question by Enrico
% Gregorio\footnote{\url{http://tex.stackexchange.com/a/47260/729}}.
%
% \begin{macrocode}
\cs_new:Npn \@@_newnot:N #1
{
\tl_set:Nx \l_not_token_name_tl { \token_to_str:N #1 }
\exp_args:Nx \tl_if_empty:nF { \tl_tail:V \l_not_token_name_tl }
{
\tl_set:Nx \l_not_token_name_tl { \tl_tail:V \l_not_token_name_tl }
}
\cs_if_exist:cTF { n \l_not_token_name_tl }
{
\use:c { n \l_not_token_name_tl }
}
{
\cs_if_exist:cTF { not \l_not_token_name_tl }
{
\use:c { not \l_not_token_name_tl }
}
{
\@@_oldnot: #1
}
}
}
% \end{macrocode}
% \begin{macrocode}
\cs_set_eq:NN \@@_oldnot: \not
\AtBeginDocument{\cs_set_eq:NN \not \@@_newnot:N}
% \end{macrocode}
% \begin{macrocode}
\cs_new_protected_nopar:Nn \@@_setup_negations:
{
\cs_gset:cpn { not= } { \neq }
\cs_gset:cpn { not< } { \nless }
\cs_gset:cpn { not> } { \ngtr }
\cs_gset:Npn \ngets { \nleftarrow }
\cs_gset:Npn \nsimeq { \nsime }
\cs_gset:Npn \nequal { \ne }
\cs_gset:Npn \nle { \nleq }
\cs_gset:Npn \nge { \ngeq }
\cs_gset:Npn \ngreater { \ngtr }
\cs_gset:Npn \nforksnot { \forks }
}
% \end{macrocode}
%
%
%
% \begin{macrocode}
%</package&(XE|LU)>
% \end{macrocode}
%
\endinput
|