Debian Codegraph @

texmf-dist/doc/luametatex/base/luametatex-math.tex

raw
1 % language=us runpath=texruns:manuals/luametatex
2
3 \environment luametatex-style
4
5 \startdocument[title=Math]
6
7 \startsection[title={Introduction}]
8
9 There is a lot to tell about math typesetting in \LUAMETATEX\ but plenty is
10 covered in articles, progress reports and manuals. Here we limit ourselves to
11 some basics. This chapter mostly contains information that is not presented
12 elsewhere. Because math in regular \TEX\ is basically frozen and other macro
13 packaged depend on that, the extensions we have in \LUAMETATEX\ are mainly useful
14 for \CONTEXT. Even there we don't use all features, because completely opening up
15 and providing ways to control every aspect also served the purpose of testing: it
16 just comes with the package.
17
18 This chapter is a variant on the one in the old \LUAMETATEX\ manual and it might
19 evolve a bit. We will not discuss the many options that the engine provides, at
20 least not now. There is an extensive \quotation {Math in \CONTEXT} that shows the
21 state of the art and serves as reference. In due time we might write some more
22 about what happens deep down in the engine, although already plenty has been
23 published during the upgrade, about dealing with math fonts as well as
24 experimenting with new features. Because all gets wrapped in high level
25 interfaces there is not that much need (nor audience) for endless explanations
26 anyway. There are also examples given in the chapter that discusses all
27 primitives. Most \CONTEXT\ users will never see these low level math commands!
28
29 \stopsection
30
31 \startsection[title={Traditional alongside \OPENTYPE}]
32
33 Because we started in 2019 from \LUATEX, by the end of 2021 this chapter started
34 with this, even if we already reworked the engine:
35
36 \startquotation
37 At this point there is no difference between \LUAMETATEX\ and \LUATEX\ with
38 respect to math. Well, this might no longer be true because we have more control
39 options that define default behavior and also have a more extensive scaling
40 model. Anyway, it should not look worse, and maybe even a bit better. The
41 handling of mathematics in \LUATEX\ differs quite a bit from how \TEX82 (and
42 therefore \PDFTEX) handles math. First, \LUATEX\ adds primitives and extends some
43 others so that \UNICODE\ input can be used easily. Second, all of \TEX82's
44 internal special values (for example for operator spacing) have been made
45 accessible and changeable via control sequences. Third, there are extensions that
46 make it easier to use \OPENTYPE\ math fonts. And finally, there are some
47 extensions that have been proposed or considered in the past that are now added
48 to the engine.
49
50 You might be surprised that we don't use all these new control features in
51 \CONTEXT\ \LMTX, but who knows what might happen because users drive it. The main
52 reason for adding so much is that I decided it made more sense to be complete now
53 than gradually add more and more. At some point we should be able to say \quote
54 {This is it}. Also, when looking at these features, you need to keep in mind that
55 when it comes to math, \LATEX\ is the dominant macro package and it never needed
56 these engine features, so most are probably just here for exploration purposes.
57 \stopquotation
58
59 Although we still process math as \TEX\ does, there have been some fundamental
60 changes to the machinery. Most of that is discussed in documents that come with
61 \CONTEXT\ and in Mikael Sundqvist math manual. Together we explored some new ways
62 to deal with math spacing, penalties, fencing, operators, fractions, atoms and
63 other features of the \TEX\ engine. We started from the way \CONTEXT\ used the
64 already present functionality combine with sometimes somewhat dirty (but on the
65 average working well) tricks.
66
67 Much in \LUAMETATEX\ math handling is about micro|-|typography and for us the
68 results are quite visible. But, as far as we know, there have never been
69 complaints or demands in the direction of the features discussed here. Also,
70 \TEX\ math usage outside \CONTEXT\ is rather chiseled in stone (already for
71 nearly three decades) so we don't expect other macro packages to use the new
72 features anyway. Anyway, after spending a real lot of time on this we both
73 decided that we're mostly feature complete.
74
75 \stopsection
76
77 \startsection[title=Intermezzo]
78
79 It is important to understand a bit how \TEX\ handles math. The math engine
80 is a large subsystem and basically can be divided in two parts: convert
81 sequential input into a list of nodes where math related ones actually are
82 sort of intermediate and therefore called noads.
83
84 In text mode entering \type {abc} results in three glyph nodes and \type {a b
85 c} in three glyph nodes separated by (spacing) glue. Successive glyphs can be
86 transformed in the font engine later on, just as hyphenation directive can
87 be added. Eventually one (normally) gets a mix of glyphs, font kerns from
88 a sequence of glyphs
89
90 In math mode \type {abc} results in three simple ordinary noads and \type {a b c}
91 is equivalent to that: three noads. But \type {a bc} results in two ordinary
92 noads where the second one has a sublist of two ordinary noads. Because
93 characters have class properties, \type {( a + b = c )} results in a simple open
94 noad, a simple ordinary, a simple binary, a simple ordinary, a simple relation, a
95 simple ordinary and simple close noad. The next samples show a bit of this; in
96 order to see the effects of spacing between ordinary atoms set it to \type {9mu}.
97
98 \startbuffer
99 \typebuffer[sample]
100 % \tracingmath \plusone
101 % \tracingonline\plusone
102 \startlinecorrection
103 \setmathspacing\mathordinarycode\mathordinarycode\allmathstyles9mu
104 \mathgroupingmode\zerocount
105 \scale[scale=2000]{\showmakeup[mathglue]\showboxes\mathspacingmode\plusone\getbuffer[sample]}
106 \stoplinecorrection
107 \blank[2*line]
108 \stopbuffer
109
110 \startbuffer[sample]
111 $a b c$ \quad $a bc$ \quad $abc$
112 \stopbuffer
113
114 \getbuffer
115
116 With \type {\tracingmath 1} we get this logged:
117
118 \starttyping
119 > \inlinemath=
120 \noad[ord][...]
121 .\nucleus
122 ..\mathchar[ord][...], family "0, character "61
123 \noad[ord][...]
124 .\nucleus
125 ..\mathchar[ord][...], family "0, character "62
126 \noad[ord][...]
127 .\nucleus
128 ..\mathchar[ord][...], family "0, character "63
129
130 > \inlinemath=
131 \noad[ord][...]
132 .\nucleus
133 ..\mathchar[ord][...], family "0, character "61
134 \noad[ord][...]
135 .\nucleus
136 ..\mathchar[ord][...], family "0, character "62
137 \noad[ord][...]
138 .\nucleus
139 ..\mathchar[ord][...], family "0, character "63
140
141 > \inlinemath=
142 \noad[ord][...]
143 .\nucleus
144 ..\mathchar[ord][...], family "0, character "61
145 \noad[ord][...]
146 .\nucleus
147 ..\mathchar[ord][...], family "0, character "62
148 \noad[ord][...]
149 .\nucleus
150 ..\mathchar[ord][...], family "0, character "63
151 \stoptyping
152
153 \startbuffer[sample]
154 ${a} {b} {c}$ \quad ${a} {bc}$ \quad ${abc}$
155 \stopbuffer
156
157 \getbuffer
158
159 If the previous log surprises you, that might be because in \CONTEXT\ we set up
160 the engine differently: curly braces don't create ordinary atoms. However, when
161 we set \type {\mathgroupingmode 0} we return to what the engine normally does.
162
163 \starttyping
164 > \inlinemath=
165 \noad[ord][...]
166 .\nucleus
167 ..\mathchar[ord][...], family "0, character "61
168 \noad[ord][...]
169 .\nucleus
170 ..\mathchar[ord][...], family "0, character "62
171 \noad[ord][...]
172 .\nucleus
173 ..\mathchar[ord][...], family "0, character "63
174
175 > \inlinemath=
176 \noad[ord][...]
177 .\nucleus
178 ..\mathchar[ord][...], family "0, character "61
179 \noad[ord][...]
180 .\nucleus
181 ..\submlist[0][...][tracing depth 5 reached]
182
183 > \inlinemath=
184 \noad[ord][...]
185 .\nucleus
186 ..\submlist[0][...][tracing depth 5 reached]
187 \stoptyping
188
189 A warning is in place: tracing in \LUAMETATEX\ gets extended when we feel the
190 need to gat more feedback from the engine. But it will only be more.
191
192 From the first example you can imagine what these sub lists look like: a list of
193 ordinary atoms. The final list that is mix of nodes and yet unprocessed noads get
194 fed into the math|-|to|-|hlist function and eventually the noads become glyphs,
195 boxes, kerns, glue and whatever makes sense. A lot goes on there: think scripts,
196 fractions, fences, accents, radicals, spacing, break control.
197
198 An example of more tricky scanning is shown here:
199
200 \starttyping
201 a + 1 \over 2 + b
202 a + {1}\over{2} + b
203 a + {{1}\over{2}} + b
204 \stoptyping
205
206 In this case the \type {\over} makes \TEX\ reconsider the last noad, remove if
207 from the current list and save it for later, then scan for a following atom a
208 single character turned atom or a braced sequence that then is an ordinary noad.
209 In the end a fraction noad is made. When that gets processed later specific
210 numerator and denominator styles get applied (explicitly entered style nodes of
211 course overload this for the content). The fact that this construct is all about
212 (implicit) ordinary noads, themselves captured in noads, combined with the wish
213 for enforced consistent positioning of numerator and denominator, plus style
214 overload, color support and whatever comes to mind means that in practice one
215 will use a \type {\frac} macro that provides all that control. \footnote {There
216 are now a \type {\Uover} primitives that look ahead and then of course still
217 treat curly braces as math lists to be picked up.}
218
219 A similar tricky case is this:
220
221 \starttyping
222 ( a + ( b - c ) + d )
223 \left ( a + \left ( b - c \right ) + d \right )
224 \stoptyping
225
226 Here the first line creates a list of noads but the second line create a fenced
227 structure that is handled as a whole in order to make the fences match. \footnote
228 {Actually instead of such a structure there could have been delimiters with
229 backlinks but one never knows what happens with these links when processing
230 passes are made so that fragility is avoided.} A fence noad will not break across
231 lines as it is boxed and that is the reason why macro packages have these \type
232 {\bigg} macros: they explicitly force a size using some trickery. In \LUAMETATEX\
233 a fence object can actually be unpacked when the class is configured as such. It
234 is one of the many extensions we have.
235
236 There are some peculiar cases that one can run into but that actually are
237 mentioned in the \TEX\ book. Often these reasons for intentional side effects
238 become clear when one thinks of the average usage but unless one is willing to
239 spend time on the \quote {fine points of math} they can also interfere with
240 intentions. The next bits of code are just for the reader to look at. Try to
241 predict the outcome. Watch out: in \LMTX\ the outcome is not what one gets by
242 default in \LUATEX, \PDFTEX\ or regular \TEX. \footnote {One can set \typ
243 {\mathgroupingmode = 0} to get close.}
244
245 \starttyping
246 $ 1 {\red +} 2$\par
247 $ 1 \color[red]{+} 2$\par
248 $ 1 \mathbin{\red +} 2$\par
249 $ a + - b + {- b} $
250 $ a \pm - b - {+ b} $
251 $ - b $
252 $ {- b} $
253 \stoptyping
254
255 The message here is that when a user is coding the mindset with respect to
256 grouping using curly braces has to be switched to math mode too. And how many
257 users really read the relevant chapters of the \TEX\ book a couple of times (as
258 much makes only sense after playing with math in \TEX)? Even if one doesn't grasp
259 everything it's a worthwhile read. Also consider this: did you really ask for an
260 ordinary atom when you uses curly braces where no lists were expected? And what
261 would have happened when ordinary related spacing had been set to non|-|zero?
262
263 All the above (and plenty more) is why in \CONTEXT\ \LMTX\ we make extensive use
264 of some \LUAMETATEX\ features, like: additional atom classes, configurable inter
265 atom spacing and penalties, pairwise atom rules that can change classes, class
266 based rendering options, more font parameters, configurable style instead of hard
267 coded ones in constructs, more granular spacing, etc. That way we get quite
268 predictable results but also drop some older (un)expected behavior and side
269 effects. It is also why we cannot show many examples in the \LUAMETATEX\ manual:
270 it uses \CONTEXT\ and we see no reason to complicate out lives (and spend energy
271 on) turning off all the nicely cooperating features (and then for sure forgetting
272 one) just for the sake of demos. It also gave us the opportunity to improve
273 existing mechanisms and|/|or at least simplify their sometimes complex code.
274
275 One last word here about sequences of ordinary atoms: the traditional code path
276 feeds ordinary atoms into a ligature and kerning routine and does that when it
277 encounters one. However, in \OPENTYPE\ we don't have ligatures not (single) kerns
278 so there that doesn't apply. As we're not aware of traditional math fonts with
279 ligatures and no one is likely to use these fonts with \LUAMETATEX\ the ligature
280 code has been disabled. \footnote {It might show up in a different way if we feel
281 the need in which case it's more related to runtime patches to fonts and class
282 bases ligature building.} The kerning has been redone a bit so that it permits us
283 to fine tune spacing (which in \CONTEXT\ we control with goodie files). The
284 mentioned routine can also add italic correction, but that happens selectively
285 because it is driven by specifications and circumstances. It is one of the places
286 where the approach differs from the original, if only for practical reasons.
287
288 In addition to what we explained above, we mention the \typ {\beginmathgroup} and
289 \typ {\endmathgroup} primitives behave like \typ {\begingroup} and \typ {\endgroup}
290 but restore a style change inside the group. Style changes are actually injecting
291 s special style noad which makes them sort of persistent till the next explicit
292 change which can be confusing. This additional grouping model compensates for
293 that.
294
295 \stopsection
296
297 \startsection[title={Unicode math characters}]
298
299 For various reasons we need to encode a math character in a 32 bit number and
300 because we often also need to keep track of families and classes the range of
301 characters is limited to 20 bits. There are upto 64 classes (which is a lot more
302 than in \LUATEX) and 64 families (less than in \LUATEX). The upper limit of
303 characters is less that what \UNICODE\ offers but for math we're okay. If needed
304 we can provide less families.
305
306 The math primitives from \TEX\ are kept as they are, except for the ones that
307 convert from input to math commands: \type {mathcode}, and \type {delcode}. These
308 two now allow for the larger character codes argument on the left hand side of
309 the equals sign. The number variants of some primitives might be dropped in favor
310 of the primitives that read more than one separate value (class, family and
311 code). All relevant primitives are explained in the primitives chapter.
312
313 A delimiter in traditional \TEX\ combines two definitions: the regular character
314 and the way it can become a larger (extensible) one. The small character is just
315 like a math character but the larger one can come from a different font (family).
316 However, in \OPENTYPE\ math fonts the larger sizes (variants) and extensibles
317 (parts) come from the same font. For that reason \LUAMETATEX\ also accepts a math
318 character when a delimited specifier is expected. It basically means that we
319 could remove delimiters as such from the engine. After all, when we let \LUA\
320 load a traditional font we can as well use virtual fonts to handle the variants
321 and extensibles, which is indeed the case when we support the jmh fonts.
322
323 \stopsection
324
325 \startsection[title={Math classes}]
326
327 Most characters belong to a so called math class which can be set for each
328 character if needed. There are upto 64 classes of which at this moment about 20
329 are predefined so, taking some future usage by the engine into account,you can
330 assume 32 upto 60 to be available for any purpose. The number of families has
331 been reduced from 256 to 64 which is plenty for daily use in an \OPENTYPE\ setup.
332 If we ever need to expand the \UNICODE\ range there will be less families or we
333 just go for a larger internal record. The values of begin and end classes and the
334 number of classes can be fetched from the \LUA\ status table. There are callbacks
335 that makes it possible to report user classes when there is the need.
336
337 \stopsection
338
339 \startsection[title=Setting up the engine]
340
341 Rendering math has long been dominated by \TEX\ but that changed when \MICROSOFT\
342 came with \OPENTYPE\ math: an implementation as well as a font. Some of that was
343 modeled after \TEX\ and some was dictated (we think) by the way word processors
344 deal with math. For instance, traditional \TEX\ math has a limited set of glyph
345 properties and therefore has a somewhat complex interplay between width and
346 italic correction. There are no kerns, contrary to \OPENTYPE\ math fonts that
347 provides staircase kerns. Interestingly \TEX\ does have some ligature building
348 going on in the engine.
349
350 In traditional \TEX\ italic correction gets added to the width and selectively
351 removed later (or compensated by some shift and|/|or cheating with the box
352 width). When we started with \LUATEX\ we had to gamble quite a bit about how to
353 apply parameters and glyph properties which resulted in different code paths,
354 heuristics, etc. That worked on the average but fonts are often not perfect and
355 when served as an example for another one the bad bits can be inherited. That
356 said, over time the descriptions improved and this is what the \OPENTYPE\
357 specification has to say about italic correction now \footnote {\type
358 {https://docs.microsoft.com/en-us/typography/opentype/spec/math}}:
359
360 \startitemize [n]
361 \startitem
362 When a run of slanted characters is followed by a straight character
363 (such as an operator or a delimiter), the italics correction of the last
364 glyph is added to its advance width.
365 \stopitem
366 \startitem
367 When positioning limits on an N-ary operator (e.g., integral sign), the
368 horizontal position of the upper limit is moved to the right by half the
369 italics correction, while the position of the lower limit is moved to the
370 left by the same distance.
371 \stopitem
372 \startitem
373 When positioning superscripts and subscripts, their default horizontal
374 positions are also different by the amount of the italics correction of
375 the preceding glyph.
376 \stopitem
377 \stopitemize
378
379 The first rule is complicated by the fact that \quote {followed} is vague: in
380 \TEX\ the sequence \typ {$ a b c def $} results in six separate atoms, separated
381 by inter atom spacing. The characters in these atoms are the nucleus and there
382 can be a super- and|/|or subscript attached and in \LUAMETATEX\ also a prime,
383 super-prescript and/or sub-prescript.
384
385 The second rule comes from \TEX\ and one can wonder why the available top accent
386 anchor is not used. Maybe because bottom accent anchors are missing? Anyway,
387 we're stuck with this now.
388
389 The third rule also seems to come from \TEX. Take the \quote {\it f} character:
390 in \TEX\ fonts that one has a narrow width and part sticks out (in some even at
391 the left edge). That means that when the subscript gets attached it will move
392 inwards relative to the real dimensions. Before the superscript an italic
393 correction is added so what that correction is non|-|zero the scripts are
394 horizontally shifted relative to each other.
395
396 Now look at this specification of staircase kerns \footnote {Idem.}:
397
398 \startnarrower
399 The \type {MathKernInfo} table provides mathematical kerning values used for
400 kerning of subscript and superscript glyphs relative to a base glyph. Its
401 purpose is to improve spacing in situations such as omega with superscript f
402 or capital V with subscript capital A.
403
404 Mathematical kerning is height dependent; that is, different kerning amounts
405 can be specified for different heights within a glyph’s vertical extent. For
406 any given glyph, different values can be specified for four corner positions,
407 top|-|right, to|-|left, etc., allowing for different kerning adjustments
408 according to whether the glyph occurs as a subscript, a superscript, a base
409 being kerned with a subscript, or a base being kerned with a superscript.
410 \stopnarrower
411
412 Again we're talking super- and subscripts and should we now look at the italic
413 correction or assume that the kerns do the job? This is a mixed bag because
414 scripts are not always (single) characters. We have to guess a bit here. After
415 years of experimenting we came to the conclusion that it will never be okay so
416 that's why we settled on controls and runtime fixes to fonts.
417
418 This means that processing math is controlled by \typ {\mathfontcontrol}, a
419 numeric bitset parameter. The recommended bits are marked with a star but it
420 really depends on the macro package to set up the machinery well. Of course one
421 can just enable all and see what happens. \footnote {This model was more granular
422 and could even be font (and character) specific but that was dropped because
423 fonts are too inconsistent and an occasional fit is more robust that a generally
424 applied rule.} A list of possible control bits can be found in the primitives
425 chapter where we discuss this parameter.
426
427 So, to summarize: the reason for this approach is that traditional and \OPENTYPE\
428 fonts have different approaches (especially when it comes to dealing with the
429 width and italic corrections) and is even more complicated by the fact that the
430 fonts are often inconsistent (within and between). In \CONTEXT\ we deal with this
431 by runtime fixes to fonts. In any case the Cambria font is taken as reference.
432
433 {\em It is important to notice that in \CONTEXT\ we no longer use italic
434 correction at all. After many experiments Mikael Sundvist and I settled on a
435 different approach where we use true widths, proper anchors, a new set of corner
436 kerns, additional parameters and more. We tweak the fonts to match this model
437 which in our opinion gives better results and less interference. We could
438 actually simplify the engine and kick italics out of math but for the moment we
439 keep it around so that we can show improvements in manuals and articles.}
440
441 \stopsection
442
443 \startsection[title={Math styles}]
444
445 It is possible to discover the math style that will be used for a formula in an
446 expandable fashion (while the math list is still being read). To make this
447 possible, \LUATEX\ adds the new primitive: \typ {\mathstyle}. This is a \quote
448 {convert command} like e.g. \typ {\romannumeral}: its value can only be read,
449 not set. Beware that contrary to \LUATEX\ this is now a proper number so you need
450 to use \type {\number} or \type {\the} in order to serialize it.
451
452 The returned value is between 0 and 7 (in math mode), or $-1$ (all other modes).
453 For easy testing, the eight math style commands have been altered so that they can
454 be used as numeric values, so you can write code like this:
455
456 \starttyping
457 \ifnum\mathstyle=\textstyle
458 \message{normal text style}
459 \else \ifnum\mathstyle=\crampedtextstyle
460 \message{cramped text style}
461 \fi \fi
462 \stoptyping
463
464 Sometimes you won't get what you expect so a bit of explanation might help to
465 understand what happens. When math is parsed and expanded it gets turned into a
466 linked list. In a second pass the formula will be build. This has to do with the
467 fact that in order to determine the automatically chosen sizes (in for instance
468 fractions) following content can influence preceding sizes. A side effect of this
469 is for instance that one cannot change the definition of a font family (and
470 thereby reusing numbers) because the number that got used is stored and used in
471 the second pass (so changing \type {\fam 12} mid|-|formula spoils over to
472 preceding use of that family).
473
474 The style switching primitives like \type {\textstyle} are turned into nodes so the
475 styles set there are frozen. The \type {\mathchoice} primitive results in four
476 lists being constructed of which one is used in the second pass. The fact that
477 some automatic styles are not yet known also means that the \type {\mathstyle}
478 primitive expands to the current style which can of course be different from the
479 one really used. It's a snapshot of the first pass state. As a consequence in the
480 following example you get a style number (first pass) typeset that can actually
481 differ from the used style (second pass). In the case of a math choice used
482 ungrouped, the chosen style is used after the choice too, unless you group.
483
484 \startbuffer[1]
485 [a:\number\mathstyle]\quad
486 \bgroup
487 \mathchoice
488 {\bf \scriptstyle (x:d :\number\mathstyle)}
489 {\bf \scriptscriptstyle (x:t :\number\mathstyle)}
490 {\bf \scriptscriptstyle (x:s :\number\mathstyle)}
491 {\bf \scriptscriptstyle (x:ss:\number\mathstyle)}
492 \egroup
493 \quad[b:\number\mathstyle]\quad
494 \mathchoice
495 {\bf \scriptstyle (y:d :\number\mathstyle)}
496 {\bf \scriptscriptstyle (y:t :\number\mathstyle)}
497 {\bf \scriptscriptstyle (y:s :\number\mathstyle)}
498 {\bf \scriptscriptstyle (y:ss:\number\mathstyle)}
499 \quad[c:\number\mathstyle]\quad
500 \bgroup
501 \mathchoice
502 {\bf \scriptstyle (z:d :\number\mathstyle)}
503 {\bf \scriptscriptstyle (z:t :\number\mathstyle)}
504 {\bf \scriptscriptstyle (z:s :\number\mathstyle)}
505 {\bf \scriptscriptstyle (z:ss:\number\mathstyle)}
506 \egroup
507 \quad[d:\number\mathstyle]
508 \stopbuffer
509
510 \startbuffer[2]
511 [a:\number\mathstyle]\quad
512 \begingroup
513 \mathchoice
514 {\bf \scriptstyle (x:d :\number\mathstyle)}
515 {\bf \scriptscriptstyle (x:t :\number\mathstyle)}
516 {\bf \scriptscriptstyle (x:s :\number\mathstyle)}
517 {\bf \scriptscriptstyle (x:ss:\number\mathstyle)}
518 \endgroup
519 \quad[b:\number\mathstyle]\quad
520 \mathchoice
521 {\bf \scriptstyle (y:d :\number\mathstyle)}
522 {\bf \scriptscriptstyle (y:t :\number\mathstyle)}
523 {\bf \scriptscriptstyle (y:s :\number\mathstyle)}
524 {\bf \scriptscriptstyle (y:ss:\number\mathstyle)}
525 \quad[c:\number\mathstyle]\quad
526 \begingroup
527 \mathchoice
528 {\bf \scriptstyle (z:d :\number\mathstyle)}
529 {\bf \scriptscriptstyle (z:t :\number\mathstyle)}
530 {\bf \scriptscriptstyle (z:s :\number\mathstyle)}
531 {\bf \scriptscriptstyle (z:ss:\number\mathstyle)}
532 \endgroup
533 \quad[d:\number\mathstyle]
534 \stopbuffer
535
536 \typebuffer[1]
537
538 This gives:
539
540 \blank $\displaystyle \getbuffer[1]$ \blank
541 \blank $\textstyle \getbuffer[1]$ \blank
542
543 Using \type {\begingroup} \unknown\ \type {\endgroup} instead gives:
544
545 \blank $\displaystyle \getbuffer[2]$ \blank
546 \blank $\textstyle \getbuffer[2]$ \blank
547
548 This might look wrong but it's just a side effect of \type {\mathstyle} expanding
549 to the current (first pass) style and the number being injected in the list that
550 gets converted in the second pass. It all makes sense and it illustrates the
551 importance of grouping. In fact, the math choice style being effective afterwards
552 has advantages. It would be hard to get it otherwise.
553
554 So far for the more \LUATEX ish approach. One problem with \type {\mathstyle} is
555 that when you got it, and want to act upon it, you need to remap it onto say \type
556 {\scriptstyle} which can be done with an eight branched \type {\ifcase}. This is
557 why we also have a more efficient alternative that you can use in macros:
558
559 \starttyping
560 \normalexpand{ ... \givenmathstyle\the\mathstyle ...}
561 \normalexpand{ ... \givenmathstyle\the\mathstackstyle ...}
562 \stoptyping
563
564 This new primitive \typ {\givenmathstyle} accepts a numeric value. The \typ
565 {\mathstackstyle} primitive is just a bonus (it complements \type {\mathstack}).
566
567 The styles that the different math components and their sub components start out
568 with are no longer hard coded but can be set at runtime:
569
570 \starttabulate
571 \FL
572 \BC primitive name \BC default \NC \NR
573 \TL
574 \NC \type {\Umathoverlinevariant} \NC cramped \NC \NR
575 \NC \type {\Umathunderlinevariant} \NC normal \NC \NR
576 \NC \type {\Umathoverdelimitervariant} \NC small \NC \NR
577 \NC \type {\Umathunderdelimitervariant} \NC small \NC \NR
578 \NC \type {\Umathdelimiterovervariant} \NC normal \NC \NR
579 \NC \type {\Umathdelimiterundervariant} \NC normal \NC \NR
580 \NC \type {\Umathhextensiblevariant} \NC normal \NC \NR
581 \NC \type {\Umathvextensiblevariant} \NC normal \NC \NR
582 \NC \type {\Umathfractionvariant} \NC cramped \NC \NR
583 \NC \type {\Umathradicalvariant} \NC cramped \NC \NR
584 \NC \type {\Umathdegreevariant} \NC doublesuperscript \NC \NR
585 \NC \type {\Umathaccentvariant} \NC cramped \NC \NR
586 \NC \type {\Umathtopaccentvariant} \NC cramped \NC \NR
587 \NC \type {\Umathbottomaccentvariant} \NC cramped \NC \NR
588 \NC \type {\Umathoverlayaccentvariant} \NC cramped \NC \NR
589 \NC \type {\Umathnumeratorvariant} \NC numerator \NC \NR
590 \NC \type {\Umathdenominatorvariant} \NC denominator \NC \NR
591 \NC \type {\Umathsuperscriptvariant} \NC superscript \NC \NR
592 \NC \type {\Umathsubscriptvariant} \NC subscript \NC \NR
593 \NC \type {\Umathprimevariant} \NC superscript \NC \NR
594 \NC \type {\Umathstackvariant} \NC numerator \NC \NR
595 \LL
596 \stoptabulate
597
598 These defaults remap styles are as follows:
599
600 \starttabulate[|Tl|l|l|]
601 \FL
602 \BC default \BC result \BC mapping \NC \NR
603 \TB
604 \NC cramped \NC cramp the style \NC D' D' T' T' S' S' SS' SS' \NC \NR
605 \NC subscript \NC smaller and cramped \NC S' S' S' S' SS' SS' SS' SS' \NC \NR
606 \NC small \NC smaller \NC S S S S SS SS SS SS \NC \NR
607 \NC superscript \NC smaller \NC S S S S SS SS SS SS \NC \NR
608 \NC smaller \NC smaller unless already SS \NC S S' S S' SS SS' SS SS' \NC \NR
609 \NC numerator \NC smaller unless already SS \NC S S' S S' SS SS' SS SS' \NC \NR
610 \NC denominator \NC smaller, all cramped \NC S' S' S' S' SS' SS' SS' SS' \NC \NR
611 \NC doublesuperscript \NC smaller, keep cramped \NC S S' S S' SS SS' SS SS' \NC \NR
612 \LL
613 \stoptabulate
614
615 The main reason for opening this up was that it permits experiments and removed
616 hard coded internal values. But as these defaults served well for decades there
617 are no real reasons to change them.
618
619 There are a few math commands in \TEX\ where the style that will be used is not
620 known straight from the start. These commands (\type {\over}, \type {\atop},
621 \typ {\overwithdelims}, \typ {\atopwithdelims}) would therefore normally return
622 wrong values for \type {\mathstyle}. To fix this, \LUATEX\ introduces a special
623 prefix command: \type {\mathstack}:
624
625 \starttyping
626 $\mathstack {a \over b}$
627 \stoptyping
628
629 The \type {\mathstack} command will scan the next brace and start a new math group
630 with the correct (numerator) math style. The \typ {\mathstackstyle} primitive
631 relates to this feature.
632
633 \LUATEX\ has four new primitives to set the cramped math styles directly:
634
635 \starttyping
636 \crampeddisplaystyle
637 \crampedtextstyle
638 \crampedscriptstyle
639 \crampedscriptscriptstyle
640 \stoptyping
641
642 These additional commands are not all that valuable on their own, but they come
643 in handy as arguments to the math parameter settings that will be added shortly.
644
645 Because internally the eight styles are represented as numbers some of the new
646 primitives that relate to them also work with numbers and often you can use them
647 mixed. The \typ {\tomathstyle} prefix converts a symbolic style into a number so
648 \typ {\number \tomathstyle \crampedscriptstyle} gives~\number \tomathstyle
649 \crampedscriptstyle.
650
651 In Eijkhouts \quotation {\TEX\ by Topic} the rules for handling styles in scripts
652 are described as follows:
653
654 \startitemize
655 \startitem
656 In any style superscripts and subscripts are taken from the next smaller style.
657 Exception: in display style they are in script style.
658 \stopitem
659 \startitem
660 Subscripts are always in the cramped variant of the style; superscripts are only
661 cramped if the original style was cramped.
662 \stopitem
663 \startitem
664 In an \type {..\over..} formula in any style the numerator and denominator are
665 taken from the next smaller style.
666 \stopitem
667 \startitem
668 The denominator is always in cramped style; the numerator is only in cramped
669 style if the original style was cramped.
670 \stopitem
671 \startitem
672 Formulas under a \type {\sqrt} or \type {\overline} are in cramped style.
673 \stopitem
674 \stopitemize
675
676 In \LUATEX\ one can set the styles in more detail which means that you sometimes
677 have to set both normal and cramped styles to get the effect you want. (Even) if
678 we force styles in the script using \typ {\scriptstyle} and \typ
679 {\crampedscriptstyle} we get this:
680
681 \startbuffer[demo]
682 \starttabulate
683 \FL
684 \BC style \BC example \NC \NR
685 \TL
686 \NC default \NC $b_{x=xx}^{x=xx}$ \NC \NR
687 \NC script \NC $b_{\scriptstyle x=xx}^{\scriptstyle x=xx}$ \NC \NR
688 \NC crampedscript \NC $b_{\crampedscriptstyle x=xx}^{\crampedscriptstyle x=xx}$ \NC \NR
689 \LL
690 \stoptabulate
691 \stopbuffer
692
693 \getbuffer[demo]
694
695 Now we set the following parameters using \type {\setmathspacing} that accepts two
696 class identifier, a style and a value.
697
698 \startbuffer[setup]
699 \setmathspacing 0 3 \scriptstyle = 30mu
700 \setmathspacing 0 3 \scriptstyle = 30mu
701 \stopbuffer
702
703 \typebuffer[setup]
704
705 This gives a different result:
706
707 \start\getbuffer[setup,demo]\stop
708
709 But, as this is not what is expected (visually) we should say:
710
711 \startbuffer[setup]
712 \setmathspacing 0 3 \scriptstyle = 30mu
713 \setmathspacing 0 3 \scriptstyle = 30mu
714 \setmathspacing 0 3 \crampedscriptstyle = 30mu
715 \setmathspacing 0 3 \crampedscriptstyle = 30mu
716 \stopbuffer
717
718 \typebuffer[setup]
719
720 Now we get:
721
722 \start\getbuffer[setup,demo]\stop
723
724 \stopsection
725
726 \startsection[title={Math parameters}]
727
728 In \LUATEX, the font dimension parameters that \TEX\ used in math typesetting are
729 now accessible via primitive commands. In fact, refactoring of the math engine
730 has resulted in turning some hard codes properties into parameters.
731
732 {\em The next needs checking ...}
733
734 \starttabulate
735 \FL
736 \BC primitive name \BC description \NC \NR
737 \TL
738 \NC \type {\Umathquad} \NC the width of 18 mu's \NC \NR
739 \NC \type {\Umathaxis} \NC height of the vertical center axis of
740 the math formula above the baseline \NC \NR
741 \NC \type {\Umathoperatorsize} \NC minimum size of large operators in display mode \NC \NR
742 \NC \type {\Umathoverbarkern} \NC vertical clearance above the rule \NC \NR
743 \NC \type {\Umathoverbarrule} \NC the width of the rule \NC \NR
744 \NC \type {\Umathoverbarvgap} \NC vertical clearance below the rule \NC \NR
745 \NC \type {\Umathunderbarkern} \NC vertical clearance below the rule \NC \NR
746 \NC \type {\Umathunderbarrule} \NC the width of the rule \NC \NR
747 \NC \type {\Umathunderbarvgap} \NC vertical clearance above the rule \NC \NR
748 \NC \type {\Umathradicalkern} \NC vertical clearance above the rule \NC \NR
749 \NC \type {\Umathradicalrule} \NC the width of the rule \NC \NR
750 \NC \type {\Umathradicalvgap} \NC vertical clearance below the rule \NC \NR
751 \NC \type {\Umathradicaldegreebefore}\NC the forward kern that takes place before placement of
752 the radical degree \NC \NR
753 \NC \type {\Umathradicaldegreeafter} \NC the backward kern that takes place after placement of
754 the radical degree \NC \NR
755 \NC \type {\Umathradicaldegreeraise} \NC this is the percentage of the total height and depth of
756 the radical sign that the degree is raised by; it is
757 expressed in \type {percents}, so 60\% is expressed as the
758 integer $60$ \NC \NR
759 \NC \type {\Umathstackvgap} \NC vertical clearance between the two
760 elements in an \type {\atop} stack \NC \NR
761 \NC \type {\Umathstacknumup} \NC numerator shift upward in \type {\atop} stack \NC \NR
762 \NC \type {\Umathstackdenomdown} \NC denominator shift downward in \type {\atop} stack \NC \NR
763 \NC \type {\Umathfractionrule} \NC the width of the rule in a \type {\over} \NC \NR
764 \NC \type {\Umathfractionnumvgap} \NC vertical clearance between the numerator and the rule \NC \NR
765 \NC \type {\Umathfractionnumup} \NC numerator shift upward in \type {\over} \NC \NR
766 \NC \type {\Umathfractiondenomvgap} \NC vertical clearance between the denominator and the rule \NC \NR
767 \NC \type {\Umathfractiondenomdown} \NC denominator shift downward in \type {\over} \NC \NR
768 \NC \type {\Umathfractiondelsize} \NC minimum delimiter size for \type {\...withdelims} \NC \NR
769 \NC \type {\Umathlimitabovevgap} \NC vertical clearance for limits above operators \NC \NR
770 \NC \type {\Umathlimitabovebgap} \NC vertical baseline clearance for limits above operators \NC \NR
771 \NC \type {\Umathlimitabovekern} \NC space reserved at the top of the limit \NC \NR
772 \NC \type {\Umathlimitbelowvgap} \NC vertical clearance for limits below operators \NC \NR
773 \NC \type {\Umathlimitbelowbgap} \NC vertical baseline clearance for limits below operators \NC \NR
774 \NC \type {\Umathlimitbelowkern} \NC space reserved at the bottom of the limit \NC \NR
775 \NC \type {\Umathoverdelimitervgap} \NC vertical clearance for limits above delimiters \NC \NR
776 \NC \type {\Umathoverdelimiterbgap} \NC vertical baseline clearance for limits above delimiters \NC \NR
777 \NC \type {\Umathunderdelimitervgap} \NC vertical clearance for limits below delimiters \NC \NR
778 \NC \type {\Umathunderdelimiterbgap} \NC vertical baseline clearance for limits below delimiters \NC \NR
779 \NC \type {\Umathsubshiftdrop} \NC subscript drop for boxes and subformulas \NC \NR
780 \NC \type {\Umathsubshiftdown} \NC subscript drop for characters \NC \NR
781 \NC \type {\Umathsupshiftdrop} \NC superscript drop (raise, actually) for boxes and subformulas \NC \NR
782 \NC \type {\Umathsupshiftup} \NC superscript raise for characters \NC \NR
783 \NC \type {\Umathsubsupshiftdown} \NC subscript drop in the presence of a superscript \NC \NR
784 \NC \type {\Umathsubtopmax} \NC the top of standalone subscripts cannot be higher than this
785 above the baseline \NC \NR
786 \NC \type {\Umathsupbottommin} \NC the bottom of standalone superscripts cannot be less than
787 this above the baseline \NC \NR
788 \NC \type {\Umathsupsubbottommax} \NC the bottom of the superscript of a combined super- and subscript
789 be at least as high as this above the baseline \NC \NR
790 \NC \type {\Umathsubsupvgap} \NC vertical clearance between super- and subscript \NC \NR
791 \NC \type {\Umathspaceafterscript} \NC additional space added after a super- or subscript \NC \NR
792 \NC \type {\Umathconnectoroverlapmin}\NC minimum overlap between parts in an extensible recipe \NC \NR
793 \LL
794 \stoptabulate
795
796 In addition to the above official \OPENTYPE\ font parameters we have these (the
797 undefined will get presets, quite likely zero):
798
799 \starttabulate
800 \FL
801 \BC primitive name \BC description \NC \NR
802 \TL
803 \NC \type {\Umathconnectoroverlapmin} \NC \NC \NR
804 \NC \type {\Umathsubsupshiftdown} \NC \NC \NR
805 \NC \type {\Umathfractiondelsize} \NC \NC \NR
806 \NC \type {\Umathnolimitsupfactor} \NC a multiplier for the way limits are shifted up and down \NC \NR
807 \NC \type {\Umathnolimitsubfactor} \NC a multiplier for the way limits are shifted up and down \NC \NR
808 \NC \type {\Umathaccentbasedepth} \NC the complement of \type {\Umathaccentbaseheight} \NC \NR
809 \NC \type {\Umathflattenedaccentbasedepth} \NC the complement of \type {\Umathflattenedaccentbaseheight} \NC \NR
810 \NC \type {\Umathspacebeforescript} \NC \NC \NR
811 \NC \type {\Umathprimeraise} \NC \NC \NR
812 \NC \type {\Umathprimeraisecomposed} \NC \NC \NR
813 \NC \type {\Umathprimeshiftup} \NC the prime variant of \type {\Umathsupshiftup} \NC \NR
814 \NC \type {\Umathprimespaceafter} \NC the prescript variant of \type {\Umathspaceafterscript} \NC \NR
815 \NC \type {\Umathprimeshiftdrop} \NC the prime variant of \type {\Umathsupshiftdrop} \NC \NR
816 \NC \type {\Umathskeweddelimitertolerance} \NC \NC \NR
817 \NC \type {\Umathaccenttopshiftup} \NC the amount that a top accent is shifted up \NC \NR
818 \NC \type {\Umathaccentbottomshiftdown} \NC the amount that a bottom accent is shifted down \NC \NR
819 \NC \type {\Umathaccenttopovershoot} \NC \NC \NR
820 \NC \type {\Umathaccentbottomovershoot} \NC \NC \NR
821 \NC \type {\Umathaccentsuperscriptdrop} \NC \NC \NR
822 \NC \type {\Umathaccentsuperscriptpercent} \NC \NC \NR
823 \NC \type {\Umathaccentextendmargin} \NC margins added to automatically extended accents \NC \NR
824 \NC \type {\Umathflattenedaccenttopshiftup} \NC the amount that a wide top accent is shifted up \NC \NR
825 \NC \type {\Umathflattenedaccentbottomshiftdown} \NC the amount that a wide bottom accent is shifted down \NC \NR
826 \NC \type {\Umathdelimiterpercent} \NC \NC \NR
827 \NC \type {\Umathdelimitershortfall} \NC \NC \NR
828 \NC \type {\Umathradicalextensiblebefore} \NC \NC \NR
829 \NC \type {\Umathradicalextensibleafter} \NC \NC \NR
830 \LL
831 \stoptabulate
832
833 These relate to the font parameters and in \CONTEXT\ we assign some different
834 defaults and tweak them in the goodie files:
835
836 \starttabulate[|T|T|c|]
837 \FL
838 \BC font parameter \BC primitive name \BC default \NC \NR
839 \TL
840 \NC MinConnectorOverlap \NC \type {\Umathconnectoroverlapmin} \NC 0 \NC \NR
841 \NC SubscriptShiftDownWithSuperscript \NC \type {\Umathsubsupshiftdown} \NC inherited \NC \NR
842 \NC FractionDelimiterSize \NC \type {\Umathfractiondelsize} \NC undefined \NC \NR
843 \NC FractionDelimiterDisplayStyleSize \NC \type {\Umathfractiondelsize} \NC undefined \NC \NR
844 \NC NoLimitSubFactor \NC \type {\Umathnolimitsupfactor} \NC 0 \NC \NR
845 \NC NoLimitSupFactor \NC \type {\Umathnolimitsubfactor} \NC 0 \NC \NR
846 \NC AccentBaseDepth \NC \type {\Umathaccentbasedepth} \NC reserved \NC \NR
847 \NC FlattenedAccentBaseDepth \NC \type {\Umathflattenedaccentbasedepth} \NC reserved \NC \NR
848 \NC SpaceBeforeScript \NC \type {\Umathspacebeforescript} \NC 0 \NC \NR
849 \NC PrimeRaisePercent \NC \type {\Umathprimeraise} \NC 0 \NC \NR
850 \NC PrimeRaiseComposedPercent \NC \type {\Umathprimeraisecomposed} \NC 0 \NC \NR
851 \NC PrimeShiftUp \NC \type {\Umathprimeshiftup} \NC 0 \NC \NR
852 \NC PrimeShiftUpCramped \NC \type {\Umathprimeshiftup} \NC 0 \NC \NR
853 \NC PrimeSpaceAfter \NC \type {\Umathprimespaceafter} \NC 0 \NC \NR
854 \NC PrimeBaselineDropMax \NC \type {\Umathprimeshiftdrop} \NC 0 \NC \NR
855 \NC SkewedDelimiterTolerance \NC \type {\Umathskeweddelimitertolerance} \NC 0 \NC \NR
856 \NC AccentTopShiftUp \NC \type {\Umathaccenttopshiftup} \NC undefined \NC \NR
857 \NC AccentBottomShiftDown \NC \type {\Umathaccentbottomshiftdown} \NC undefined \NC \NR
858 \NC AccentTopOvershoot \NC \type {\Umathaccenttopovershoot} \NC 0 \NC \NR
859 \NC AccentBottomOvershoot \NC \type {\Umathaccentbottomovershoot} \NC 0 \NC \NR
860 \NC AccentSuperscriptDrop \NC \type {\Umathaccentsuperscriptdrop} \NC 0 \NC \NR
861 \NC AccentSuperscriptPercent \NC \type {\Umathaccentsuperscriptpercent} \NC 0 \NC \NR
862 \NC AccentExtendMargin \NC \type {\Umathaccentextendmargin} \NC 0 \NC \NR
863 \NC FlattenedAccentTopShiftUp \NC \type {\Umathflattenedaccenttopshiftup} \NC undefined \NC \NR
864 \NC FlattenedAccentBottomShiftDown \NC \type {\Umathflattenedaccentbottomshiftdown} \NC undefined \NC \NR
865 \NC DelimiterPercent \NC \type {\Umathdelimiterpercent} \NC 0 \NC \NR
866 \NC DelimiterShortfall \NC \type {\Umathdelimitershortfall} \NC 0 \NC \NR
867 \LL
868 \stoptabulate
869
870 These parameters not only provide a bit more control over rendering, they also
871 can be used in compensating issues in font, because no font is perfect. Some are
872 the side effects of experiments and they have CamelCase companions in the \type
873 {MathConstants} table. For historical reasons the names are a bit inconsistent as
874 some originate in \TEX\ so we prefer to keep those names. Not many users will
875 mess around with these font parameters anyway. \footnote {I wonder if some names
876 should change, so that decision is pending.}
877
878 Each of the parameters in this section can be set by a command like this:
879
880 \starttyping
881 \Umathquad\displaystyle=1em
882 \stoptyping
883
884 they obey grouping, and you can use \type {\the\Umathquad\displaystyle} if
885 needed.
886
887 There are quite some parameters that can be set and there are eight styles, which means a lot
888 of keying in. For that reason is is possible to set parameters groupwise:
889
890 \starttabulate[|l|c|c|c|c|c|c|c|c|]
891 \FL
892 \BC primitive name \BC D \BC D' \BC T \BC T' \BC S \BC S' \BC SS \BC SS' \NC \NR
893 \TL
894 \NC \type {\alldisplaystyles} \NC$+$\NC$+ $\NC \NC \NC \NC \NC \NC \NC \NR
895 \NC \type {\alltextstyles} \NC \NC \NC$+$\NC$+ $\NC \NC \NC \NC \NC \NR
896 \NC \type {\allscriptstyles} \NC \NC \NC \NC \NC$+$\NC$+ $\NC \NC \NC \NR
897 \NC \type {\allscriptscriptstyles} \NC \NC \NC \NC \NC \NC \NC$+ $\NC$+ $\NC \NR
898 \NC \type {\allmathstyles} \NC$+$\NC$+ $\NC$+$\NC$+ $\NC$+$\NC$+ $\NC$+ $\NC$+ $\NC \NR
899 \NC \type {\allmainstyles} \NC \NC \NC \NC \NC \NC \NC \NC \NC \NR
900 \NC \type {\allsplitstyles} \NC$+$\NC$+ $\NC$+$\NC$+ $\NC$-$\NC$- $\NC$- $\NC$- $\NC \NR
901 \NC \type {\allunsplitstyles} \NC \NC \NC \NC \NC$+$\NC$+ $\NC$+ $\NC$+ $\NC \NR
902 \NC \type {\alluncrampedstyles} \NC$+$\NC \NC$+$\NC \NC$+$\NC \NC$+ $\NC \NC \NR
903 \NC \type {\allcrampedstyles} \NC \NC$+ $\NC \NC$+ $\NC \NC$+ $\NC \NC$+ $\NC \NR
904 \LL
905 \stoptabulate
906
907 These groups are especially handy when you set up inter atom spacing, pre- and
908 post atom penalties and atom rules.
909
910 We already introduced the font specific math parameters but we tell abit more
911 about them and how they relate to the original \TEX\ font dimensions.
912
913 While it is nice to have these math parameters available for tweaking, it would
914 be tedious to have to set each of them by hand. For this reason, \LUATEX\
915 initializes a bunch of these parameters whenever you assign a font identifier to
916 a math family based on either the traditional math font dimensions in the font
917 (for assignments to math family~2 and~3 using \TFM|-|based fonts like \type
918 {cmsy} and \type {cmex}), or based on the named values in a potential \type
919 {MathConstants} table when the font is loaded via Lua. If there is a \type
920 {MathConstants} table, this takes precedence over font dimensions, and in that
921 case no attention is paid to which family is being assigned to: the \type
922 {MathConstants} tables in the last assigned family sets all parameters.
923
924 In the table below, the one|-|letter style abbreviations and symbolic tfm font
925 dimension names match those used in the \TeX book. Assignments to \typ
926 {\textfont} set the values for the cramped and uncramped display and text styles,
927 \typ {\scriptfont} sets the script styles, and \typ {\scriptscriptfont} sets the
928 scriptscript styles, so we have eight parameters for three font sizes. In the
929 \TFM\ case, assignments only happen in family~2 and family~3 (and of course only
930 for the parameters for which there are font dimensions).
931
932 Besides the parameters below, \LUATEX\ also looks at the \quote {space} font
933 dimension parameter. For math fonts, this should be set to zero.
934
935 \def\MathLine#1#2#3#4#5%
936 {\TB
937 \NC \llap{\high{\tx #2\enspace}}\tt \type {#1} \NC \tt #5 \NC \NR
938 \NC \tx #3 \NC \tt #4 \NC \NR}
939
940 \starttabulate[|l|l|]
941 \FL
942 \BC variable / style \BC tfm / opentype \NC \NR
943 \TL
944 \MathLine{\Umathaxis} {} {} {AxisHeight} {axis_height}
945 \MathLine{\Umathaccentbaseheight} {} {} {AccentBaseHeight} {xheight}
946 \MathLine{\Umathflattenedaccentbaseheight}{} {} {FlattenedAccentBaseHeight} {xheight}
947 \MathLine{\Umathoperatorsize} {6} {D, D'} {DisplayOperatorMinHeight} {\emdash}
948 \MathLine{\Umathfractiondelsize} {9} {D, D'} {FractionDelimiterDisplayStyleSize} {delim1}
949 \MathLine{\Umathfractiondelsize} {9} {T, T', S, S', SS, SS'}{FractionDelimiterSize} {delim2}
950 \MathLine{\Umathfractiondenomdown} {} {D, D'} {FractionDenominatorDisplayStyleShiftDown}{denom1}
951 \MathLine{\Umathfractiondenomdown} {} {T, T', S, S', SS, SS'}{FractionDenominatorShiftDown} {denom2}
952 \MathLine{\Umathfractiondenomvgap} {} {D, D'} {FractionDenominatorDisplayStyleGapMin} {3*default_rule_thickness}
953 \MathLine{\Umathfractiondenomvgap} {} {T, T', S, S', SS, SS'}{FractionDenominatorGapMin} {default_rule_thickness}
954 \MathLine{\Umathfractionnumup} {} {D, D'} {FractionNumeratorDisplayStyleShiftUp} {num1}
955 \MathLine{\Umathfractionnumup} {} {T, T', S, S', SS, SS'}{FractionNumeratorShiftUp} {num2}
956 \MathLine{\Umathfractionnumvgap} {} {D, D'} {FractionNumeratorDisplayStyleGapMin} {3*default_rule_thickness}
957 \MathLine{\Umathfractionnumvgap} {} {T, T', S, S', SS, SS'}{FractionNumeratorGapMin} {default_rule_thickness}
958 \MathLine{\Umathfractionrule} {} {} {FractionRuleThickness} {default_rule_thickness}
959 \MathLine{\Umathskewedfractionhgap} {} {} {SkewedFractionHorizontalGap} {math_quad/2}
960 \MathLine{\Umathskewedfractionvgap} {} {} {SkewedFractionVerticalGap} {math_x_height}
961 \MathLine{\Umathlimitabovebgap} {} {} {UpperLimitBaselineRiseMin} {big_op_spacing3}
962 \MathLine{\Umathlimitabovekern} {1} {} {0} {big_op_spacing5}
963 \MathLine{\Umathlimitabovevgap} {} {} {UpperLimitGapMin} {big_op_spacing1}
964 \MathLine{\Umathlimitbelowbgap} {} {} {LowerLimitBaselineDropMin} {big_op_spacing4}
965 \MathLine{\Umathlimitbelowkern} {1} {} {0} {big_op_spacing5}
966 \MathLine{\Umathlimitbelowvgap} {} {} {LowerLimitGapMin} {big_op_spacing2}
967 \MathLine{\Umathoverdelimitervgap} {} {} {StretchStackGapBelowMin} {big_op_spacing1}
968 \MathLine{\Umathoverdelimiterbgap} {} {} {StretchStackTopShiftUp} {big_op_spacing3}
969 \MathLine{\Umathunderdelimitervgap} {} {} {StretchStackGapAboveMin} {big_op_spacing2}
970 \MathLine{\Umathunderdelimiterbgap} {} {} {StretchStackBottomShiftDown} {big_op_spacing4}
971 \MathLine{\Umathoverbarkern} {} {} {OverbarExtraAscender} {default_rule_thickness}
972 \MathLine{\Umathoverbarrule} {} {} {OverbarRuleThickness} {default_rule_thickness}
973 \MathLine{\Umathoverbarvgap} {} {} {OverbarVerticalGap} {3*default_rule_thickness}
974 \MathLine{\Umathquad} {1} {} {<font_size(f)>} {math_quad}
975 \MathLine{\Umathradicalkern} {} {} {RadicalExtraAscender} {default_rule_thickness}
976 \MathLine{\Umathradicalrule} {2} {} {RadicalRuleThickness} {<not set>}
977 \MathLine{\Umathradicalvgap} {3} {D, D'} {RadicalDisplayStyleVerticalGap} {default_rule_thickness+abs(math_x_height)/4}
978 \MathLine{\Umathradicalvgap} {3} {T, T', S, S', SS, SS'}{RadicalVerticalGap} {default_rule_thickness+abs(default_rule_thickness)/4}
979 \MathLine{\Umathradicaldegreebefore} {2} {} {RadicalKernBeforeDegree} {<not set>}
980 \MathLine{\Umathradicaldegreeafter} {2} {} {RadicalKernAfterDegree} {<not set>}
981 \MathLine{\Umathradicaldegreeraise} {2,7}{} {RadicalDegreeBottomRaisePercent} {<not set>}
982 \MathLine{\Umathspaceafterscript} {4} {} {SpaceAfterScript} {script_space}
983 \MathLine{\Umathstackdenomdown} {} {D, D'} {StackBottomDisplayStyleShiftDown} {denom1}
984 \MathLine{\Umathstackdenomdown} {} {T, T', S, S', SS, SS'}{StackBottomShiftDown} {denom2}
985 \MathLine{\Umathstacknumup} {} {D, D'} {StackTopDisplayStyleShiftUp} {num1}
986 \MathLine{\Umathstacknumup} {} {T, T', S, S', SS, SS'}{StackTopShiftUp} {num3}
987 \MathLine{\Umathstackvgap} {} {D, D'} {StackDisplayStyleGapMin} {7*default_rule_thickness}
988 \MathLine{\Umathstackvgap} {} {T, T', S, S', SS, SS'}{StackGapMin} {3*default_rule_thickness}
989 \MathLine{\Umathsubshiftdown} {} {} {SubscriptShiftDown} {sub1}
990 \MathLine{\Umathsubshiftdrop} {} {} {SubscriptBaselineDropMin} {sub_drop}
991 \MathLine{\Umathsubsupshiftdown} {8} {} {SubscriptShiftDownWithSuperscript} {\emdash}
992 \MathLine{\Umathsubtopmax} {} {} {SubscriptTopMax} {abs(math_x_height*4)/5}
993 \MathLine{\Umathsubsupvgap} {} {} {SubSuperscriptGapMin} {4*default_rule_thickness}
994 \MathLine{\Umathsupbottommin} {} {} {SuperscriptBottomMin} {abs(math_x_height/4)}
995 \MathLine{\Umathsupshiftdrop} {} {} {SuperscriptBaselineDropMax} {sup_drop}
996 \MathLine{\Umathsupshiftup} {} {D} {SuperscriptShiftUp} {sup1}
997 \MathLine{\Umathsupshiftup} {} {T, S, SS,} {SuperscriptShiftUp} {sup2}
998 \MathLine{\Umathsupshiftup} {} {D', T', S', SS'} {SuperscriptShiftUpCramped} {sup3}
999 \MathLine{\Umathsupsubbottommax} {} {} {SuperscriptBottomMaxWithSubscript} {abs(math_x_height*4)/5}
1000 \MathLine{\Umathunderbarkern} {} {} {UnderbarExtraDescender} {default_rule_thickness}
1001 \MathLine{\Umathunderbarrule} {} {} {UnderbarRuleThickness} {default_rule_thickness}
1002 \MathLine{\Umathunderbarvgap} {} {} {UnderbarVerticalGap} {3*default_rule_thickness}
1003 \MathLine{\Umathconnectoroverlapmin} {5} {} {MinConnectorOverlap} {0}
1004 \LL
1005 \stoptabulate
1006
1007 A few notes:
1008
1009 \startitemize[n]
1010
1011 \startitem
1012 \OPENTYPE\ fonts set \typ {\Umathlimitabovekern} and \typ
1013 {\Umathlimitbelowkern} to zero and set \typ {\Umathquad} to the font size of
1014 the used font, because these are not supported in the \type {MATH} table.
1015 \stopitem
1016
1017 \startitem
1018 Traditional \TFM\ fonts do not set \typ {\Umathradicalrule} because \TEX82\
1019 uses the height of the radical instead. When this parameter is indeed not set
1020 when \LUATEX\ has to typeset a radical, a backward compatibility mode will
1021 kick in that assumes that an oldstyle \TEX\ font is used. Also, they do not
1022 set \typ {\Umathradicaldegreebefore}, \typ {\Umathradicaldegreeafter}, and \typ
1023 {\Umathradicaldegreeraise}. These are then automatically initialized to
1024 $5/18$quad, $-10/18$quad, and 60.
1025 \stopitem
1026
1027 \startitem
1028 If \TFM\ fonts are used, then the \typ {\Umathradicalvgap} is not set until
1029 the first time \LUATEX\ has to typeset a formula because this needs
1030 parameters from both family~2 and family~3. This provides a partial backward
1031 compatibility with \TEX82, but that compatibility is only partial: once the
1032 \typ {\Umathradicalvgap} is set, it will not be recalculated any more.
1033 \stopitem
1034
1035 \startitem
1036 When \TFM\ fonts are used a similar situation arises with respect to \typ
1037 {\Umathspaceafterscript}: it is not set until the first time \LUATEX\ has to
1038 typeset a formula. This provides some backward compatibility with \TEX82. But
1039 once the \typ {\Umathspaceafterscript} is set, \typ {\scriptspace} will never
1040 be looked at again.
1041 \stopitem
1042
1043 \startitem
1044 Traditional \TFM\ fonts set \typ {\Umathconnectoroverlapmin} to zero because
1045 \TEX82\ always stacks extensibles without any overlap.
1046 \stopitem
1047
1048 \startitem
1049 The \typ {\Umathoperatorsize} is only used in \typ {\displaystyle}, and is only
1050 set in \OPENTYPE\ fonts. In \TFM\ font mode, it is artificially set to one
1051 scaled point more than the initial attempt's size, so that always the \quote
1052 {first next} will be tried, just like in \TEX82.
1053 \stopitem
1054
1055 \startitem
1056 The \typ {\Umathradicaldegreeraise} is a special case because it is the only
1057 parameter that is expressed in a percentage instead of a number of scaled
1058 points.
1059 \stopitem
1060
1061 \startitem
1062 \typ {SubscriptShiftDownWithSuperscript} does not actually exist in the
1063 \quote {standard} \OPENTYPE\ math font Cambria, but it is useful enough to be
1064 added.
1065 \stopitem
1066
1067 \startitem
1068 \typ {FractionDelimiterDisplayStyleSize} and \typ {FractionDelimiterSize}
1069 do not actually exist in the \quote {standard} \OPENTYPE\ math font Cambria,
1070 but were useful enough to be added.
1071 \stopitem
1072
1073 \stopitemize
1074
1075 As this mostly refers to \LUATEX\ there is more to tell about how \LUAMETATEX\
1076 deals with it. However, it is enough to know that much more behavior is
1077 configurable.
1078
1079 You can let the engine ignore a parameter with \typ {\setmathignore}, like:
1080
1081 \starttyping
1082 \setmathignore \Umathspacebeforescript 1
1083 \setmathignore \Umathspaceafterscript 1
1084 \stoptyping
1085
1086 Be aware of the fact that a global setting can get unnoticed by users because
1087 there is no warning that some parameter is ignored.
1088
1089 There are a couple of parameters that don't relate to the font but are more generally
1090 influencing the appearances. Some were added for experimenting.
1091
1092 {\em This is not complete}
1093
1094 \starttabulate[|l|l|]
1095 \FL
1096 \BC primitive \BC meaning \NC \NR
1097 \TL
1098 \type {\Umathextrasubpreshift} \NC \NR
1099 \type {\Umathextrasubprespace} \NC \NR
1100 \type {\Umathextrasubshift} \NC \NR
1101 \type {\Umathextrasubspace} \NC \NR
1102 \type {\Umathextrasuppreshift} \NC \NR
1103 \type {\Umathextrasupprespace} \NC \NR
1104 \type {\Umathextrasupshift} \NC \NR
1105 \type {\Umathextrasupspace} \NC \NR
1106 \type {\Umathprimeshiftdrop} \NC \NR
1107 \LL
1108 \stoptabulate
1109
1110 \stopsection
1111
1112 \startsection[title={Math spacing}]
1113
1114 Besides the parameters mentioned in the previous sections, there are also
1115 primitives to control the math spacing table (as explained in Chapter~18 of the
1116 \TEX book). This happens per class pair. Because we have many possible classes,
1117 we no longer have the many primitives that \LUATEX\ has but you can define then
1118 using the generic \type {\setmathspacing} primitive:
1119
1120 \starttyping
1121 \def\Umathordordspacing {\setmathspacing 0 0 }
1122 \def\Umathordordopenspacing {\setmathspacing 0 4 }
1123 \stoptyping
1124
1125 These parameters are (normally) of type \type {\muskip}, so setting a parameter can
1126 be done like this:
1127
1128 \starttyping
1129 \setmathspacing 1 0 \displaystyle=4mu plus 2mu % op ord Umathopordspacing
1130 \stoptyping
1131
1132 The atom pairs known by the engine are all initialized by \type {initex} to the
1133 values mentioned in the table in Chapter~18 of the \TEX book.
1134
1135 For ease of use as well as for backward compatibility, \typ {\thinmuskip}, \typ
1136 {\medmuskip} and \typ {\thickmuskip} are treated specially. In their case a pointer
1137 to the corresponding internal parameter is saved, not the actual \type {\muskip}
1138 value. This means that any later changes to one of these three parameters will be
1139 taken into account. As a bonus we also introduced the \typ {\tinymuskip} and \typ
1140 {\pettymuskip} primitives, just because we consider these fundamental, but they
1141 are not assigned internally to atom spacing combinations.
1142
1143 In \LUAMETATEX\ we go a bit further. Any named dimension, glue and mu glue
1144 register as well as the constants with these properties can be bound to a pair by
1145 prefixing \typ {\setmathspacing} by \type {\inherited}.
1146
1147 Careful readers will realize that there are also primitives for the items marked
1148 \type {*} in the \TEX book. These will actually be used because we pose no
1149 restrictions. However, you can enforce the remapping rules to conform to the
1150 rules of \TEX\ (or yourself).
1151
1152 Every class has a set of spacing parameters and the more classes you define the more
1153 pairwise spacing you need to define. However, you can default to an existing class.
1154 By default all spacing is zero and you can get rid of the defaults inherited from
1155 good old \TEX\ with \typ {\resetmathspacing}. You can alias class spacing to an exiting
1156 class with \type {\letmathspacing}:
1157
1158 \starttyping
1159 \letmathspacing class displayclass textclass scriptclass scriptscriptclass
1160 \stoptyping
1161
1162 Instead you can copy spacing with \type {\copymathspacing}:
1163
1164 \starttyping
1165 \copymathspacing class parentclass
1166 \stoptyping
1167
1168 Specific paring happens with \type {\setmathspacing}:
1169
1170 \starttyping
1171 \setmathspacing leftclass rightclass style value
1172 \stoptyping
1173
1174 Unless we have a frozen parameter, the prefix \type {\inherited} makes it possible
1175 to have a more dynamic relationship: the used value resolves to the current value
1176 of the given register. Possible values are the usual mu skip register, a regular
1177 skip or dimension register, or just some mu skip value.
1178
1179 A similar set of primitives deals with rules. These remap pairs onto other pairs, so
1180 \typ {\setmathatomrule} looks like:
1181
1182 \starttyping
1183 \setmathatomrule oldleftclass oldrightclass newleftclass newrightclass
1184 \stoptyping
1185
1186 The \type {\letmathatomrule} and \type {\copymathatomrule} primitives take two
1187 classes where the second is the parent.
1188
1189 % Some primitives are still experimental and might evolve, like \type
1190 % {\letmathparent} and \type {\copymathparent} that take numbers as in:
1191 %
1192 % \starttyping
1193 % \letmathatomrule class spacingclass prepenaltyclass postpenaltyclass options reserved
1194 % \stoptyping
1195 %
1196 % Primitives like this were used when experimenting and when re use them in \CONTEXT\
1197 % eventually they will become stable.
1198
1199 The \type {\setmathprepenalty} and \type {\setmathpostpenalty} primitives take a
1200 class and penalty (integer) value. These are injected before and after atoms with
1201 the given class where a penalty of 10000 is a signal to ignore it.
1202
1203 The engine control options for a class can be set with \type {\setmathoptions}. The
1204 possible options are discussed elsewhere. This primitive takes a class number and
1205 an integer (bitset). For all these setters the \CONTEXT\ math setup gives examples.
1206
1207 Math is processed in two passes. The first pass is needed to intercept for
1208 instance \type {\over}, one of the few \TEX\ commands that actually has a
1209 preceding argument. There are often lots of curly braces used in math and these
1210 can result in a nested run of the math sub engine. However, you need to be aware
1211 of the fact that some properties are kind of global to a formula and the last
1212 setting (for instance a family switch) wins. This also means that a change (or
1213 again, the last one) in math parameters affects the whole formula. In
1214 \LUAMETATEX\ we have changed this model a bit. One can argue that this introduces
1215 an incompatibility but it's hard to imagine a reason for setting the parameters
1216 at the end of a formula run and assume that they also influence what goes in
1217 front.
1218
1219 \startbuffer
1220 $
1221 x \subscript {-}
1222 \frozen\Umathsubshiftdown\textstyle 0pt x \subscript {0}
1223 {\frozen\Umathsubshiftdown\textstyle 5pt x \subscript {5}}
1224 x \subscript {0}
1225 {\frozen\Umathsubshiftdown\textstyle 15pt x \subscript {15}}
1226 x \subscript {0}
1227 {\frozen\Umathsubshiftdown\textstyle 20pt x \subscript {20}}
1228 x \subscript {0}
1229 \frozen\Umathsubshiftdown\textstyle 10pt x \subscript {10}
1230 x \subscript {0}
1231 $
1232 \stopbuffer
1233
1234 \typebuffer
1235
1236 The \type {\frozen} prefix does the magic: it injects information in the
1237 math list about the set parameter.
1238
1239 In \LUATEX\ 1.10+ the last setting, the \type {10pt} drop wins, but in
1240 \LUAMETATEX\ you will see each local setting taking effect. The implementation
1241 uses a new node type, parameters nodes, so you might encounter these in an
1242 unprocessed math list. The result looks as follows:
1243
1244 \blank \getbuffer \blank
1245
1246 The \type {\mathatom} primitive is the generic one and it accepts a couple of
1247 keywords:
1248
1249 {\em to be checked}
1250
1251 \starttabulate[|lT|l|l|]
1252 \FL
1253 \BC keyword \BC argument \NC meaning \NC \NR
1254 \TL
1255 \NC attr \NC int int \NC attributes to be applied to this atom \NC \NR
1256 \NC leftclass \NC class \NC the left edge class that determines spacing etc \NC \NR
1257 \NC rightclass \NC class \NC the right edge class that determines spacing etc \NC \NR
1258 \NC class \NC class \NC the general class \NC \NR
1259 \NC unpack \NC \NC unpack this atom in inline math \NC \NR
1260 \NC source \NC int \NC a symbolic index of the resulting box \NC \NR
1261 \NC textfont \NC \NC use the current text font \NC \NR
1262 \NC mathfont \NC \NC use the current math font \NC \NR
1263 \NC limits \NC \NC put scripts on top and below \NC \NR
1264 \NC nolimits \NC \NC force scripts to be postscripts \NC \NR
1265 \NC nooverflow \NC \NC keep (extensible) within target dimensions \NC \NR
1266 \NC options \NC int \NC bitset with options \NC \NR
1267 \NC void \NC \NC discard content and ignore dimensions \NC \NR
1268 \NC phantom \NC \NC discard content but retain dimensions \NC \NR
1269 \LL
1270 \stoptabulate
1271
1272 To what extend the options kick in depends on the class as well where and how the
1273 atom is used.
1274
1275 The original \TEX\ engines has three atom modifiers: \type {\displaylimits}, \type
1276 {\limits}, and \type {\nolimits}. These look back to the last atom and set a limit
1277 related signal. Just to be consistent we have some more of that: \typ
1278 {\Umathadapttoleft}, \typ {\Umathadapttoright}, \typ {\Umathuseaxis}, \typ
1279 {\Umathnoaxis}, \typ {\Umathphantom}, \typ {\Umathvoid}, \typ {\Umathsource}, \typ
1280 {\Umathopenupheight}, \typ {\Umathopenupdepth}, \typ {\Umathlimits}, \typ
1281 {\Umathnolimits}. The last two are equivalent to the lowercase ones with the
1282 similar names. Al these modifiers are cheap primitives and one can wonder if they
1283 are needed but that also now also applies to the original three. We could stick
1284 to one modifier that takes an integer but let's not diverge too much from the
1285 original concept.
1286
1287 The \type {\nonscript} primitive injects a glue node that signals that the next
1288 glue is to be ignored when we are in script or scriptscript mode. The \typ
1289 {\noatomruling} does the same but this time the signal is that no inter|-|atom
1290 rules need to be applied.
1291
1292 \stopsection
1293
1294 \startsection[title={Fonts}]
1295
1296 When we started with \LUATEX\ there was only Cambria as \OPENTYPE\ math font.
1297 However, as soon as we could load a wide font, and basic math handling was
1298 adapted to handle a fonts passed via \LUA, in \CONTEXT\ we switched to \OPENTYPE\
1299 math exclusively. This was possible because at the same time virtual fonts were
1300 integrated in the engine. Because the way \TEX\ approaches math differs from
1301 \OPENTYPE\ we had code paths that could handle both and were somewhat complex.
1302 Later these code paths were split more visible and detailed control over specific
1303 features was introduced. The reason for this came from the fact that the Latin
1304 Modern Math as well as additional fonts were a mix of \OPENTYPE\ and traditional
1305 (metric wise). Inconsistencies were handles by \CONTEXT\ when loading and passing
1306 fonts and runtime patching was our way out. There is also some juggling of math
1307 lists in \LUA\ involved.
1308
1309 In \LUAMETATEX\ much more control was added alongside many new features in
1310 rendering math. Although by making decisions with respect to fonts in the end we
1311 could potentially use a much simpler code base. However we keep what we have
1312 because we need to write articles, manuals, presentations etc.\ that show the
1313 differences. We settled on the fact that fonts are what they are and won't
1314 change. Font specific tweaks are dealt with in a math font goodie file: most
1315 tweaks are generic and applied to all fonts, some are optional, and many can be
1316 tuned by parameters. In the end one can argue that we render math a bit different
1317 due to different font and character properties; for instance we got rid of italic
1318 correction and often deal with kerning, variants and extensibles a bit different.
1319
1320 A consequence of this is that we will not describe in detail what happens in the
1321 math engine, first of all because we don't expect other macro packages to follow
1322 \CONTEXT\ in the way it deals with rendering math and the \LUATEX\ kind of hybrid
1323 approach is likely good enough because after all there was never demand for more
1324 advanced math rendering nor attempts to extend the engines in that area. This is
1325 why \LUAMETATEX\ tries to be \LUATEX\ compatible when it comes to the basics
1326 required by potential other usage than \CONTEXT. However, we might eventually
1327 drop some eight bit font related features, simply because one can pass them
1328 wrapped in a \UNICODE\ and \OPENTYPE\ math disguise. This is to be decided.
1329
1330 The process of upgrading math is described in manuals, articles and presentations
1331 by the authors. There one can find a discussion about decisions made.
1332
1333 \stopsection
1334
1335 \startsection[title={Scripts}]
1336
1337 \startbuffer[show:3]
1338 \startlinecorrection[blank]
1339 \scale[s=3]\bgroup
1340 \switchtobodyfont[modern]%
1341 \showmakeup[glyph,continuation]%
1342 \getbuffer
1343 \egroup
1344 \stoplinecorrection
1345 \stopbuffer
1346
1347 The \LUAMETATEX\ engine has native support for prescripts and primes. Here we
1348 dive a bit into the former. We start with a regular sub and superscript example:
1349
1350 \startbuffer
1351 \im { F _ {a} ^ {b} }
1352 \stopbuffer
1353
1354 \typebuffer \getbuffer[show:3]
1355
1356 Depending on how the font is set up, a subscript might get a (negative) kern.
1357 Kerning at the top left of the nucleus is ignored, because one never sees it in
1358 for instance chemistry:
1359
1360 \startbuffer
1361 \im { F _ {a} ^ {b} ___ {c} ^^^ {d} }
1362 \stopbuffer
1363
1364 \typebuffer \getbuffer[show:3]
1365
1366 There can be multiple pre- and postscripts. In traditional \TEX\ one sometimes
1367 has to inject fake nuclei but in \LUAMETATEX\ this is done automatically. These
1368 are called continuation atoms.
1369
1370 \startbuffer
1371 \im { F
1372 _ {a} ^ {b}
1373 _ {a} ^ {b}
1374 } \quad
1375 \im { F
1376 _ {a} ^ {b} ___ {c} ^^^ {d}
1377 _ {a} ^ {b} ___ {c} ^^^ {d}
1378 }
1379 \stopbuffer
1380
1381 \typebuffer \getbuffer[show:3]
1382
1383 You will notice that the subscript no longer aligns, a feature that deals with
1384 rendering tensors. these features are controlled by the (four byte) \prm
1385 {mathdoublescriptmode} parameter. In \CONTEXT\ this one is set up as follows:
1386
1387 \starttyping
1388 \mathdoublescriptmode
1389 "\tohexadecimal\numexpr
1390 \inheritclassdoublescriptmodecode
1391 + \discardshapekerndoublescriptmodecode
1392 + \realignscriptsdoublescriptmodecode
1393 + \reorderprescriptsdoublescriptmodecode
1394 \relax
1395 \tohexadecimal\mathcontinuationcode % 2 bytes
1396 \tohexadecimal\mathcontinuationcode % 2 bytes
1397 \tohexadecimal\mathcontinuationcode % 2 bytes
1398 \stoptyping
1399
1400 The first byte set the options, the second the subtype of the continuation node
1401 and the last two set the left and right class values. In \CONTEXT\ we have a
1402 dedicated continuation class (\mono{0x\tohexadecimal\mathcontinuationcode}). So,
1403 current value of this parameter is \mono{0x\tohexadecimal\mathdoublescriptmode},
1404 but we can do this:
1405
1406 \startbuffer[temp]
1407 \advance\mathdoublescriptmode
1408 -"\tohexadecimal\discardshapekerndoublescriptmodecode 000000
1409 \stopbuffer
1410
1411 \typebuffer[temp]
1412
1413 and get:
1414
1415 {\getbuffer[temp,show:3]}
1416
1417 \startbuffer
1418 \im { F
1419 _ {a} ^ {b}
1420 ___ {c}
1421 ___ {c}
1422 }
1423 \stopbuffer
1424
1425 \typebuffer \getbuffer[show:3]
1426
1427 The next set of examples demonstrates that the \type {\noscript} injects a bogus
1428 atom that breaks the alignment chain.
1429
1430 \startbuffer
1431 \im { F ^ {a}
1432 ___ {a} ___ {a} ___ {a}
1433 } \quad
1434 \im { F ^ {a}
1435 \noscript ___ {a} ___ {a} ___ {a}
1436 } \quad
1437 \im { F ^ {a}
1438 ___ {a} \noscript ___ {a} ___ {a}
1439 } \quad
1440 \im { F ^ {a}
1441 ___ {a} ___ {a} \noscript ___ {a} ___ {a}
1442 }
1443 \stopbuffer
1444
1445 \typebuffer \getbuffer[show:3]
1446
1447 \startbuffer
1448 \im { F ^ {a} _{a}
1449 ___ {a} ___ {a} ___ {a}
1450 } \quad
1451 \im { F ^ {a} _{a}
1452 \noscript ___ {a} ___ {a} ___ {a}
1453 } \quad
1454 \im { F ^ {a} _{a}
1455 ___ {a} \noscript ___ {a} ___ {a}
1456 } \quad
1457 \im { F ^ {a} _{a}
1458 ___ {a} ___ {a} \noscript ___ {a} ___ {a}
1459 }
1460 \stopbuffer
1461
1462 \typebuffer \getbuffer[show:3]
1463
1464 A more useful application of this is the following:
1465
1466 \startbuffer
1467 \im {F
1468 __ {a} \noscript
1469 ^^ {b} \noscript
1470 ^^ {c} \noscript
1471 __ {d}
1472 }
1473 \stopbuffer
1474
1475 \typebuffer \getbuffer[show:3]
1476
1477 % \startbuffer
1478 % \m { F _ {c} }
1479 % \m { F _ {c} _ {d} }
1480 % \m { F _ {c} \noscript _ {d} \noscript _ {e} }
1481 % \stopbuffer
1482 %
1483 % \typebuffer \getbuffer[show:3]
1484 %
1485 % \startbuffer
1486 % \m { F ^ {c} }
1487 % \m { F ^ {c} ^ {d} }
1488 % \m { F ^ {c} \noscript ^ {d} \noscript ^ {e} }
1489 % \stopbuffer
1490 %
1491 % \typebuffer \getbuffer[show:3]
1492 %
1493 % \startbuffer
1494 % \m { F _c ^ {c} }
1495 % \m { F _c ^ {c} _ {d} ^ {d} }
1496 % \m { F _c ^ {c} \noscript _ {d} ^ {d} \noscript ^ {e} _ {e} }
1497 % \stopbuffer
1498 %
1499 % \typebuffer \getbuffer[show:3]
1500 %
1501 % \startbuffer
1502 % \m { F ___ {c} }
1503 % \m { F ___ {c} ___ {d} }
1504 % \m { F ___ {c} \noscript ___ {d} \noscript ___ {e} }
1505 % \stopbuffer
1506 %
1507 % \typebuffer \getbuffer[show:3]
1508 %
1509 % \startbuffer
1510 % \m { F ^^^ {c} }
1511 % \m { F ^^^ {c} ^^^ {d} }
1512 % \m { F ^^^ {c} \noscript ^^^ {d} \noscript ^^^ {e} }
1513 % \stopbuffer
1514 %
1515 % \typebuffer \getbuffer[show:3]
1516 %
1517 % \startbuffer
1518 % \m { F _ {c} ^ {c} }
1519 % \m { F _ {c} ^ {c} _ {d} ^ {d} }
1520 % \m { F _ {c} ^ {c} \noscript _ {d} ^ {d} \noscript ^ {e} _ {e} }
1521 % \stopbuffer
1522 %
1523 % \typebuffer \getbuffer[show:3]
1524 %
1525 % \startbuffer
1526 % \m { F
1527 % ^{a} _{d} ^^^{d} ___ {d} \noscript
1528 % ^{b} _{e} ^^^{e} ___ {e} \noscript
1529 % ^{c} _{f} ^^^{f} ___ {f}
1530 % }
1531 % \stopbuffer
1532 %
1533 % \typebuffer \getbuffer[show:3]
1534 %
1535 % \startbuffer
1536 % \m { F
1537 % ^^^{d} ___ {d}
1538 % ^ {a} _ {d} \noscript
1539 % ^ {a} _ {d} \noscript
1540 % ^ {c} _ {f}
1541 % }
1542 % \stopbuffer
1543 %
1544 % \typebuffer \getbuffer[show:3]
1545 %
1546 % \startbuffer
1547 % \m { F
1548 % ___ {d}
1549 % _ {f}
1550 % }
1551 % \m { F
1552 % ___ {d} \noscript
1553 % _ {f}
1554 % }
1555 % \stopbuffer
1556 %
1557 % \typebuffer \getbuffer[show:3]
1558 %
1559 % \startbuffer
1560 % \m { F
1561 % ___ {a}
1562 % _ {b} \noscript
1563 % _ {c} \noscript
1564 % _ {d} \noscript
1565 % _ {e}
1566 % }
1567 % \stopbuffer
1568 %
1569 % \typebuffer \getbuffer[show:3]
1570
1571 \stopsection
1572
1573 \stopdocument