Debian Codegraph @

texmf-dist/tex/luatex/minim-math/minim-math.tex

raw
1
2 \ifdefined \minimmathloaded
3 \wlog{(skipped)}
4 \expandafter\endinput \fi
5 \chardef\minimmathloaded=\catcode`:
6 \catcode`:=11
7
8 \input minim-alloc
9
10 % \mathdef c {expansion}
11 \protected\def\mathdef#1#2{%
12 \protected\def\mathdef:tmp{#2}%
13 \mathcode`#1="8000\relax
14 \letcharcode`#1=\mathdef:tmp}
15 % \mathlet c \csname
16 \let\mathlet = \mathdef
17
18 % sensible defaults
19 \matheqdirmode = 1 % short skips also in rtl
20 \mathdisplayskipmode = 1
21 %
22 % not set here, but maybe relevant:
23 %
24 % \mathsurroundskip = ...
25 % \mathitalicsmode = 1
26 % \mathscriptboxmode = 2
27 % \matheqnogapstep = 1000 % default value
28 % \predisplaygapfactor = 2000 % default value
29
30 % 1 Global style transformations
31
32 % first, helper functions for parsing arguments
33
34 \def\math:parselist#1#2#3#4{% \function \argwrap {list} {arg}
35 \edef\math:expandedlist{{#3}}%
36 \def\math:listaction##1{#1{##1}{#2{#4}}}%
37 \expandafter\splitcommalist
38 \expandafter\math:parseitem
39 \math:expandedlist}
40
41 \def\math:parseitem#1{\math:getrange#1--\math:getrange}
42 \def\math:getrange#1-#2-{\def\math:tmp{#2}%
43 \ifx\math:tmp\empty \math:singleargument{#1}\fi
44 \math:rangeargument{#1}{#2}}
45 \def\math:singleargument#1#2\math:getrange{\fi%
46 \math:listaction{#1}}
47 \def\math:rangeargument#1#2#3\math:getrange{%
48 \math:listaction{\the\numexpr(#1)@\the\numexpr(#2)}}
49
50 \def\math:simplequote#1{#1}
51 \def\math:tonumber#1{\the\numexpr(#1)\relax}
52
53 % then, the user interface
54
55 \protected\def\mathcls{\math:parselist\math:mathcls\math:simplequote}
56 \protected\def\mathfam{\math:parselist\math:mathfam\math:tonumber}
57 \protected\def\mathmap{\math:parselist\math:mathmap\math:simplequote}
58
59 % defined from the lua side: \usemathvariant, \usemathdefault, \mathstyle
60
61 % 1 Local style transformations
62
63 % We use the variable class, but not the family mechanism
64 \fam = -1
65 \let\setfam=\fam
66
67 % for backwards compatibility with plain.tex
68 \newcount\math:famcount
69 \protected\def\fam{%
70 \afterassignment\math:fam
71 \math:famcount}
72 \def\math:fam{%
73 \ifcase\math:famcount
74 \mathstyle{up}\or
75 \mathstyle{it}\or
76 \mathstyle{cal}\or
77 \or % plain family 3 is \tenex
78 \mathstyle{it}\or
79 \mathstyle{sf}\or % slanted math not in unicode
80 \mathstyle{bf}\or
81 \mathstyle{tt}\fi}
82
83 % style switches
84 \protected\def\mit#1{{\mathstyle{it}#1}}
85 \protected\def\mup#1{{\mathstyle{up}#1}}
86 \protected\def\mbf#1{{\mathstyle{bf}#1}}
87 \protected\def\mbfit#1{{\mathstyle{bfit}#1}}
88 \protected\def\mbb#1{{\mathstyle{bb}#1}}
89 \protected\def\frak#1{{\mathstyle{frak}#1}}
90 \protected\def\bffrak#1{{\mathstyle{bffrak}#1}}
91 \protected\def\scr#1{{\mathstyle{scr}#1}} \let\mcal = \scr
92 \protected\def\bfscr#1{{\mathstyle{bfscr}#1}} \let\bfcal = \bfscr
93
94 % 1 Processing the character table
95
96 \newcount \radicalfam \radicalfam = 0
97 \newcount \accentfam \accentfam = 0
98 \newcount \extensiblefam \extensiblefam = 0
99
100 \protected\def\math:accent{\ifmmode% spec num char
101 \expandafter\math:mathaccent\else
102 \expandafter\math:textaccent\fi}
103 \def\math:mathaccent#1#2#3{\Umathaccent #1"0 \accentfam #2 }
104 \def\math:textaccent#1#2#3#4{#4#3}% might be a normal combining accent
105
106 \protected\def\math:stack#1#2#3{% spec num char
107 \withoptions[]{\math:stack:{#1}{#2}{#3}}}
108 \def\math:stack:#1#2#3[#4]#5{%
109 {\mathop{\math:accent{#1}{#2}{#3}{#5}}%
110 \ifx\math:stack#4\math:stack\else \limits
111 \ifx\math:stack#1\math:stack^\else_\fi{#4}\fi}}
112
113 \protected\def\math:radical{\ifmmode% num char
114 \expandafter\math:mathradical\else
115 \expandafter\math:textradical\fi}
116 \def\math:mathradical#1#2{\Uradical\radicalfam #1 }
117 \def\math:textradical#1#2{#2}
118
119 % We initiate the processing here instead of from the lua side, because the lua
120 % file will be executed again inside \everyjob. We are only setting parameters
121 % here that will be saved to the format file, so we need not repeat it.
122
123 \directlua{%
124 local m = require('minim-math')
125 local file = kpse.find_file('minim-math-table', 'lua')
126 local table = loadfile(file)()
127 for _, t in ipairs(table) do
128 m.add_mathchar(t)
129 end
130 }
131
132 % 1 Fixing a few characters
133
134 % fixing a math cs (prevents expansion loops)
135 \def\explicitmathchar#1{%
136 \expandafter\Umathcharnumdef
137 \expandafter#1%
138 \expandafter\Umathcodenum
139 \expandafter`#1}
140
141 % special characters must be explicit
142 \explicitmathchar\lbrace \let\{=\lbrace
143 \explicitmathchar\rbrace \let\}=\rbrace
144 \explicitmathchar\percent
145 \explicitmathchar\mathdollar
146 \explicitmathchar\octothorpe
147 \explicitmathchar\ampersand
148
149 % decimal comma settings
150 \explicitmathchar \comma
151 \Umathchardef \ordcomma "0"0"2C
152 \protected\def\smartcomma{%
153 \futurelet\smartcomma:next\smartcomma:do}
154 \def\smartcomma:do{\let\smartcomma:c\comma
155 \ifx0\smartcomma:next\let\smartcomma:c\ordcomma\fi
156 \ifx1\smartcomma:next\let\smartcomma:c\ordcomma\fi
157 \ifx2\smartcomma:next\let\smartcomma:c\ordcomma\fi
158 \ifx3\smartcomma:next\let\smartcomma:c\ordcomma\fi
159 \ifx4\smartcomma:next\let\smartcomma:c\ordcomma\fi
160 \ifx5\smartcomma:next\let\smartcomma:c\ordcomma\fi
161 \ifx6\smartcomma:next\let\smartcomma:c\ordcomma\fi
162 \ifx7\smartcomma:next\let\smartcomma:c\ordcomma\fi
163 \ifx8\smartcomma:next\let\smartcomma:c\ordcomma\fi
164 \ifx9\smartcomma:next\let\smartcomma:c\ordcomma\fi
165 \smartcomma:c}
166
167 \protected\def\decimalcomma {\Umathcode`\, = 0 \Umathcharfam`\, `\,}
168 \protected\def\nodecimalcomma{\Umathcode`\, = 6 \Umathcharfam`\, `\,}
169 \protected\def\smartdecimalcomma{\mathlet,\smartcomma}
170
171
172 % set the colon to how it used to be
173 \Umathcode`\:="3"0"2236 % \ratio
174 \Umathchardef\colon "6"0"3A
175
176 % ldot as a punctuation mark
177 \Umathchardef\ldotp "6"0"2E
178 \let \period = \ldotp
179
180 % remapping two characters
181 \mathlet * \ast
182 \mathlet - \minus
183
184 % interpret the normal middle dot as the middle dot operator
185 \mathlet · \cdot
186 \Umathchardef\cdotp "6"0"B7
187
188 % move a macro over
189 \protected\def\*{\discretionary{\thinspace
190 \the\textfont\Umathcharfam`\×\Uchar`\×}{}{}}
191
192 % some aliases
193 \let\neq = \ne
194 \let\le = \leq
195 \let\ge = \geq
196 \let\owns = \ni
197 \let\gets = \leftarrow
198 \let\to = \rightarrow
199 \let\land = \wedge
200 \let\lor = \vee
201 \let\lnot = \neg
202
203 % replace \mathhexbox macros
204 \protected\def\mathcharbox#1{\leavevmode
205 \hbox{$\mathsurround0pt\relax#1$}}
206 \protected\def\dag{\mathcharbox†}
207 \protected\def\ddag{\mathcharbox‡}
208 \protected\def\S{\mathcharbox§}
209 \protected\def\P{\mathcharbox¶}
210 \protected\def\Orb{\mathcharbox◯}
211
212 % wide accents are default
213 \let\widehat = \hat
214 \let\widetilde = \tilde
215 \let\overline = \overbar
216 \let\underline = \underbar
217
218 % integrals
219 \let\intlimits=\nolimits
220
221 \explicitmathchar\intop
222 \explicitmathchar\iintop
223 \explicitmathchar\iiintop
224 \explicitmathchar\ointop
225 \explicitmathchar\oiintop
226 \explicitmathchar\oiiintop
227 \explicitmathchar\intclockwiseop
228 \explicitmathchar\varointclockwiseop
229 \explicitmathchar\ointctrclockwiseop
230
231 \edef\int {\intop\intlimits}
232 \edef\iint {\iintop\intlimits}
233 \edef\iiint {\iiintop\intlimits}
234 \edef\oint {\ointop\intlimits}
235 \edef\oiint {\oiintop\intlimits}
236 \edef\oiiint {\oiiintop\intlimits}
237 \edef\intclockwise {\intclockwiseop\intlimits}
238 \edef\varointclockwise {\varointclockwiseop\intlimits}
239 \edef\ointctrclockwise {\ointctrclockwiseop\intlimits}
240
241 \mathlet ∫ \int
242 \mathlet ∬ \iint
243 \mathlet ∭ \iiint
244 \mathlet ∮ \oint
245 \mathlet ∯ \oiint
246 \mathlet ∰ \oiiint
247 \mathlet ∱ \intclockwise
248 \mathlet ∲ \varointclockwise
249 \mathlet ∳ \ointctrclockwise
250
251 % 1 Roots
252
253 \protected\def\sqrt{\sqrt:make{\Uradical\radicalfam"221A}}
254 \protected\def\root#1\of{\sqrt:make{\Uroot\radicalfam"221A{#1}}}
255 \def\sqrt:open#1#2{#1{#2}} % braces are necessary
256 \def\sqrt:close#1{\mathpalette{\sqrt:closed{#1}}}
257 \def\sqrt:closed#1#2#3{% root style content
258 \setbox0=\hbox{$#2\Uradical\radicalfam"221A{#3}$}%
259 #2#1{#3\mkern2mu}\kern-\Umathradicalrule#2%
260 \raise\dimexpr\ht0-1\Umathradicalkern#2-.5\Umathradicalrule#2\hbox
261 {\vrule height0pt depth.2\ht0 width\Umathradicalrule#2}%
262 \kern\Umathradicalkern#2}
263
264 \protected\def\normalroots{\let\sqrt:make\sqrt:open}
265 \protected\def\closedroots{\let\sqrt:make\sqrt:close}
266
267 \normalroots
268
269 \let\of=\relax
270 \mathlet √ \sqrt
271 \mathdef ∛ {\root3\of}
272 \mathdef ∜ {\root4\of}
273
274 % 1 Dots
275
276 % \vdots, \ddots, \adots
277 \newdimen\mathdots:pt
278 \newbox\mathdots:box
279 \def\mathdots:init#1#2{%
280 \mathdots:pt=.1\fontdimen6#20\relax
281 \setbox\mathdots:box=\hbox{$#1.$}%
282 \ht\mathdots:box=\mathdots:pt}
283 \def\mathdots:choice#1{\mathinner{\mathchoice
284 {\mathdots:init\displaystyle\textfont#1}
285 {\mathdots:init\textstyle\textfont#1}
286 {\mathdots:init\scriptstyle\scriptfont#1}
287 {\mathdots:init\scriptscriptstyle\scriptscriptfont#1}}}
288 \protected\def\texvdots{\mathdots:choice{\vbox{%
289 \baselineskip4\mathdots:pt\lineskiplimit0pt\relax \kern6\mathdots:pt
290 \copy\mathdots:box \copy\mathdots:box \copy\mathdots:box}}}
291 \protected\def\texddots{\mathdots:choice{\mkern1mu
292 \raise7\mathdots:pt \vbox{\kern7\mathdots:pt\copy\mathdots:box}\mkern2mu
293 \raise4\mathdots:pt \copy\mathdots:box\mkern2mu
294 \raise1\mathdots:pt \copy\mathdots:box\mkern1mu}}
295 \protected\def\texadots{\mathdots:choice{\mkern1mu
296 \raise1\mathdots:pt \copy\mathdots:box\mkern2mu
297 \raise4\mathdots:pt \copy\mathdots:box\mkern2mu
298 \raise7\mathdots:pt \vbox{\kern7\mathdots:pt\copy\mathdots:box}\mkern1mu}}
299
300 % \ldots and \cdots are unchanged from plain.tex
301 \protected\edef\texldots{\ldots}
302 \protected\edef\texcdots{\cdots}
303
304 % \traditionaldots
305 \protected\def\traditionaldots{%
306 \mathlet \⋮ \texvdots \let\vdots = \texvdots
307 \mathlet \⋯ \texcdots \let\cdots = \texcdots
308 \mathlet \⋰ \texadots \let\adots = \texadots
309 \mathlet \⋱ \texddots \let\ddots = \texddots
310 \mathlet \… \texldots \let\ldots = \texldots}
311
312 % \unicodedots
313 \protected\def\unicodedots{%
314 \Umathcode `\⋮ = "3"0"22EE \let\vdots = \unicodevdots
315 \Umathcode `\⋯ = "0"0"22EF \let\cdots = \unicodecdots
316 \Umathcode `\⋰ = "3"0"22F0 \let\adots = \unicodeadots
317 \Umathcode `\⋱ = "3"0"22F1 \let\ddots = \unicodeddots
318 \Umathcode `\… = "3"0"2026 \let\ldots = \unicodeellipsis}
319
320 \traditionaldots
321
322 % 1 Primes
323
324 % primes
325 \mathdef'{\math:prime{}}
326 \mathdef`{\math:bprime{}}
327 \def\math:prime#1{%
328 \nextifx'{\math:prime:plus{#1}}%
329 {^\csname#1prime\endcsname}}
330 \def\math:prime:plus#1'{%
331 \math:prime{#1p}}
332 \def\math:bprime#1{%
333 \nextifx`{\math:bprime:plus{#1}}%
334 {^\csname b#1prime\endcsname}}
335 \def\math:bprime:plus#1`{%
336 \math:bprime{#1p}}
337 % \pprime etc.
338 \let\pprime=\dprime
339 \let\ppprime=\trprime
340 \let\pppprime=\qprime
341 \let\bprime=\backprime
342 \let\bpprime=\backdprime
343 \let\bppprime=\backtrprime
344
345 % 1 Superscripts and subscripts
346
347 \edef\math:tmp{%
348 \mathdef\Uchar"00B2{^2}
349 \mathdef\Uchar"00B3{^3}
350 \mathdef\Uchar"00B9{^1}
351 \mathdef\Uchar"2070{^0}
352 \mathdef\Uchar"2071{^i}
353 \mathdef\Uchar"2074{^4}
354 \mathdef\Uchar"2075{^5}
355 \mathdef\Uchar"2076{^6}
356 \mathdef\Uchar"2077{^7}
357 \mathdef\Uchar"2078{^8}
358 \mathdef\Uchar"2079{^9}
359 \mathdef\Uchar"207A{^+}
360 \mathdef\Uchar"207B{^-}
361 \mathdef\Uchar"207C{^=}
362 \mathdef\Uchar"207D{^(}
363 \mathdef\Uchar"207E{^)}
364 \mathdef\Uchar"207F{^n}
365 \mathdef\Uchar"1D62{_i}
366 \mathdef\Uchar"1D63{_r}
367 \mathdef\Uchar"1D64{_u}
368 \mathdef\Uchar"1D65{_v}
369 \mathdef\Uchar"1D66{_β}
370 \mathdef\Uchar"1D67{_γ}
371 \mathdef\Uchar"1D68{_ρ}
372 \mathdef\Uchar"1D69{_φ}
373 \mathdef\Uchar"1D6A{_χ}
374 \mathdef\Uchar"2080{_0}
375 \mathdef\Uchar"2081{_1}
376 \mathdef\Uchar"2082{_2}
377 \mathdef\Uchar"2083{_3}
378 \mathdef\Uchar"2084{_4}
379 \mathdef\Uchar"2085{_5}
380 \mathdef\Uchar"2086{_6}
381 \mathdef\Uchar"2087{_7}
382 \mathdef\Uchar"2088{_8}
383 \mathdef\Uchar"2089{_9}
384 \mathdef\Uchar"208A{_+}
385 \mathdef\Uchar"208B{_-}
386 \mathdef\Uchar"208C{_=}
387 \mathdef\Uchar"208D{_(}
388 \mathdef\Uchar"208E{_)}
389 \mathdef\Uchar"2090{_a}
390 \mathdef\Uchar"2091{_e}
391 \mathdef\Uchar"2092{_o}
392 \mathdef\Uchar"2093{_x}
393 \mathdef\Uchar"2094{_ə}
394 \mathdef\Uchar"2095{_h}
395 \mathdef\Uchar"2096{_k}
396 \mathdef\Uchar"2097{_l}
397 \mathdef\Uchar"2098{_m}
398 \mathdef\Uchar"2099{_n}
399 \mathdef\Uchar"209A{_p}
400 \mathdef\Uchar"209B{_s}
401 \mathdef\Uchar"209C{_t}
402 \mathdef\Uchar"2C7C{_j}}
403 \math:tmp
404
405 % 1 Long arrows
406
407 \def\extend#1#2#3{\withoptions[]{\extend:#1{#2}{#3}}}
408 \def\extend:#1#2#3[#4]#5{\mathrel{% char left right below above
409 \mathpalette\extend:choose{#1{#2}{#3}{#4}{#5}}}}
410 \def\extend:choose#1#2{\extend:choose:#1#2}
411 \def\extend:choose:#1#2#3#4#5#6{% style char left right below above
412 \setbox0=\hbox{$#1#5$}\setbox2=\hbox{$#1#6$}%
413 \ifdim \wd0 < \wd2
414 \mathop{\Uoverdelimiter \extensiblefam `#2
415 {\mkern#3mu#6\mkern#4mu}}\limits_{#5}\else
416 \mathop{\Uunderdelimiter \extensiblefam `#2
417 {\mkern#3mu#5\mkern#4mu}}\limits^{#6}\fi}
418
419 \protected\def\xleftarrow {\extend←73}
420 \protected\def\xrightarrow{\extend→37}
421
422 \protected\def\xLeftarrow {\extend⇐73}
423 \protected\def\xRightarrow{\extend⇒37}
424
425 \protected\def\xleftrightarrow{\extend↔77}
426 \protected\def\xLeftrightarrow{\extend⇔77}
427
428 \protected\def\xmapsto {\extend↦47}
429 \protected\def\xmapsfrom {\extend↤74}
430
431 \protected\def\xhookrightarrow {\extend↪67}
432 \protected\def\xhookleftarrow {\extend↩76}
433
434 \protected\def\xleftrightarrows {\extend⇆77}
435 \protected\def\xleftleftarrows {\extend⇇73}
436 \protected\def\xrightrightarrows {\extend⇉37}
437
438 \protected\def\xeq{\extend=11}
439
440 \let \→ \xrightarrow
441 \let \⇒ \xRightarrow
442 \let \← \xleftarrow
443 \let \⇐ \xLeftarrow
444 \let \↔ \xleftrightarrow
445 \let \⇔ \xLeftrightarrow
446 \let \↦ \xmapsto
447 \let \↤ \xmapsfrom
448
449 % 1 Miscellaneous mathematical functions
450
451 % \stackrel {super} {rel}
452 \protected\def\stackrel#1#2{\mathrel{\mathop{#2}\limits^{#1}}}
453 % \stackbin {super} {bin}
454 \protected\def\stackbin#1#2{\mathbin{\mathop{#2}\limits^{#1}}}
455
456 % \text {text}
457 \newcount\textfam
458 \textfam=0
459 \protected\def\text#1{{\mathchoice
460 {\hbox{\the\textfont\textfam#1}}%
461 {\hbox{\the\textfont\textfam#1}}%
462 {\hbox{\the\scriptfont\textfam#1}}%
463 {\hbox{\the\scriptscriptfont\textfam#1}}}}
464
465 % some definitions with vertical lines
466 \def\bra#1{\left⟨#1\right\vert}
467 \def\ket#1{\left\vert#1\right⟩}
468 \def\braket#1#2{\left⟨#1\middle\vert#2\right⟩}
469 \def\norm#1{\left\vert#1\right\vert} \let \abs=\norm
470 \def\Norm#1{\left\Vert#1\right\Vert}
471 \def\ceil#1{\left⌈#1\right⌉}
472 \def\floor#1{\left⌊#1\right⌋}
473
474 % a slightly smaller unary minus
475 \def\unaryminus{\mathord{\mathpalette\unaryminus:make{}}}
476 \def\unaryminus:make#1#2{%
477 \setbox0 = \hbox{$#1-$}
478 \kern .75\wd0
479 \pdfextension save
480 \pdfextension setmatrix{.75 0 0 1}
481 \kern -\wd0 \box0
482 \pdfextension restore}
483
484 % a smaller inverse-function sign
485 \protected\def\inv{^{\scriptscriptstyle\unaryminus1}}%
486
487 % upright multiletter symbols
488 \def\mord#1{\mathord{\mathstyle{up}#1}}
489 \def\mop #1{\mathop {\mathstyle{up}#1}\nolimits}
490 \def\mlop#1{\mathop {\mathstyle{up}#1}\limits}
491
492 % \frac, \tfrac, \dfrac
493 \protected\def\frac#1#2{\Ustack{#1\over#2}}
494 \protected\def\tfrac#1#2{{\textstyle{#1\over#2}}}
495 \protected\def\dfrac#1#2{{\displaystyle{#1\over#2}}}
496
497 % make a few plain macros \protected
498 \def\minim:protect#1{\protected\edef#1{\expandafter\unexpanded\expandafter{#1}}}
499 \minim:protect\smash
500 \minim:protect\dotfill
501
502 % 1 Operators
503
504 \def\newmathop#1{\protected\expandafter\def
505 \csname#1\endcsname{\mathop{\mathstyle{up}#1}\nolimits}}
506 \def\newlargemathop#1{\protected\expandafter\def
507 \csname#1\endcsname{\mathop{\mathstyle{up}#1}}}
508
509 % ported operators
510 \newlargemathop {lim}
511 \newlargemathop {gcd} \newlargemathop {lcm}
512 \newlargemathop {max} \newlargemathop {min}
513 \newlargemathop {sup} \newlargemathop {inf}
514 \newlargemathop {det}
515 \newlargemathop {Pr}
516 \newmathop {log} \newmathop {lg} \newmathop {ln}
517 \newmathop {sin} \newmathop {arcsin} \newmathop {sinh}
518 \newmathop {cos} \newmathop {arccos} \newmathop {cosh}
519 \newmathop {tan} \newmathop {arctan} \newmathop {tanh}
520 \newmathop {cot} \newmathop {coth}
521 \newmathop {sec} \newmathop {csc}
522 \newmathop {arg}
523 \newmathop {ker}
524 \newmathop {dim}
525 \newmathop {hom}
526 \newmathop {exp}
527 \newmathop {deg}
528
529 \protected\def\limsup{\mathop{\mathstyle{up}lim\,sup}}
530 \protected\def\liminf{\mathop{\mathstyle{up}lim\,inf}}
531
532 \let\para=\parallel
533
534 % additional operators
535 \newmathop {Tr} \newmathop {tr} \newmathop{Span}
536 \newmathop {GL} \newmathop {SL}
537 \newmathop {SU} \newmathop {U}
538 \newmathop {SO} \newmathop {O}
539 \newmathop {Sp}
540 \newmathop {im}
541 \newmathop {End} \newmathop {Aut}
542 \newmathop {Dom} \newmathop {Codom}
543
544 % 1 Displayed equations
545
546 % \leftdisplaystrue
547 \newif\ifleftdisplays
548 \newif\ifdisplay:
549 \newif\ifdisplay:nr
550
551 \ifdefined\minimmathlatex\else % for the latex package
552
553 % \display
554 \protected\def\display{\display:true}
555 % \displaynr {nr}
556 \protected\def\displaynr{\display:true\display:nrtrue
557 \nextifcat\bgroup\display:specialnr\relax}
558
559 % \setdisplaynr {...}
560 \newtoks\setdisplaynr
561 % \equationnumber
562 \newcount\equationnumber \equationnumber = 0
563 \setdisplaynr{\global\advance\equationnumber1(\the\equationnumber)}
564
565 \newtoks\display:specialnr
566 \display:specialnr{\the\setdisplaynr}
567
568 % \[ ... \]
569 \protected\def\[#1\]{%
570 \ifdisplay:\expandafter\startdisplay\else\Ustartmath\fi
571 \tagging:tagformula{#1}#1\relax
572 \global\expandafter\display:false
573 \ifdisplay:\expandafter\stopdisplay\else\Ustopmath\fi}
574 \protected\def\]{\errmessage{Unmatched \string\]}}
575 \ifdefined \tagging:tagformula \else
576 \let\tagging:tagformula=\ignore \fi
577
578 \newmuskip\leftdisplayindent
579 \leftdisplayindent = 0mu
580
581 \protected\def\startdisplay{%
582 % if the display starts a paragraph, omit baselineskip
583 % and ensure that the long \beforedisplayskip is used
584 \ifvmode \nointerlineskip
585 \noindent \hbox to .5\hsize{\hss}\fi
586 \Ustartdisplaymath
587 % compatibility with minim-pdf
588 \csname tagging:indisplaytrue\endcsname
589 % for left-aligned equations, force manual placement
590 \ifleftdisplays\mskip\leftdisplayindent\relax\fi}
591 \protected\def\stopdisplay{%
592 \ifleftdisplays
593 \hskip\displaywidth minus\displaywidth\fi
594 \global\expandafter\display:nrfalse
595 \ifdisplay:nr
596 \eqno\the\display:specialnr
597 \global\display:specialnr{\the\setdisplay:nr}\fi
598 \Ustopdisplaymath
599 \ignorespaces}
600
601 \fi
602
603 %  standard mappings
604
605 \mathstyle{clear}
606 \mathmap{latin, greek, Latin}{it}
607
608 % map ħ (h-with-stroke) to ℏ (planck-constant)
609 \mathdef ħ {ℏ}
610
611 % \reqno
612 \let\reqno = \eqno
613
614 \let\math:tmp=\undefined
615 \catcode`:=\minimmathloaded
616