3 \environment luatex-style
4 \environment luatex-logos
6 \startcomponent luatex-math
8 \startchapter[reference=math,title=
{Math
}]
10 The handling of mathematics in
\LUATEX\ differs quite a bit from how
\TEX82 (and
11 therefore
\PDFTEX) handles math. First,
\LUATEX\ adds primitives and extends some
12 others so that
\UNICODE\ input can be used easily. Second, all of
\TEX82's
13 internal special values (for example for operator spacing) have been made
14 accessible and changeable via control sequences. Third, there are extensions that
15 make it easier to use
\OPENTYPE\ math fonts. And finally, there are some
16 extensions that have been proposed in the past that are now added to the engine.
18 \section{The current math style
}
20 It is possible to discover the math style that will be used for a formula in an
21 expandable fashion (while the math list is still being read). To make this
22 possible,
\LUATEX\ adds the new primitive:
\type {\mathstyle}. This is a
\quote
23 {convert command
} like e.g.
\type {\romannumeral}: its value can only be read,
26 \subsection{\type {\mathstyle}}
28 The returned value is between
0 and
7 (in math mode), or $-
1$ (all other modes).
29 For easy testing, the eight math style commands have been altered so that the can
30 be used as numeric values, so you can write code like this:
33 \ifnum\mathstyle=
\textstyle
34 \message{normal text style
}
35 \else \ifnum\mathstyle=
\crampedtextstyle
36 \message{cramped text style
}
40 \subsection{\type {\Ustack}}
42 There are a few math commands in
\TEX\ where the style that will be used is not
43 known straight from the start. These commands (
\type {\over},
\type {\atop},
44 \type {\overwithdelims},
\type {\atopwithdelims}) would therefore normally return
45 wrong values for
\type {\mathstyle}. To fix this,
\LUATEX\ introduces a special
46 prefix command:
\type {\Ustack}:
52 The
\type {\Ustack} command will scan the next brace and start a new math group
53 with the correct (numerator) math style.
55 \section{Unicode math characters
}
57 Character handling is now extended up to the full
\UNICODE\ range (the
\type {\U}
58 prefix), which is compatible with
\XETEX.
60 The math primitives from
\TEX\ are kept as they are, except for the ones that
61 convert from input to math commands:
\type {mathcode
}, and
\type {delcode
}. These
62 two now allow for a
21-bit character argument on the left hand side of the equals
65 Some of the new
\LUATEX\ primitives read more than one separate value. This is
66 shown in the tables below by a plus sign in the second column.
68 The input for such primitives would look like this:
71 \def\overbrace{\Umathaccent 0 1 "
23DE
}
74 Altered
\TEX82 primitives:
76 \starttabulate[|l|l|l|
]
77 \NC \bf primitive
\NC \bf value range (in hex)
\NC \NR
78 \NC \type {\mathcode} \NC 0--
10FFFF =
0--
8000 \NC \NR
79 \NC \type {\delcode} \NC 0--
10FFFF =
0--FFFFFF
\NC \NR
84 \starttabulate[|l|l|l|
]
85 \NC \bf primitive
\NC \bf value range (in hex)
\NC \NR
86 \NC \type {\mathchardef} \NC 0--
8000 \NC \NR
87 \NC \type {\mathchar} \NC 0--
7FFF
\NC \NR
88 \NC \type {\mathaccent} \NC 0--
7FFF
\NC \NR
89 \NC \type {\delimiter} \NC 0--
7FFFFFF
\NC \NR
90 \NC \type {\radical} \NC 0--
7FFFFFF
\NC \NR
93 For practical reasons
\type {\mathchardef} will silently accept values larger
94 that
\type {0x8000} and interpret it as
\type {\Umathcharnumdef}. This is needed
95 to satisfy older macro packages.
97 New primitives that are compatible with
\XETEX:
99 \starttabulate[|l|l|l|l|
]
100 \NC \bf primitive
\NC \bf value range (in hex)
\NC \NR
101 \NC \type {\Umathchardef} \NC 0+
0+
0--
7+FF+
10FFFF$^
1$
\NC \NR
102 \NC \type {\Umathcharnumdef}$^
5$
\NC -
80000000--
7FFFFFFF$^
3$
\NC \NR
103 \NC \type {\Umathcode} \NC 0--
10FFFF =
0+
0+
0--
7+FF+
10FFFF$^
1$
\NC \NR
104 \NC \type {\Udelcode} \NC 0--
10FFFF =
0+
0--FF+
10FFFF$^
2$
\NC \NR
105 \NC \type {\Umathchar} \NC 0+
0+
0--
7+FF+
10FFFF
\NC \NR
106 \NC \type {\Umathaccent} \NC 0+
0+
0--
7+FF+
10FFFF$^
{2,
4}$
\NC \NR
107 \NC \type {\Udelimiter} \NC 0+
0+
0--
7+FF+
10FFFF$^
2$
\NC \NR
108 \NC \type {\Uradical} \NC 0+
0--FF+
10FFFF$^
2$
\NC \NR
109 \NC \type {\Umathcharnum} \NC -
80000000--
7FFFFFFF$^
3$
\NC \NR
110 \NC \type {\Umathcodenum} \NC 0--
10FFFF = -
80000000--
7FFFFFFF$^
3$
\NC \NR
111 \NC \type {\Udelcodenum} \NC 0--
10FFFF = -
80000000--
7FFFFFFF$^
3$
\NC \NR
114 Specifications typically look like:
117 \Umathchardef\xx="
1"
0"
456
118 \Umathcode 123="
1"
0"
789
121 Note
1: The new primitives that deal with delimiter-style objects do not set up a
122 \quote {large family
}. Selecting a suitable size for display purposes is expected
123 to be dealt with by the font via the
\type {\Umathoperatorsize} parameter (more
124 information can be found in a following section).
126 Note
2: For these three primitives, all information is packed into a single
127 signed integer. For the first two (
\type {\Umathcharnum} and
\type {\Umathcodenum}),
128 the lowest
21 bits are the character code, the
3 bits above that represent the
129 math class, and the family data is kept in the topmost bits (This means that the
130 values for math families
128--
255 are actually negative). For
\type {\Udelcodenum}
131 there is no math class; the math family information is stored in the bits
132 directly on top of the character code. Using these three commands is not as
133 natural as using the two- and three-value commands, so unless you know exactly
134 what you are doing and absolutely require the speedup resulting from the faster
135 input scanning, it is better to use the verbose commands instead.
137 Note
3: The
\type {\Umathaccent} command accepts optional keywords to control
138 various details regarding math accents. See
\in {section
} [mathacc
] below for
141 New primitives that exist in
\LUATEX\ only (all of these will be explained
142 in following sections):
144 \starttabulate[|l|l|l|l|
]
145 \NC \bf primitive
\NC \bf value range (in hex)
\NC \NR
146 \NC \type {\Uroot} \NC 0+
0--FF+
10FFFF$^
2$
\NC \NR
147 \NC \type {\Uoverdelimiter} \NC 0+
0--FF+
10FFFF$^
2$
\NC \NR
148 \NC \type {\Uunderdelimiter} \NC 0+
0--FF+
10FFFF$^
2$
\NC \NR
149 \NC \type {\Udelimiterover} \NC 0+
0--FF+
10FFFF$^
2$
\NC \NR
150 \NC \type {\Udelimiterunder} \NC 0+
0--FF+
10FFFF$^
2$
\NC \NR
153 \section{Cramped math styles
}
155 \LUATEX\ has four new primitives to set the cramped math styles directly:
161 \crampedscriptscriptstyle
164 These additional commands are not all that valuable on their own, but they come
165 in handy as arguments to the math parameter settings that will be added shortly.
167 In Eijkhouts
\quotation {\TEX\ by Topic
} the rules for handling styles in scripts
168 are described as follows:
172 In any style superscripts and subscripts are taken from the next smaller style.
173 Exception: in display style they are taken in script style.
176 Subscripts are always in the cramped variant of the style; superscripts are only
177 cramped if the original style was cramped.
180 In an
\type {..
\over..
} formula in any style the numerator and denominator are
181 taken from the next smaller style.
184 The denominator is always in cramped style; the numerator is only in cramped
185 style if the original style was cramped.
188 Formulas under a
\type {\sqrt} or
\type {\overline} are in cramped style.
192 In
\LUATEX\ one can set the styles in more detail which means that you sometimes
193 have to set both normal and cramped styles to get the effect you want. If we
194 force styles in the script using
\type {\scriptstyle} and
\type {\crampedscriptstyle}
199 \NC default
\NC $b_
{x=xx
}^
{x=xx
}$
\NC \NR
200 \NC script
\NC $b_
{\scriptstyle x=xx
}^
{\scriptstyle x=xx
}$
\NC \NR
201 \NC crampedscript
\NC $b_
{\crampedscriptstyle x=xx
}^
{\crampedscriptstyle x=xx
}$
\NC \NR
207 Now we set the following parameters
210 \Umathordrelspacing\scriptstyle=
30mu
211 \Umathordordspacing\scriptstyle=
30mu
218 \start\getbuffer[setup,demo
]\stop
220 But, as this is not what is expected (visually) we should say:
223 \Umathordrelspacing\scriptstyle=
30mu
224 \Umathordordspacing\scriptstyle=
30mu
225 \Umathordrelspacing\crampedscriptstyle=
30mu
226 \Umathordordspacing\crampedscriptstyle=
30mu
233 \start\getbuffer[setup,demo
]\stop
235 \section{Math parameter settings
}
237 In
\LUATEX, the font dimension parameters that
\TEX\ used in math typesetting are
238 now accessible via primitive commands. In fact, refactoring of the math engine
239 has resulted in many more parameters than were accessible before.
242 \NC \bf primitive name
\NC \bf description
\NC \NR
243 \NC \type {\Umathquad} \NC the width of
18 mu's
\NC \NR
244 \NC \type {\Umathaxis} \NC height of the vertical center axis of
245 the math formula above the baseline
\NC \NR
246 \NC \type {\Umathoperatorsize} \NC minimum size of large operators in display mode
\NC \NR
247 \NC \type {\Umathoverbarkern} \NC vertical clearance above the rule
\NC \NR
248 \NC \type {\Umathoverbarrule} \NC the width of the rule
\NC \NR
249 \NC \type {\Umathoverbarvgap} \NC vertical clearance below the rule
\NC \NR
250 \NC \type {\Umathunderbarkern} \NC vertical clearance below the rule
\NC \NR
251 \NC \type {\Umathunderbarrule} \NC the width of the rule
\NC \NR
252 \NC \type {\Umathunderbarvgap} \NC vertical clearance above the rule
\NC \NR
253 \NC \type {\Umathradicalkern} \NC vertical clearance above the rule
\NC \NR
254 \NC \type {\Umathradicalrule} \NC the width of the rule
\NC \NR
255 \NC \type {\Umathradicalvgap} \NC vertical clearance below the rule
\NC \NR
256 \NC \type {\Umathradicaldegreebefore}\NC the forward kern that takes place before placement of
257 the radical degree
\NC \NR
258 \NC \type {\Umathradicaldegreeafter} \NC the backward kern that takes place after placement of
259 the radical degree
\NC \NR
260 \NC \type {\Umathradicaldegreeraise} \NC this is the percentage of the total height and depth of
261 the radical sign that the degree is raised by. It is
262 expressed in
\type {percents
}, so
60\% is expressed as the
263 integer $
60$.
\NC \NR
264 \NC \type {\Umathstackvgap} \NC vertical clearance between the two
265 elements in a
\type {\atop} stack
\NC \NR
266 \NC \type {\Umathstacknumup} \NC numerator shift upward in
\type {\atop} stack
\NC \NR
267 \NC \type {\Umathstackdenomdown} \NC denominator shift downward in
\type {\atop} stack
\NC \NR
268 \NC \type {\Umathfractionrule} \NC the width of the rule in a
\type {\over} \NC \NR
269 \NC \type {\Umathfractionnumvgap} \NC vertical clearance between the numerator and the rule
\NC \NR
270 \NC \type {\Umathfractionnumup} \NC numerator shift upward in
\type {\over} \NC \NR
271 \NC \type {\Umathfractiondenomvgap} \NC vertical clearance between the denominator and the rule
\NC \NR
272 \NC \type {\Umathfractiondenomdown} \NC denominator shift downward in
\type {\over} \NC \NR
273 \NC \type {\Umathfractiondelsize} \NC minimum delimiter size for
\type {\...withdelims
} \NC \NR
274 \NC \type {\Umathlimitabovevgap} \NC vertical clearance for limits above operators
\NC \NR
275 \NC \type {\Umathlimitabovebgap} \NC vertical baseline clearance for limits above operators
\NC \NR
276 \NC \type {\Umathlimitabovekern} \NC space reserved at the top of the limit
\NC \NR
277 \NC \type {\Umathlimitbelowvgap} \NC vertical clearance for limits below operators
\NC \NR
278 \NC \type {\Umathlimitbelowbgap} \NC vertical baseline clearance for limits below operators
\NC \NR
279 \NC \type {\Umathlimitbelowkern} \NC space reserved at the bottom of the limit
\NC \NR
280 \NC \type {\Umathoverdelimitervgap} \NC vertical clearance for limits above delimiters
\NC \NR
281 \NC \type {\Umathoverdelimiterbgap} \NC vertical baseline clearance for limits above delimiters
\NC \NR
282 \NC \type {\Umathunderdelimitervgap} \NC vertical clearance for limits below delimiters
\NC \NR
283 \NC \type {\Umathunderdelimiterbgap} \NC vertical baseline clearance for limits below delimiters
\NC \NR
284 \NC \type {\Umathsubshiftdrop} \NC subscript drop for boxes and subformulas
\NC \NR
285 \NC \type {\Umathsubshiftdown} \NC subscript drop for characters
\NC \NR
286 \NC \type {\Umathsupshiftdrop} \NC superscript drop (raise, actually) for boxes and subformulas
\NC \NR
287 \NC \type {\Umathsupshiftup} \NC superscript raise for characters
\NC \NR
288 \NC \type {\Umathsubsupshiftdown} \NC subscript drop in the presence of a superscript
\NC \NR
289 \NC \type {\Umathsubtopmax} \NC the top of standalone subscripts cannot be higher than this
290 above the baseline
\NC \NR
291 \NC \type {\Umathsupbottommin} \NC the bottom of standalone superscripts cannot be less than
292 this above the baseline
\NC \NR
293 \NC \type {\Umathsupsubbottommax} \NC the bottom of the superscript of a combined super- and subscript
294 be at least as high as this above the baseline
\NC \NR
295 \NC \type {\Umathsubsupvgap} \NC vertical clearance between super- and subscript
\NC \NR
296 \NC \type {\Umathspaceafterscript} \NC additional space added after a super- or subscript
\NC \NR
297 \NC \type {\Umathconnectoroverlapmin}\NC minimum overlap between parts in an extensible recipe
\NC \NR
300 Each of the parameters in this section can be set by a command like this:
303 \Umathquad\displaystyle=
1em
306 they obey grouping, and you can use
\type {\the\Umathquad\displaystyle} if
309 \section{Skips around display math
}
311 The injection of
\type {\abovedisplayskip} and
\type {\belowdisplayskip} is not
312 symmetrical. An above one is always inserted, also when zero, but the below is
313 only inserted when larger than zero. Especially the later mkes it sometimes hard
314 to fully control spacing. Therefore
\LUATEX\ comes with a new directive:
\type
315 {\mathdisplayskipmode}. The following values apply:
318 \NC 0 \NC normal
\TEX\ behaviour: always above, only below when larger than zero
\NC \NR
319 \NC 1 \NC always
\NC \NR
320 \NC 2 \NC only when not zero
\NC \NR
321 \NC 3 \NC never, not even when not zero
\NC \NR
324 \section{Font-based Math Parameters
}
326 While it is nice to have these math parameters available for tweaking, it would
327 be tedious to have to set each of them by hand. For this reason,
\LUATEX\
328 initializes a bunch of these parameters whenever you assign a font identifier to
329 a math family based on either the traditional math font dimensions in the font
330 (for assignments to math family~
2 and~
3 using
\TFM|-|based fonts like
\type
331 {cmsy
} and
\type {cmex
}), or based on the named values in a potential
\type
332 {MathConstants
} table when the font is loaded via Lua. If there is a
\type
333 {MathConstants
} table, this takes precedence over font dimensions, and in that
334 case no attention is paid to which family is being assigned to: the
\type
335 {MathConstants
} tables in the last assigned family sets all parameters.
337 In the table below, the one|-|letter style abbreviations and symbolic tfm font
338 dimension names match those using in the
\TeX book. Assignments to
\type
339 {\textfont} set the values for the cramped and uncramped display and text styles.
340 Use
\type {\scriptfont} for the script styles, and
\type {\scriptscriptfont} for the
341 scriptscript styles (totalling eight parameters for three font sizes). In the
342 \TFM\ case, assignments only happen in family~
2 and family~
3 (and of course only
343 for the parameters for which there are font dimensions).
345 Besides the parameters below,
\LUATEX\ also looks at the
\quote {space
} font
346 dimension parameter. For math fonts, this should be set to zero.
350 \switchtobodyfont[8pt
]
352 \starttabulate[|l|l|l|p|
]
353 \NC \bf variable
\NC \bf style
\NC \bf default value opentype
\NC \bf default value tfm
\NC \NR
354 \NC \type {\Umathaxis} \NC --
\NC AxisHeight
\NC axis_height
\NC \NR
355 \NC \type {\Umathoperatorsize} \NC D, D'
\NC DisplayOperatorMinHeight
\NC $^
6$
\NC \NR
356 \NC \type {\Umathfractiondelsize} \NC D, D'
\NC FractionDelimiterDisplayStyleSize$^
9$
\NC delim1
\NC \NR
357 \NC \NC T, T', S, S', SS, SS'
\NC FractionDelimiterSize$^
9$
\NC delim2
\NC \NR
358 \NC \type {\Umathfractiondenomdown} \NC D, D'
\NC FractionDenominatorDisplayStyleShiftDown
\NC denom1
\NC \NR
359 \NC \NC T, T', S, S', SS, SS'
\NC FractionDenominatorShiftDown
\NC denom2
\NC \NR
360 \NC \type {\Umathfractiondenomvgap} \NC D, D'
\NC FractionDenominatorDisplayStyleGapMin
\NC 3*default_rule_thickness
\NC \NR
361 \NC \NC T, T', S, S', SS, SS'
\NC FractionDenominatorGapMin
\NC default_rule_thickness
\NC \NR
362 \NC \type {\Umathfractionnumup} \NC D, D'
\NC FractionNumeratorDisplayStyleShiftUp
\NC num1
\NC \NR
363 \NC \NC T, T', S, S', SS, SS'
\NC FractionNumeratorShiftUp
\NC num2
\NC \NR
364 \NC \type {\Umathfractionnumvgap} \NC D, D'
\NC FractionNumeratorDisplayStyleGapMin
\NC 3*default_rule_thickness
\NC \NR
365 \NC \NC T, T', S, S', SS, SS'
\NC FractionNumeratorGapMin
\NC default_rule_thickness
\NC \NR
366 \NC \type {\Umathfractionrule} \NC --
\NC FractionRuleThickness
\NC default_rule_thickness
\NC \NR
367 \NC \type {\Umathskewedfractionhgap} \NC --
\NC SkewedFractionHorizontalGap
\NC math_quad/
2 \NC \NR
368 \NC \type {\Umathskewedfractionvgap} \NC --
\NC SkewedFractionVerticalGap
\NC math_x_height
\NC \NR
369 \NC \type {\Umathlimitabovebgap} \NC --
\NC UpperLimitBaselineRiseMin
\NC big_op_spacing3
\NC \NR
370 \NC \type {\Umathlimitabovekern} \NC --
\NC 0$^
1$
\NC big_op_spacing5
\NC \NR
371 \NC \type {\Umathlimitabovevgap} \NC --
\NC UpperLimitGapMin
\NC big_op_spacing1
\NC \NR
372 \NC \type {\Umathlimitbelowbgap} \NC --
\NC LowerLimitBaselineDropMin
\NC big_op_spacing4
\NC \NR
373 \NC \type {\Umathlimitbelowkern} \NC --
\NC 0$^
1$
\NC big_op_spacing5
\NC \NR
374 \NC \type {\Umathlimitbelowvgap} \NC --
\NC LowerLimitGapMin
\NC big_op_spacing2
\NC \NR
375 \NC \type {\Umathoverdelimitervgap} \NC --
\NC StretchStackGapBelowMin
\NC big_op_spacing1
\NC \NR
376 \NC \type {\Umathoverdelimiterbgap} \NC --
\NC StretchStackTopShiftUp
\NC big_op_spacing3
\NC \NR
377 \NC \type {\Umathunderdelimitervgap} \NC--
\NC StretchStackGapAboveMin
\NC big_op_spacing2
\NC \NR
378 \NC \type {\Umathunderdelimiterbgap} \NC--
\NC StretchStackBottomShiftDown
\NC big_op_spacing4
\NC \NR
379 \NC \type {\Umathoverbarkern} \NC --
\NC OverbarExtraAscender
\NC default_rule_thickness
\NC \NR
380 \NC \type {\Umathoverbarrule} \NC --
\NC OverbarRuleThickness
\NC default_rule_thickness
\NC \NR
381 \NC \type {\Umathoverbarvgap} \NC --
\NC OverbarVerticalGap
\NC 3*default_rule_thickness
\NC \NR
382 \NC \type {\Umathquad} \NC --
\NC <font_size(f)>$^
1$
\NC math_quad
\NC \NR
383 \NC \type {\Umathradicalkern} \NC --
\NC RadicalExtraAscender
\NC default_rule_thickness
\NC \NR
384 \NC \type {\Umathradicalrule} \NC --
\NC RadicalRuleThickness
\NC <not set>$^
2$
\NC \NR
385 \NC \type {\Umathradicalvgap} \NC D, D'
\NC RadicalDisplayStyleVerticalGap
\NC (default_rule_thickness+
\crlf
386 (abs(math_x_height)/
4))$^
3$
\NC \NR
387 \NC \NC T, T', S, S', SS, SS'
\NC RadicalVerticalGap
\NC (default_rule_thickness+
\crlf
388 (abs(default_rule_thickness)/
4))$^
3$
\NC \NR
389 \NC \type {\Umathradicaldegreebefore} \NC --
\NC RadicalKernBeforeDegree
\NC <not set>$^
2$
\NC \NR
390 \NC \type {\Umathradicaldegreeafter} \NC --
\NC RadicalKernAfterDegree
\NC <not set>$^
2$
\NC \NR
391 \NC \type {\Umathradicaldegreeraise} \NC --
\NC RadicalDegreeBottomRaisePercent
\NC <not set>$^
{2,
7}$
\NC \NR
392 \NC \type {\Umathspaceafterscript} \NC --
\NC SpaceAfterScript
\NC script_space$^
4$
\NC \NR
393 \NC \type {\Umathstackdenomdown} \NC D, D'
\NC StackBottomDisplayStyleShiftDown
\NC denom1
\NC \NR
394 \NC \NC T, T', S, S', SS, SS'
\NC StackBottomShiftDown
\NC denom2
\NC \NR
395 \NC \type {\Umathstacknumup} \NC D, D'
\NC StackTopDisplayStyleShiftUp
\NC num1
\NC \NR
396 \NC \NC T, T', S, S', SS, SS'
\NC StackTopShiftUp
\NC num3
\NC \NR
397 \NC \type {\Umathstackvgap} \NC D, D'
\NC StackDisplayStyleGapMin
\NC 7*default_rule_thickness
\NC \NR
398 \NC \NC T, T', S, S', SS, SS'
\NC StackGapMin
\NC 3*default_rule_thickness
\NC \NR
399 \NC \type {\Umathsubshiftdown} \NC --
\NC SubscriptShiftDown
\NC sub1
\NC \NR
400 \NC \type {\Umathsubshiftdrop} \NC --
\NC SubscriptBaselineDropMin
\NC sub_drop
\NC \NR
401 \NC \type {\Umathsubsupshiftdown} \NC --
\NC SubscriptShiftDownWithSuperscript$^
8$
\NC \NC \NR
402 \NC \NC \NC \quad\ or SubscriptShiftDown
\NC sub2
\NC \NR
403 \NC \type {\Umathsubtopmax} \NC --
\NC SubscriptTopMax
\NC (abs(math_x_height *
4) /
5)
\NC \NR
404 \NC \type {\Umathsubsupvgap} \NC --
\NC SubSuperscriptGapMin
\NC 4*default_rule_thickness
\NC \NR
405 \NC \type {\Umathsupbottommin} \NC --
\NC SuperscriptBottomMin
\NC (abs(math_x_height) /
4)
\NC \NR
406 \NC \type {\Umathsupshiftdrop} \NC --
\NC SuperscriptBaselineDropMax
\NC sup_drop
\NC \NR
407 \NC \type {\Umathsupshiftup} \NC D
\NC SuperscriptShiftUp
\NC sup1
\NC \NR
408 \NC \NC T, S, SS,
\NC SuperscriptShiftUp
\NC sup2
\NC \NR
409 \NC \NC D', T', S', SS'
\NC SuperscriptShiftUpCramped
\NC sup3
\NC \NR
410 \NC \type {\Umathsupsubbottommax} \NC --
\NC SuperscriptBottomMaxWithSubscript
\NC (abs(math_x_height *
4) /
5)
\NC \NR
411 \NC \type {\Umathunderbarkern} \NC --
\NC UnderbarExtraDescender
\NC default_rule_thickness
\NC \NR
412 \NC \type {\Umathunderbarrule} \NC --
\NC UnderbarRuleThickness
\NC default_rule_thickness
\NC \NR
413 \NC \type {\Umathunderbarvgap} \NC --
\NC UnderbarVerticalGap
\NC 3*default_rule_thickness
\NC \NR
414 \NC \type {\Umathconnectoroverlapmin} \NC --
\NC MinConnectorOverlap
\NC 0$^
5$
\NC \NR
419 Note
1:
\OPENTYPE\ fonts set
\type {\Umathlimitabovekern} and
\type
420 {\Umathlimitbelowkern} to zero and set
\type {\Umathquad} to the font size of the
421 used font, because these are not supported in the
\type {MATH
} table,
423 Note
2:
\TFM\ fonts do not set
\type {\Umathradicalrule} because
\TEX82\ uses the
424 height of the radical instead. When this parameter is indeed not set when
425 \LUATEX\ has to typeset a radical, a backward compatibility mode will kick in
426 that assumes that an oldstyle
\TEX\ font is used. Also, they do not set
\type
427 {\Umathradicaldegreebefore},
\type {\Umathradicaldegreeafter}, and
\type
428 {\Umathradicaldegreeraise}. These are then automatically initialized to
429 $
5/
18$quad, $-
10/
18$quad, and
60.
431 Note
3: If
\TFM\ fonts are used, then the
\type {\Umathradicalvgap} is not set
432 until the first time
\LUATEX\ has to typeset a formula because this needs
433 parameters from both family~
2 and family~
3. This provides a partial backward
434 compatibility with
\TEX82, but that compatibility is only partial: once the
\type
435 {\Umathradicalvgap} is set, it will not be recalculated any more.
437 Note
4: When
\TFM\ fonts are used a similar situation arises with respect to
438 \type {\Umathspaceafterscript}: it is not set until the first time
\LUATEX\ has
439 to typeset a formula. This provides some backward compatibility with
\TEX82. But
440 once the
\type {\Umathspaceafterscript} is set,
\type {\scriptspace} will never
443 Note
5: Traditional
\TFM\ fonts set
\type {\Umathconnectoroverlapmin} to zero
444 because
\TEX82\ always stacks extensibles without any overlap.
446 Note
6: The
\type {\Umathoperatorsize} is only used in
\type {\displaystyle}, and
447 is only set in
\OPENTYPE\ fonts. In
\TFM\ font mode, it is artificially set to
448 one scaled point more than the initial attempt's size, so that always the
\quote
449 {first next
} will be tried, just like in
\TEX82.
451 Note
7: The
\type {\Umathradicaldegreeraise} is a special case because it is the
452 only parameter that is expressed in a percentage instead of as a number of scaled
455 Note
8:
\type {SubscriptShiftDownWithSuperscript
} does not actually exist in the
456 \quote {standard
} \OPENTYPE\ math font Cambria, but it is useful enough to be
459 Note
9:
\type {FractionDelimiterDisplayStyleSize
} and
\type
460 {FractionDelimiterSize
} do not actually exist in the
\quote {standard
} \OPENTYPE\
461 math font Cambria, but were useful enough to be added.
463 \section{Math spacing setting
}
465 Besides the parameters mentioned in the previous sections, there are also
64 new
466 primitives to control the math spacing table (as explained in Chapter~
18 of the
467 \TEX book). The primitive names are a simple matter of combining two math atom
468 types, but for completeness' sake, here is the whole list:
477 \Umathordclosespacing
478 \Umathordpunctspacing
479 \Umathordinnerspacing
493 \Umathbinclosespacing
494 \Umathbinpunctspacing
495 \Umathbininnerspacing
501 \Umathrelclosespacing
502 \Umathrelpunctspacing
503 \Umathrelinnerspacing
508 \Umathopenopenspacing
509 \Umathopenclosespacing
510 \Umathopenpunctspacing
511 \Umathopeninnerspacing
512 \Umathcloseordspacing
514 \Umathclosebinspacing
515 \Umathcloserelspacing
516 \Umathcloseopenspacing
517 \Umathcloseclosespacing
518 \Umathclosepunctspacing
519 \Umathcloseinnerspacing
520 \Umathpunctordspacing
522 \Umathpunctbinspacing
523 \Umathpunctrelspacing
524 \Umathpunctopenspacing
525 \Umathpunctclosespacing
526 \Umathpunctpunctspacing
527 \Umathpunctinnerspacing
528 \Umathinnerordspacing
530 \Umathinnerbinspacing
531 \Umathinnerrelspacing
532 \Umathinneropenspacing
533 \Umathinnerclosespacing
534 \Umathinnerpunctspacing
535 \Umathinnerinnerspacing
539 These parameters are of type
\type {\muskip}, so setting a parameter can be done
543 \Umathopordspacing\displaystyle=
4mu plus
2mu
546 They are all initialized by
\type {initex
} to the values mentioned in the table
547 in Chapter~
18 of the
\TEX book.
549 Note
1: for ease of use as well as for backward compatibility,
\type
550 {\thinmuskip},
\type {\medmuskip} and
\type {\thickmuskip} are treated
551 especially. In their case a pointer to the corresponding internal parameter is
552 saved, not the actual
\type {\muskip} value. This means that any later changes to
553 one of these three parameters will be taken into account.
555 Note
2: Careful readers will realise that there are also primitives for the items
556 marked
\type {*
} in the
\TEX book. These will not actually be used as those
557 combinations of atoms cannot actually happen, but it seemed better not to break
558 orthogonality. They are initialized to zero.
560 \section[mathacc
]{Math accent handling
}
562 \LUATEX\ supports both top accents and bottom accents in math mode, and math
563 accents stretch automatically (if this is supported by the font the accent comes
564 from, of course). Bottom and combined accents as well as fixed-width math accents
565 are controlled by optional keywords following
\type {\Umathaccent}.
567 The keyword
\type {bottom
} after
\type {\Umathaccent} signals that a bottom accent
568 is needed, and the keyword
\type {both
} signals that both a top and a bottom
569 accent are needed (in this case two accents need to be specified, of course).
571 Then the set of three integers defining the accent is read. This set of integers
572 can be prefixed by the
\type {fixed
} keyword to indicate that a non-stretching
573 variant is requested (in case of both accents, this step is repeated).
578 \Umathaccent both fixed
0 0 "
20D7 fixed
0 0 "
20D7
{example
}
581 If a math top accent has to be placed and the accentee is a character and has a
582 non-zero
\type {top_accent
} value, then this value will be used to place the
583 accent instead of the
\type {\skewchar} kern used by
\TEX82.
585 The
\type {top_accent
} value represents a vertical line somewhere in the
586 accentee. The accent will be shifted horizontally such that its own
\type
587 {top_accent
} line coincides with the one from the accentee. If the
\type
588 {top_accent
} value of the accent is zero, then half the width of the accent
589 followed by its italic correction is used instead.
591 The vertical placement of a top accent depends on the
\type {x_height
} of the
592 font of the accentee (as explained in the
\TEX book), but if value that turns out
593 to be zero and the font had a
\type {MathConstants
} table, then
\type
594 {AccentBaseHeight
} is used instead.
596 The vertical placement of a bottom accent is straight below the accentee, no
597 correction takes place.
599 Possible locations are
\type {top
},
\type {bottom
},
\type {both
} and
\type
600 {center
}. When no location is given
\type {top
} is assumed. An additional
601 parameter
\type {fraction
} can be specified followed by a number; a value of for
602 instance
1200 means that the criterium is
1.2 times the width of the nuclues. The
603 fraction only applies to the stepwise selected shapes and is mostly meant for the
604 \type {overlay
} location. It also works for the other locations but then it
607 \section{Math root extension
}
609 The new primitive
\type {\Uroot} allows the construction of a radical noad
610 including a degree field. Its syntax is an extension of
\type {\Uradical}:
613 \Uradical <fam integer> <char integer> <radicand>
614 \Uroot <fam integer> <char integer> <degree> <radicand>
617 The placement of the degree is controlled by the math parameters
\type
618 {\Umathradicaldegreebefore},
\type {\Umathradicaldegreeafter}, and
\type
619 {\Umathradicaldegreeraise}. The degree will be typeset in
\type
620 {\scriptscriptstyle}.
622 \section{Math kerning in super- and subscripts
}
624 The character fields in a
\LUA|-|loaded
\OPENTYPE\ math font can have a
\quote
625 {mathkern
} table. The format of this table is the same as the
\quote {mathkern
}
626 table that is returned by the
\type {fontloader
} library, except that all height
627 and kern values have to be specified in actual scaled points.
629 When a super- or subscript has to be placed next to a math item,
\LUATEX\ checks
630 whether the super- or subscript and the nucleus are both simple character items.
631 If they are, and if the fonts of both character items are
\OPENTYPE\ fonts (as
632 opposed to legacy
\TEX\ fonts), then
\LUATEX\ will use the
\OPENTYPE\ math
633 algorithm for deciding on the horizontal placement of the super- or subscript.
635 This works as follows:
639 The vertical position of the script is calculated.
642 The default horizontal position is flat next to the base character.
645 For superscripts, the italic correction of the base character is added.
648 For a superscript, two vertical values are calculated: the bottom of the
649 script (after shifting up), and the top of the base. For a subscript, the two
650 values are the top of the (shifted down) script, and the bottom of the base.
653 For each of these two locations:
656 find the math kern value at this height for the base (for a subscript
657 placement, this is the bottom_right corner, for a superscript
658 placement the top_right corner)
661 find the math kern value at this height for the script (for a
662 subscript placement, this is the top_left corner, for a superscript
663 placement the bottom_left corner)
666 add the found values together to get a preliminary result.
671 The horizontal kern to be applied is the smallest of the two results from
676 The math kern value at a specific height is the kern value that is specified by the
677 next higher height and kern pair, or the highest one in the character (if there is no
678 value high enough in the character), or simply zero (if the character has no math kern
681 \section{Scripts on horizontally extensible items like arrows
}
683 The primitives
\type {\Uunderdelimiter} and
\type {\Uoverdelimiter} allow the
684 placement of a subscript or superscript on an automatically extensible item and
685 \type {\Udelimiterunder} and
\type {\Udelimiterover} allow the placement of an
686 automatically extensible item as a subscript or superscript on a nucleus. The
689 % these produce radical noads .. in fact the code base has the numbers wrong for
690 % quite a while, so no one seems to use this
693 $
\Uoverdelimiter 0 "
2194 {\hbox{\strut overdelimiter
}}$
694 $
\Uunderdelimiter 0 "
2194 {\hbox{\strut underdelimiter
}}$
695 $
\Udelimiterover 0 "
2194 {\hbox{\strut delimiterover
}}$
696 $
\Udelimiterunder 0 "
2194 {\hbox{\strut delimiterunder
}}$
699 \typebuffer will render this:
701 \blank \startnarrower \getbuffer \stopnarrower \blank
703 The vertical placements are controlled by
\type {\Umathunderdelimiterbgap},
\type
704 {\Umathunderdelimitervgap},
\type {\Umathoverdelimiterbgap}, and
\type
705 {\Umathoverdelimitervgap} in a similar way as limit placements on large operators.
706 The superscript in
\type {\Uoverdelimiter} is typeset in a suitable scripted style,
707 the subscript in
\type {\Uunderdelimiter} is cramped as well.
709 These primitives accepts an option
\type {width
} specification. When used the
710 also optional keywords
\type {left
},
\type {middle
} and
\type {right
} will
711 determine what happens when a requested size can't be met (which can happen when
712 we step to successive larger variants).
714 An extra primitive
\type {\Uhextensible} is available that can be used like this:
717 $
\Uhextensible width
10cm
0 "
2194$
720 \typebuffer This will render this:
722 \blank \startnarrower \getbuffer \stopnarrower \blank
724 Here you can also pass options, like:
727 $
\Uhextensible width
1pt middle
0 "
2194$
730 \typebuffer This gives:
732 \blank \startnarrower \getbuffer \stopnarrower \blank
734 \LUATEX\ internally uses a structure that supports
\OPENTYPE\
\quote
735 {MathVariants
} as well as
\TFM\
\quote {extensible recipes
}.
737 \section {Extracting values
}
739 You can extract the components of a math character. Say that we have defined:
748 [\Umathcharclass1] [\Umathcharfam1] [\Umathcharslot1]
757 These commands are provides as convenience. before they came available you could
761 \def\Umathcharclass{\directlua{tex
.print(tex
.getmathcode(token
.scan_int())[1])}}
762 \def\Umathcharfam {\directlua{tex
.print(tex
.getmathcode(token
.scan_int())[2])}}
763 \def\Umathcharslot {\directlua{tex
.print(tex
.getmathcode(token
.scan_int())[3])}}
768 The
\type {\abovewithdelims} command accepts a keyword
\type {exact
}. When issued
769 the extra space relative to the rule thickness is not added. One can of course
770 use the
\type {\Umathfraction..gap
} commands to influence the spacing. Also the
771 rule is still positioned around the math axis.
774 $$
{ {a
} \abovewithdelims() exact
4pt
{b
} }$$
777 The math parameter table contains some parameters that specify a horizontal and
778 vertical gap for skewed fractions. Of course some guessing is needed in order to
779 implement something that uses then. And so we now provide a primitive similar to the
780 other fraction related ones but with a few options so that one can influence the
781 rendering. Of course a user can mess around a bit with the parameters
782 \type {\Umathskewedfractionhgap} and
\type {\Umathskewedfractionvgap}.
784 The syntax used here is:
787 { {1} \Uskewed / <options>
{2} }
788 { {1} \Uskewedwithdelims / () <options>
{2} }
791 where the options can be
\type {noaxis
} and
\type {exact
}. By default we add half
792 the axis to the shifts and by default we zero the width of the middle character.
793 For Latin Modern The result looks as follows:
795 \def\ShowA#1#2#3{$x +
{ {#1} \Uskewed /
#3 {#2} } + x$
}
796 \def\ShowB#1#2#3{$x +
{ {#1} \Uskewedwithdelims / ()
#3 {#2} } + x$
}
799 \switchtobodyfont[modern
]
800 \starttabulate[||||||
]
808 \ShowA{a
}{b
}{exact
} \NC
809 \ShowA{1}{2}{exact
} \NC
810 \ShowB{a
}{b
}{exact
} \NC
811 \ShowB{1}{2}{exact
} \NC
813 \NC \type{noaxis
} \NC
814 \ShowA{a
}{b
}{noaxis
} \NC
815 \ShowA{1}{2}{noaxis
} \NC
816 \ShowB{a
}{b
}{noaxis
} \NC
817 \ShowB{1}{2}{noaxis
} \NC
819 \NC \type{exact noaxis
} \NC
820 \ShowA{a
}{b
}{exact noaxis
} \NC
821 \ShowA{1}{2}{exact noaxis
} \NC
822 \ShowB{a
}{b
}{exact noaxis
} \NC
823 \ShowB{1}{2}{exact noaxis
} \NC
828 \section {Other Math changes
}
830 \subsection {Verbose versions of single-character math commands
}
832 \LUATEX\ defines six new primitives that have the same function as
833 \type {^
},
\type {_
},
\type {$
}, and
\type {$$
}.
%$
835 \starttabulate[|l|l|l|l|
]
836 \NC \bf primitive
\NC \bf explanation
\NC \NR
837 \NC \type {\Usuperscript} \NC Duplicates the functionality of
\type {^
} \NC \NR
838 \NC \type {\Usubscript} \NC Duplicates the functionality of
\type {_
} \NC \NR
839 \NC \type {\Ustartmath} \NC Duplicates the functionality of
\type {$
},
% $
840 when used in non-math mode.
\NC \NR
841 \NC \type {\Ustopmath} \NC Duplicates the functionality of
\type {$
},
% $
842 when used in inline math mode.
\NC \NR
843 \NC \type {\Ustartdisplaymath} \NC Duplicates the functionality of
\type {$$
},
% $$
844 when used in non-math mode.
\NC \NR
845 \NC \type {\Ustopdisplaymath} \NC Duplicates the functionality of
\type {$$
},
% $$
846 when used in display math mode.
\NC \NR
849 The
\type {\Ustopmath} and
\type {\Ustopdisplaymath} primitives check if the current
850 math mode is the correct one (inline vs.\ displayed), but you can freely intermix
851 the four mathon|/|mathoff commands with explicit dollar sign(s).
853 \subsection{Allowed math commands in non-math modes
}
855 The commands
\type {\mathchar}, and
\type {\Umathchar} and control sequences that
856 are the result of
\type {\mathchardef} or
\type {\Umathchardef} are also
857 acceptable in the horizontal and vertical modes. In those cases, the
\type
858 {\textfont} from the requested math family is used.
860 \section{Math surrounding skips
}
862 Inline math is surrounded by (optional)
\type {\mathsurround} spacing but that is fixed
863 dimension. There is now an additional parameter
\type {\mathsurroundskip}. When set to a
864 non|-|zero value (or zero with some stretch or shrink) this parameter will replace
865 \type {\mathsurround}. By using an additional parameter instead of changing the nature
866 of
\type {\mathsurround}, we can remain compatible.
868 % \section{Math todo}
870 % The following items are still todo.
877 % Multi-story stacks.
880 % Flattened accents for high characters (maybe).
883 % Better control over the spacing around displays and handling of equation numbers.
886 % Support for multi|-|line displays using \MATHML\ style alignment points.
890 \subsection {Delimiters:
\type{\Uleft},
\type {\Umiddle} and
\type {\Uright}}
892 Normally you will force delimiters to certain sizes by putting an empty box or
893 rule next to it. The resulting delimiter will either be a character from the
894 stepwise size range or an extensible. The latter can be quite differently
895 positioned that the characters as it depends on the fit as well as the fact if
896 the used characters in the font have depth or height. Commands like (plain
\TEX
897 s)
\type {\big} need use this feature. In
\LUATEX\ we provide a bit more control
898 by three variants that supporting optional parameters
\type {height
},
\type
899 {depth
} and
\type {axis
}. The following example uses this:
902 \Uleft height
30pt depth
10pt
\Udelimiter "
0 "
0 "
000028
904 \Umiddle height
40pt depth
15pt
\Udelimiter "
0 "
0 "
002016
906 \Uright height
30pt depth
10pt
\Udelimiter "
0 "
0 "
000029
908 \Uleft height
30pt depth
10pt axis
\Udelimiter "
0 "
0 "
000028
910 \Umiddle height
40pt depth
15pt axis
\Udelimiter "
0 "
0 "
002016
912 \Uright height
30pt depth
10pt axis
\Udelimiter "
0 "
0 "
000029
918 \ruledhbox{\mathematics{\getbuffer}}
921 The keyword
\type {exact
} can be used as directive that the real dimensions
922 should be applied when the criteria can't be met which can happen when we're
923 still stepping through the successively larger variants. When no dimensions are
924 given the
\type {noaxis
} command can be used to prevent shifting over the axis.
926 You can influence the final class with the keyword
\type {class
} which will
927 influence the spacing.
929 \subsection{Fixed scripts
}
931 We have three parameters that are used for this fixed anchoring:
933 \starttabulate[|l|l|
]
934 \NC $d$
\NC \type {\Umathsubshiftdown} \NC \NR
935 \NC $u$
\NC \type {\Umathsupshiftup} \NC \NR
936 \NC $s$
\NC \type {\Umathsubsupshiftdown} \NC \NR
939 When we set
\type {\mathscriptsmode} to a value other than zero these are used
940 for calculating fixed positions. This is something that is needed for instance
941 for chemistry. You can manipulate the mentioned variables to achive different
945 {$
\mathscriptsmode#1\mathupright CH_2 + CH^+_2 + CH^
2_2$
}
947 \starttabulate[|c|c|c|l|
]
948 \NC \bf mode
\NC \bf down
\NC \bf up
\NC \NC \NR
949 \NC 0 \NC dynamic
\NC dynamic
\NC \SampleMath{0} \NC \NR
950 \NC 1 \NC $d$
\NC $u$
\NC \SampleMath{1} \NC \NR
951 \NC 2 \NC $s$
\NC $u$
\NC \SampleMath{2} \NC \NR
952 \NC 3 \NC $s$
\NC $u + s - d$
\NC \SampleMath{3} \NC \NR
953 \NC 4 \NC $d + (s-d)/
2$
\NC $u + (s-d)/
2$
\NC \SampleMath{4} \NC \NR
954 \NC 5 \NC $d$
\NC $u + s - d$
\NC \SampleMath{5} \NC \NR
957 The value of this parameter obeys grouping but applies to the whole current
960 % if needed we can put the value in stylenodes but maybe more should go there
962 \subsection {Tracing
}
964 Because there are quite some math related parameters and values, it is possible
965 to limit tracing. Only when
\type {tracingassigns
} and|/|or
\type
966 {tracingrestores
} are set to~
2 or more they will be traced.
968 \subsection {Math options
}
970 The logic in the math engine is rather complex and there are often no universal
971 solutions (read: what works out well for one font, fails for another). Therefore
972 some variations in the implementation will be driven by options for which a new
973 primitive
\type {\mathoption} has been introduced (so that we don't end up with
974 many new commands). The approach of options also permits us to see what effect a
975 specific solution has.
977 \subsubsection {\type {\mathoption noitaliccompensation
}}
979 This option compensates placement for characters with a built|-|in italic
983 {\showboxes\int}\quad
984 {\showboxes\int_{|
}^
{|
}}\quad
985 {\showboxes\int\limits_{|
}^
{|
}}
990 Gives (with computer modern that has such italics):
992 \startlinecorrection[blank
]
993 \switchtobodyfont[modern
]
994 \startcombination[nx=
2,ny=
2,distance=
5em
]
995 {\mathoption noitaliccompensation
0\relax \mathematics{\getbuffer}}
996 {\nohyphens\type{0:inline
}}
997 {\mathoption noitaliccompensation
0\relax \mathematics{\displaymath\getbuffer}}
998 {\nohyphens\type{0:display
}}
999 {\mathoption noitaliccompensation
1\relax \mathematics{\getbuffer}}
1000 {\nohyphens\type{1:inline
}}
1001 {\mathoption noitaliccompensation
1\relax \mathematics{\displaymath\getbuffer}}
1002 {\nohyphens\type{1:display
}}
1006 \subsubsection {\type {\mathoption nocharitalic
}}
1008 When two characters follow each other italic correction can interfere. The
1009 following example shows what this option does:
1020 Gives (with computer modern that has such italics):
1022 \startlinecorrection[blank
]
1023 \switchtobodyfont[modern
]
1024 \startcombination[nx=
2,ny=
2,distance=
5em
]
1025 {\mathoption nocharitalic
0\relax \mathematics{\getbuffer}}
1026 {\nohyphens\type{0:inline
}}
1027 {\mathoption nocharitalic
0\relax \mathematics{\displaymath\getbuffer}}
1028 {\nohyphens\type{0:display
}}
1029 {\mathoption nocharitalic
1\relax \mathematics{\getbuffer}}
1030 {\nohyphens\type{1:inline
}}
1031 {\mathoption nocharitalic
1\relax \mathematics{\displaymath\getbuffer}}
1032 {\nohyphens\type{1:display
}}
1036 \subsubsection {\type {\mathoption useoldfractionscaling
}}
1038 This option has been introduced as solution for tracker item
604 for fuzzy cases
1039 around either or not present fraction related settings for new fonts.