1 \environment luatex-style
2 \environment luatex-logos
4 \startcomponent luatex-math
6 \startchapter[reference=math,title=
{Math
}]
8 The handling of mathematics in
\LUATEX\ differs quite a bit from how
\TEX82 (and
9 therefore
\PDFTEX) handles math. First,
\LUATEX\ adds primitives and extends some
10 others so that
\UNICODE\ input can be used easily. Second, all of
\TEX82's
11 internal special values (for example for operator spacing) have been made
12 accessible and changeable via control sequences. Third, there are extensions that
13 make it easier to use
\OPENTYPE\ math fonts. And finally, there are some
14 extensions that have been proposed in the past that are now added to the engine.
16 \section{The current math style
}
18 It is possible to discover the math style that will be used for a formula in an
19 expandable fashion (while the math list is still being read). To make this
20 possible,
\LUATEX\ adds the new primitive:
\type {\mathstyle}. This is a
\quote
21 {convert command
} like e.g.
\type {\romannumeral}: its value can only be read,
24 \subsection{\type {\mathstyle}}
26 The returned value is between
0 and
7 (in math mode), or $-
1$ (all other modes).
27 For easy testing, the eight math style commands have been altered so that the can
28 be used as numeric values, so you can write code like this:
31 \ifnum\mathstyle=
\textstyle
32 \message{normal text style
}
33 \else \ifnum\mathstyle=
\crampedtextstyle
34 \message{cramped text style
}
38 \subsection{\type {\Ustack}}
40 There are a few math commands in
\TEX\ where the style that will be used is not
41 known straight from the start. These commands (
\type {\over},
\type {\atop},
42 \type {\overwithdelims},
\type {\atopwithdelims}) would therefore normally return
43 wrong values for
\type {\mathstyle}. To fix this,
\LUATEX\ introduces a special
44 prefix command:
\type {\Ustack}:
50 The
\type {\Ustack} command will scan the next brace and start a new math group
51 with the correct (numerator) math style.
53 \section{Unicode math characters
}
55 Character handling is now extended up to the full
\UNICODE\ range (the
\type {\U}
56 prefix), which is compatible with
\XETEX.
58 The math primitives from
\TEX\ are kept as they are, except for the ones that
59 convert from input to math commands:
\type {mathcode
}, and
\type {delcode
}. These
60 two now allow for a
21-bit character argument on the left hand side of the equals
63 Some of the new
\LUATEX\ primitives read more than one separate value. This is
64 shown in the tables below by a plus sign in the second column.
66 The input for such primitives would look like this:
69 \def\overbrace{\Umathaccent 0 1 "
23DE
}
72 Altered
\TEX82 primitives:
74 \starttabulate[|l|l|l|
]
75 \NC \bf primitive
\NC \bf value range (in hex)
\NC \NR
76 \NC \type {\mathcode} \NC 0--
10FFFF =
0--
8000 \NC \NR
77 \NC \type {\delcode} \NC 0--
10FFFF =
0--FFFFFF
\NC \NR
82 \starttabulate[|l|l|l|
]
83 \NC \bf primitive
\NC \bf value range (in hex)
\NC \NR
84 \NC \type {\mathchardef} \NC 0--
8000 \NC \NR
85 \NC \type {\mathchar} \NC 0--
7FFF
\NC \NR
86 \NC \type {\mathaccent} \NC 0--
7FFF
\NC \NR
87 \NC \type {\delimiter} \NC 0--
7FFFFFF
\NC \NR
88 \NC \type {\radical} \NC 0--
7FFFFFF
\NC \NR
91 New primitives that are compatible with
\XETEX:
93 \starttabulate[|l|l|l|l|
]
94 \NC \bf primitive
\NC \bf value range (in hex)
\NC \NR
95 \NC \type {\Umathchardef} \NC 0+
0+
0--
7+FF+
10FFFF$^
1$
\NC \NR
96 \NC \type {\Umathcharnumdef}$^
5$
\NC -
80000000--
7FFFFFFF$^
3$
\NC \NR
97 \NC \type {\Umathcode} \NC 0--
10FFFF =
0+
0+
0--
7+FF+
10FFFF$^
1$
\NC \NR
98 \NC \type {\Udelcode} \NC 0--
10FFFF =
0+
0--FF+
10FFFF$^
2$
\NC \NR
99 \NC \type {\Umathchar} \NC 0+
0+
0--
7+FF+
10FFFF
\NC \NR
100 \NC \type {\Umathaccent} \NC 0+
0+
0--
7+FF+
10FFFF$^
{2,
4}$
\NC \NR
101 \NC \type {\Udelimiter} \NC 0+
0+
0--
7+FF+
10FFFF$^
2$
\NC \NR
102 \NC \type {\Uradical} \NC 0+
0--FF+
10FFFF$^
2$
\NC \NR
103 \NC \type {\Umathcharnum} \NC -
80000000--
7FFFFFFF$^
3$
\NC \NR
104 \NC \type {\Umathcodenum} \NC 0--
10FFFF = -
80000000--
7FFFFFFF$^
3$
\NC \NR
105 \NC \type {\Udelcodenum} \NC 0--
10FFFF = -
80000000--
7FFFFFFF$^
3$
\NC \NR
108 Note
1:
\type {\Umathchardef<csname>="
8"
0"
0} and
\type
109 {\Umathchardef<number>="
8"
0"
0} are also accepted.
111 Note
2: The new primitives that deal with delimiter-style objects do not set up a
112 \quote {large family
}. Selecting a suitable size for display purposes is expected
113 to be dealt with by the font via the
\type {\Umathoperatorsize} parameter (more
114 information can be found in a following section).
116 Note
3: For these three primitives, all information is packed into a single
117 signed integer. For the first two (
\type {\Umathcharnum} and
\type {\Umathcodenum}),
118 the lowest
21 bits are the character code, the
3 bits above that represent the
119 math class, and the family data is kept in the topmost bits (This means that the
120 values for math families
128--
255 are actually negative). For
\type {\Udelcodenum}
121 there is no math class; the math family information is stored in the bits
122 directly on top of the character code. Using these three commands is not as
123 natural as using the two- and three-value commands, so unless you know exactly
124 what you are doing and absolutely require the speedup resulting from the faster
125 input scanning, it is better to use the verbose commands instead.
127 Note
4: The
\type {\Umathaccent} command accepts optional keywords to control
128 various details regarding math accents. See
\in {section
} [mathacc
] below for
131 New primitives that exist in
\LUATEX\ only (all of these will be explained
132 in following sections):
134 \starttabulate[|l|l|l|l|
]
135 \NC \bf primitive
\NC \bf value range (in hex)
\NC \NR
136 \NC \type {\Uroot} \NC 0+
0--FF+
10FFFF$^
2$
\NC \NR
137 \NC \type {\Uoverdelimiter} \NC 0+
0--FF+
10FFFF$^
2$
\NC \NR
138 \NC \type {\Uunderdelimiter} \NC 0+
0--FF+
10FFFF$^
2$
\NC \NR
139 \NC \type {\Udelimiterover} \NC 0+
0--FF+
10FFFF$^
2$
\NC \NR
140 \NC \type {\Udelimiterunder} \NC 0+
0--FF+
10FFFF$^
2$
\NC \NR
143 \section{Cramped math styles
}
145 \LUATEX\ has four new primitives to set the cramped math styles directly:
151 \crampedscriptscriptstyle
154 These additional commands are not all that valuable on their own, but they come
155 in handy as arguments to the math parameter settings that will be added shortly.
157 \section{Math parameter settings
}
159 In
\LUATEX, the font dimension parameters that
\TEX\ used in math typesetting are
160 now accessible via primitive commands. In fact, refactoring of the math engine
161 has resulted in many more parameters than were accessible before.
164 \NC \bf primitive name
\NC \bf description
\NC \NR
165 \NC \type {\Umathquad} \NC the width of
18mu's
\NC \NR
166 \NC \type {\Umathaxis} \NC height of the vertical center axis of
167 the math formula above the baseline
\NC \NR
168 \NC \type {\Umathoperatorsize} \NC minimum size of large operators in display mode
\NC \NR
169 \NC \type {\Umathoverbarkern} \NC vertical clearance above the rule
\NC \NR
170 \NC \type {\Umathoverbarrule} \NC the width of the rule
\NC \NR
171 \NC \type {\Umathoverbarvgap} \NC vertical clearance below the rule
\NC \NR
172 \NC \type {\Umathunderbarkern} \NC vertical clearance below the rule
\NC \NR
173 \NC \type {\Umathunderbarrule} \NC the width of the rule
\NC \NR
174 \NC \type {\Umathunderbarvgap} \NC vertical clearance above the rule
\NC \NR
175 \NC \type {\Umathradicalkern} \NC vertical clearance above the rule
\NC \NR
176 \NC \type {\Umathradicalrule} \NC the width of the rule
\NC \NR
177 \NC \type {\Umathradicalvgap} \NC vertical clearance below the rule
\NC \NR
178 \NC \type {\Umathradicaldegreebefore}\NC the forward kern that takes place before placement of
179 the radical degree
\NC \NR
180 \NC \type {\Umathradicaldegreeafter} \NC the backward kern that takes place after placement of
181 the radical degree
\NC \NR
182 \NC \type {\Umathradicaldegreeraise} \NC this is the percentage of the total height and depth of
183 the radical sign that the degree is raised by. It is
184 expressed in
\type {percents
}, so
60\% is expressed as the
185 integer $
60$.
\NC \NR
186 \NC \type {\Umathstackvgap} \NC vertical clearance between the two
187 elements in a
\type {\atop} stack
\NC \NR
188 \NC \type {\Umathstacknumup} \NC numerator shift upward in
\type {\atop} stack
\NC \NR
189 \NC \type {\Umathstackdenomdown} \NC denominator shift downward in
\type {\atop} stack
\NC \NR
190 \NC \type {\Umathfractionrule} \NC the width of the rule in a
\type {\over} \NC \NR
191 \NC \type {\Umathfractionnumvgap} \NC vertical clearance between the numerator and the rule
\NC \NR
192 \NC \type {\Umathfractionnumup} \NC numerator shift upward in
\type {\over} \NC \NR
193 \NC \type {\Umathfractiondenomvgap} \NC vertical clearance between the denominator and the rule
\NC \NR
194 \NC \type {\Umathfractiondenomdown} \NC denominator shift downward in
\type {\over} \NC \NR
195 \NC \type {\Umathfractiondelsize} \NC minimum delimiter size for
\type {\...withdelims
} \NC \NR
196 \NC \type {\Umathlimitabovevgap} \NC vertical clearance for limits above operators
\NC \NR
197 \NC \type {\Umathlimitabovebgap} \NC vertical baseline clearance for limits above operators
\NC \NR
198 \NC \type {\Umathlimitabovekern} \NC space reserved at the top of the limit
\NC \NR
199 \NC \type {\Umathlimitbelowvgap} \NC vertical clearance for limits below operators
\NC \NR
200 \NC \type {\Umathlimitbelowbgap} \NC vertical baseline clearance for limits below operators
\NC \NR
201 \NC \type {\Umathlimitbelowkern} \NC space reserved at the bottom of the limit
\NC \NR
202 \NC \type {\Umathoverdelimitervgap} \NC vertical clearance for limits above delimiters
\NC \NR
203 \NC \type {\Umathoverdelimiterbgap} \NC vertical baseline clearance for limits above delimiters
\NC \NR
204 \NC \type {\Umathunderdelimitervgap} \NC vertical clearance for limits below delimiters
\NC \NR
205 \NC \type {\Umathunderdelimiterbgap} \NC vertical baseline clearance for limits below delimiters
\NC \NR
206 \NC \type {\Umathsubshiftdrop} \NC subscript drop for boxes and subformulas
\NC \NR
207 \NC \type {\Umathsubshiftdown} \NC subscript drop for characters
\NC \NR
208 \NC \type {\Umathsupshiftdrop} \NC superscript drop (raise, actually) for boxes and subformulas
\NC \NR
209 \NC \type {\Umathsupshiftup} \NC superscript raise for characters
\NC \NR
210 \NC \type {\Umathsubsupshiftdown} \NC subscript drop in the presence of a superscript
\NC \NR
211 \NC \type {\Umathsubtopmax} \NC the top of standalone subscripts cannot be higher than this
212 above the baseline
\NC \NR
213 \NC \type {\Umathsupbottommin} \NC the bottom of standalone superscripts cannot be less than
214 this above the baseline
\NC \NR
215 \NC \type {\Umathsupsubbottommax} \NC the bottom of the superscript of a combined super- and subscript
216 be at least as high as this above the baseline
\NC \NR
217 \NC \type {\Umathsubsupvgap} \NC vertical clearance between super- and subscript
\NC \NR
218 \NC \type {\Umathspaceafterscript} \NC additional space added after a super- or subscript
\NC \NR
219 \NC \type {\Umathconnectoroverlapmin}\NC minimum overlap between parts in an extensible recipe
\NC \NR
222 Each of the parameters in this section can be set by a command like this:
225 \Umathquad\displaystyle=
1em
228 they obey grouping, and you can use
\type {\the\Umathquad\displaystyle} if
231 \section{Font-based Math Parameters
}
233 While it is nice to have these math parameters available for tweaking, it would
234 be tedious to have to set each of them by hand. For this reason,
\LUATEX\
235 initializes a bunch of these parameters whenever you assign a font identifier to
236 a math family based on either the traditional math font dimensions in the font
237 (for assignments to math family~
2 and~
3 using
\TFM|-|based fonts like
\type
238 {cmsy
} and
\type {cmex
}), or based on the named values in a potential
\type
239 {MathConstants
} table when the font is loaded via Lua. If there is a
\type
240 {MathConstants
} table, this takes precedence over font dimensions, and in that
241 case no attention is paid to which family is being assigned to: the
\type
242 {MathConstants
} tables in the last assigned family sets all parameters.
244 In the table below, the one|-|letter style abbreviations and symbolic tfm font
245 dimension names match those using in the
\TeX book. Assignments to
\type
246 {\textfont} set the values for the cramped and uncramped display and text styles.
247 Use
\type {\scriptfont} for the script styles, and
\type {\scriptscriptfont} for the
248 scriptscript styles (totalling eight parameters for three font sizes). In the
249 \TFM\ case, assignments only happen in family~
2 and family~
3 (and of course only
250 for the parameters for which there are font dimensions).
252 Besides the parameters below,
\LUATEX\ also looks at the
\quote {space
} font
253 dimension parameter. For math fonts, this should be set to zero.
257 \switchtobodyfont[8pt
]
259 \starttabulate[|l|l|l|p|
]
260 \NC \bf variable
\NC \bf style
\NC \bf default value opentype
\NC \bf default value tfm
\NC \NR
261 \NC \type {\Umathaxis} \NC --
\NC AxisHeight
\NC axis_height
\NC \NR
262 \NC \type {\Umathoperatorsize} \NC D, D'
\NC DisplayOperatorMinHeight
\NC $^
6$
\NC \NR
263 \NC \type {\Umathfractiondelsize} \NC D, D'
\NC FractionDelimiterDisplayStyleSize$^
9$
\NC delim1
\NC \NR
264 \NC "
\NC T, T', S, S', SS, SS'
\NC FractionDelimiterSize$^
9$
\NC delim2
\NC \NR
265 \NC \type {\Umathfractiondenomdown} \NC D, D'
\NC FractionDenominatorDisplayStyleShiftDown
\NC denom1
\NC \NR
266 \NC "
\NC T, T', S, S', SS, SS'
\NC FractionDenominatorShiftDown
\NC denom2
\NC \NR
267 \NC \type {\Umathfractiondenomvgap} \NC D, D'
\NC FractionDenominatorDisplayStyleGapMin
\NC 3*default_rule_thickness
\NC \NR
268 \NC "
\NC T, T', S, S', SS, SS'
\NC FractionDenominatorGapMin
\NC default_rule_thickness
\NC \NR
269 \NC \type {\Umathfractionnumup} \NC D, D'
\NC FractionNumeratorDisplayStyleShiftUp
\NC num1
\NC \NR
270 \NC "
\NC T, T', S, S', SS, SS'
\NC FractionNumeratorShiftUp
\NC num2
\NC \NR
271 \NC \type {\Umathfractionnumvgap} \NC D, D'
\NC FractionNumeratorDisplayStyleGapMin
\NC 3*default_rule_thickness
\NC \NR
272 \NC "
\NC T, T', S, S', SS, SS'
\NC FractionNumeratorGapMin
\NC default_rule_thickness
\NC \NR
273 \NC \type {\Umathfractionrule} \NC --
\NC FractionRuleThickness
\NC default_rule_thickness
\NC \NR
274 \NC \type {\Umathlimitabovebgap} \NC --
\NC UpperLimitBaselineRiseMin
\NC big_op_spacing3
\NC \NR
275 \NC \type {\Umathlimitabovekern} \NC --
\NC 0$^
1$
\NC big_op_spacing5
\NC \NR
276 \NC \type {\Umathlimitabovevgap} \NC --
\NC UpperLimitGapMin
\NC big_op_spacing1
\NC \NR
277 \NC \type {\Umathlimitbelowbgap} \NC --
\NC LowerLimitBaselineDropMin
\NC big_op_spacing4
\NC \NR
278 \NC \type {\Umathlimitbelowkern} \NC --
\NC 0$^
1$
\NC big_op_spacing5
\NC \NR
279 \NC \type {\Umathlimitbelowvgap} \NC --
\NC LowerLimitGapMin
\NC big_op_spacing2
\NC \NR
280 \NC \type {\Umathoverdelimitervgap} \NC --
\NC StretchStackGapBelowMin
\NC big_op_spacing1
\NC \NR
281 \NC \type {\Umathoverdelimiterbgap} \NC --
\NC StretchStackTopShiftUp
\NC big_op_spacing3
\NC \NR
282 \NC \type {\Umathunderdelimitervgap} \NC--
\NC StretchStackGapAboveMin
\NC big_op_spacing2
\NC \NR
283 \NC \type {\Umathunderdelimiterbgap} \NC--
\NC StretchStackBottomShiftDown
\NC big_op_spacing4
\NC \NR
284 \NC \type {\Umathoverbarkern} \NC --
\NC OverbarExtraAscender
\NC default_rule_thickness
\NC \NR
285 \NC \type {\Umathoverbarrule} \NC --
\NC OverbarRuleThickness
\NC default_rule_thickness
\NC \NR
286 \NC \type {\Umathoverbarvgap} \NC --
\NC OverbarVerticalGap
\NC 3*default_rule_thickness
\NC \NR
287 \NC \type {\Umathquad} \NC --
\NC <font_size(f)>$^
1$
\NC math_quad
\NC \NR
288 \NC \type {\Umathradicalkern} \NC --
\NC RadicalExtraAscender
\NC default_rule_thickness
\NC \NR
289 \NC \type {\Umathradicalrule} \NC --
\NC RadicalRuleThickness
\NC <not set>$^
2$
\NC \NR
290 \NC \type {\Umathradicalvgap} \NC D, D'
\NC RadicalDisplayStyleVerticalGap
\NC (default_rule_thickness+
\crlf
291 (abs(math_x_height)/
4))$^
3$
\NC \NR
292 \NC "
\NC T, T', S, S', SS, SS'
\NC RadicalVerticalGap
\NC (default_rule_thickness+
\crlf
293 (abs(default_rule_thickness)/
4))$^
3$
\NC \NR
294 \NC \type {\Umathradicaldegreebefore} \NC --
\NC RadicalKernBeforeDegree
\NC <not set>$^
2$
\NC \NR
295 \NC \type {\Umathradicaldegreeafter} \NC --
\NC RadicalKernAfterDegree
\NC <not set>$^
2$
\NC \NR
296 \NC \type {\Umathradicaldegreeraise} \NC --
\NC RadicalDegreeBottomRaisePercent
\NC <not set>$^
{2,
7}$
\NC \NR
297 \NC \type {\Umathspaceafterscript} \NC --
\NC SpaceAfterScript
\NC script_space$^
4$
\NC \NR
298 \NC \type {\Umathstackdenomdown} \NC D, D'
\NC StackBottomDisplayStyleShiftDown
\NC denom1
\NC \NR
299 \NC "
\NC T, T', S, S', SS, SS'
\NC StackBottomShiftDown
\NC denom2
\NC \NR
300 \NC \type {\Umathstacknumup} \NC D, D'
\NC StackTopDisplayStyleShiftUp
\NC num1
\NC \NR
301 \NC "
\NC T, T', S, S', SS, SS'
\NC StackTopShiftUp
\NC num3
\NC \NR
302 \NC \type {\Umathstackvgap} \NC D, D'
\NC StackDisplayStyleGapMin
\NC 7*default_rule_thickness
\NC \NR
303 \NC "
\NC T, T', S, S', SS, SS'
\NC StackGapMin
\NC 3*default_rule_thickness
\NC \NR
304 \NC \type {\Umathsubshiftdown} \NC --
\NC SubscriptShiftDown
\NC sub1
\NC \NR
305 \NC \type {\Umathsubshiftdrop} \NC --
\NC SubscriptBaselineDropMin
\NC sub_drop
\NC \NR
306 \NC \type {\Umathsubsupshiftdown} \NC --
\NC SubscriptShiftDownWithSuperscript$^
8$
\NC \NC \NR
307 \NC \NC \NC \quad\ or SubscriptShiftDown
\NC sub2
\NC \NR
308 \NC \type {\Umathsubtopmax} \NC --
\NC SubscriptTopMax
\NC (abs(math_x_height *
4) /
5)
\NC \NR
309 \NC \type {\Umathsubsupvgap} \NC --
\NC SubSuperscriptGapMin
\NC 4*default_rule_thickness
\NC \NR
310 \NC \type {\Umathsupbottommin} \NC --
\NC SuperscriptBottomMin
\NC (abs(math_x_height) /
4)
\NC \NR
311 \NC \type {\Umathsupshiftdrop} \NC --
\NC SuperscriptBaselineDropMax
\NC sup_drop
\NC \NR
312 \NC \type {\Umathsupshiftup} \NC D
\NC SuperscriptShiftUp
\NC sup1
\NC \NR
313 \NC "
\NC T, S, SS,
\NC SuperscriptShiftUp
\NC sup2
\NC \NR
314 \NC "
\NC D', T', S', SS'
\NC SuperscriptShiftUpCramped
\NC sup3
\NC \NR
315 \NC \type {\Umathsupsubbottommax} \NC --
\NC SuperscriptBottomMaxWithSubscript
\NC (abs(math_x_height *
4) /
5)
\NC \NR
316 \NC \type {\Umathunderbarkern} \NC --
\NC UnderbarExtraDescender
\NC default_rule_thickness
\NC \NR
317 \NC \type {\Umathunderbarrule} \NC --
\NC UnderbarRuleThickness
\NC default_rule_thickness
\NC \NR
318 \NC \type {\Umathunderbarvgap} \NC --
\NC UnderbarVerticalGap
\NC 3*default_rule_thickness
\NC \NR
319 \NC \type {\Umathconnectoroverlapmin} \NC --
\NC MinConnectorOverlap
\NC 0$^
5$
\NC \NR
324 Note
1:
\OPENTYPE\ fonts set
\type {\Umathlimitabovekern} and
\type
325 {\Umathlimitbelowkern} to zero and set
\type {\Umathquad} to the font size of the
326 used font, because these are not supported in the
\type {MATH
} table,
328 Note
2:
\TFM\ fonts do not set
\type {\Umathradicalrule} because
\TEX82\ uses the
329 height of the radical instead. When this parameter is indeed not set when
330 \LUATEX\ has to typeset a radical, a backward compatibility mode will kick in
331 that assumes that an oldstyle
\TEX\ font is used. Also, they do not set
\type
332 {\Umathradicaldegreebefore},
\type {\Umathradicaldegreeafter}, and
\type
333 {\Umathradicaldegreeraise}. These are then automatically initialized to
334 $
5/
18$quad, $-
10/
18$quad, and
60.
336 Note
3: If tfm fonts are used, then the
\type {\Umathradicalvgap} is not set until
337 the first time
\LUATEX\ has to typeset a formula because this needs parameters
338 from both family2 and family3. This provides a partial backward compatibility
339 with
\TEX82, but that compatibility is only partial: once the
\type
340 {\Umathradicalvgap} is set, it will not be recalculated any more.
342 Note
4: (also if tfm fonts are used) A similar situation arises wrt.
\type
343 {\Umathspaceafterscript}: it is not set until the first time
\LUATEX\ has to
344 typeset a formula. This provides some backward compatibility with
\TEX82. But
345 once the
\type {\Umathspaceafterscript} is set,
\type {\scriptspace} will never be
348 Note
5: Tfm fonts set
\type {\Umathconnectoroverlapmin} to zero because
\TEX82\
349 always stacks extensibles without any overlap.
351 Note
6: The
\type {\Umathoperatorsize} is only used in
\type {\displaystyle}, and is
352 only set in
\OPENTYPE\ fonts. In
\TFM\ font mode, it is artificially set to one
353 scaled point more than the initial attempt's size, so that always the
\quote
354 {first next
} will be tried, just like in
\TEX82.
356 Note
7: The
\type {\Umathradicaldegreeraise} is a special case because it is the
357 only parameter that is expressed in a percentage instead of as a number of scaled
360 Note
8:
\type {SubscriptShiftDownWithSuperscript
} does not actually exist in the
361 \quote {standard
} Opentype Math font Cambria, but it is useful enough to be
364 Note
9:
\type {FractionDelimiterDisplayStyleSize
} and
\type
365 {FractionDelimiterSize
} do not actually exist in the
\quote {standard
} Opentype
366 Math font Cambria, but were useful enough to be added.
368 \section{Math spacing setting
}
370 Besides the parameters mentioned in the previous sections, there are also
64 new
371 primitives to control the math spacing table (as explained in Chapter~
18 of the
372 \TEX book). The primitive names are a simple matter of combining two math atom
373 types, but for completeness' sake, here is the whole list:
382 \Umathordclosespacing
383 \Umathordpunctspacing
384 \Umathordinnerspacing
398 \Umathbinclosespacing
399 \Umathbinpunctspacing
400 \Umathbininnerspacing
406 \Umathrelclosespacing
407 \Umathrelpunctspacing
408 \Umathrelinnerspacing
413 \Umathopenopenspacing
414 \Umathopenclosespacing
415 \Umathopenpunctspacing
416 \Umathopeninnerspacing
417 \Umathcloseordspacing
419 \Umathclosebinspacing
420 \Umathcloserelspacing
421 \Umathcloseopenspacing
422 \Umathcloseclosespacing
423 \Umathclosepunctspacing
424 \Umathcloseinnerspacing
425 \Umathpunctordspacing
427 \Umathpunctbinspacing
428 \Umathpunctrelspacing
429 \Umathpunctopenspacing
430 \Umathpunctclosespacing
431 \Umathpunctpunctspacing
432 \Umathpunctinnerspacing
433 \Umathinnerordspacing
435 \Umathinnerbinspacing
436 \Umathinnerrelspacing
437 \Umathinneropenspacing
438 \Umathinnerclosespacing
439 \Umathinnerpunctspacing
440 \Umathinnerinnerspacing
444 These parameters are of type
\type {\muskip}, so setting a parameter can be done
448 \Umathopordspacing\displaystyle=
4mu plus
2mu
451 They are all initialized by initex to the values mentioned in the table in
452 Chapter~
18 of the
\TEX book.
454 Note
1: for ease of use as well as for backward compatibility,
\type
455 {\thinmuskip},
\type {\medmuskip} and
\type {\thickmuskip} are treated
456 especially. In their case a pointer to the corresponding internal parameter is
457 saved, not the actual
\type {\muskip} value. This means that any later changes to
458 one of these three parameters will be taken into account.
460 Note
2: Careful readers will realise that there are also primitives for the items
461 marked
\type {*
} in the
\TEX book. These will not actually be used as those
462 combinations of atoms cannot actually happen, but it seemed better not to break
463 orthogonality. They are initialized to zero.
465 \section[mathacc
]{Math accent handling
}
467 \LUATEX\ supports both top accents and bottom accents in math mode, and math
468 accents stretch automatically (if this is supported by the font the accent comes
469 from, of course). Bottom and combined accents as well as fixed-width math accents
470 are controlled by optional keywords following
\type {\Umathaccent}.
472 The keyword
\type {bottom
} after
\type {\Umathaccent} signals that a bottom accent
473 is needed, and the keyword
\type {both
} signals that both a top and a bottom
474 accent are needed (in this case two accents need to be specified, of course).
476 Then the set of three integers defining the accent is read. This set of integers
477 can be prefixed by the
\type {fixed
} keyword to indicate that a non-stretching
478 variant is requested (in case of both accents, this step is repeated).
483 \Umathaccent both fixed
0 0 "
20D7 fixed
0 0 "
20D7
{example
}
486 If a math top accent has to be placed and the accentee is a character and has a
487 non-zero
\type {top_accent
} value, then this value will be used to place the
488 accent instead of the
\type {\skewchar} kern used by
\TEX82.
490 The
\type {top_accent
} value represents a vertical line somewhere in the
491 accentee. The accent will be shifted horizontally such that its own
\type
492 {top_accent
} line coincides with the one from the accentee. If the
\type
493 {top_accent
} value of the accent is zero, then half the width of the accent
494 followed by its italic correction is used instead.
496 The vertical placement of a top accent depends on the
\type {x_height
} of the
497 font of the accentee (as explained in the
\TEX book), but if value that turns out
498 to be zero and the font had a MathConstants table, then
\type {AccentBaseHeight
}
501 If a math bottom accent has to be placed, the
\type {bot_accent
} value is checked
502 instead of
\type {top_accent
}. Because bottom accents do not exist in
\TEX82, the
503 \type {\skewchar} kern is ignored.
505 The vertical placement of a bottom accent is straight below the accentee, no
506 correction takes place.
508 \section{Math root extension
}
510 The new primitive
\type {\Uroot} allows the construction of a radical noad
511 including a degree field. Its syntax is an extension of
\type {\Uradical}:
514 \Uradical <fam integer> <char integer> <radicand>
515 \Uroot <fam integer> <char integer> <degree> <radicand>
518 The placement of the degree is controlled by the math parameters
\type
519 {\Umathradicaldegreebefore},
\type {\Umathradicaldegreeafter}, and
\type
520 {\Umathradicaldegreeraise}. The degree will be typeset in
\type
521 {\scriptscriptstyle}.
523 \section{Math kerning in super- and subscripts
}
525 The character fields in a lua-loaded OpenType math font can have a
\quote
526 {mathkern
} table. The format of this table is the same as the
\quote {mathkern
}
527 table that is returned by the
\type {fontloader
} library, except that all height
528 and kern values have to be specified in actual scaled points.
530 When a super- or subscript has to be placed next to a math item,
\LUATEX\ checks
531 whether the super- or subscript and the nucleus are both simple character items.
532 If they are, and if the fonts of both character imtes are OpenType fonts (as
533 opposed to legacy
\TEX\ fonts), then
\LUATEX\ will use the OpenType MATH
534 algorithm for deciding on the horizontal placement of the super- or subscript.
536 This works as follows:
540 The vertical position of the script is calculated.
543 The default horizontal position is flat next to the base character.
546 For superscripts, the italic correction of the base character is added.
549 For a superscript, two vertical values are calculated: the bottom of the
550 script (after shifting up), and the top of the base. For a subscript, the two
551 values are the top of the (shifted down) script, and the bottom of the base.
554 For each of these two locations:
557 find the mathkern value at this height for the base (for a subscript
558 placement, this is the bottom_right corner, for a superscript
559 placement the top_right corner)
562 find the mathkern value at this height for the script (for a
563 subscript placement, this is the top_left corner, for a superscript
564 placement the bottom_left corner)
567 add the found values together to get a preliminary result.
572 The horizontal kern to be applied is the smallest of the two results from
577 The mathkern value at a specific height is the kern value that is specified by the
578 next higher height and kern pair, or the highest one in the character (if there is no
579 value high enough in the character), or simply zero (if the character has no mathkern
582 \section{Scripts on horizontally extensible items like arrows
}
584 The primitives
\type {\Uunderdelimiter} and
\type {\Uoverdelimiter} allow the
585 placement of a subscript or superscript on an automatically extensible item and
586 \type {\Udelimiterunder} and
\type {\Udelimiterover} allow the placement of an
587 automatically extensible item as a subscript or superscript on a nucleus. The
590 % these produce radical noads .. in fact the code base has the numbers wrong for
591 % quite a while, so no one seems to use this
594 $
\Uoverdelimiter 0 "
2194 {\hbox{\strut overdelimiter
}}$
595 $
\Uunderdelimiter 0 "
2194 {\hbox{\strut underdelimiter
}}$
596 $
\Udelimiterover 0 "
2194 {\hbox{\strut delimiterover
}}$
597 $
\Udelimiterunder 0 "
2194 {\hbox{\strut delimiterunder
}}$
600 \typebuffer will render this:
602 \blank \startnarrower \getbuffer \stopnarrower \blank
604 The vertical placements are controlled by
\type {\Umathunderdelimiterbgap},
\type
605 {\Umathunderdelimitervgap},
\type {\Umathoverdelimiterbgap}, and
\type
606 {\Umathoverdelimitervgap} in a similar way as limit placements on large operators.
607 The superscript in
\type {\Uoverdelimiter} is typeset in a suitable scripted style,
608 the subscript in
\type {\Uunderdelimiter} is cramped as well.
610 \section {Extensible delimiters
}
612 \LUATEX\ internally uses a structure that supports
\OPENTYPE\
\quote
613 {MathVariants
} as well as
\TFM\
\quote {extensible recipes
}.
615 \section{Other Math changes
}
617 \subsection {Verbose versions of single-character math commands
}
619 \LUATEX\ defines six new primitives that have the same function as
620 \type {^
},
\type {_
},
\type {$
}, and
\type {$$
}.
%$
622 \starttabulate[|l|l|l|l|
]
623 \NC \bf primitive
\NC \bf explanation
\NC \NR
624 \NC \type {\Usuperscript} \NC Duplicates the functionality of
\type {^
} \NC \NR
625 \NC \type {\Usubscript} \NC Duplicates the functionality of
\type {_
} \NC \NR
626 \NC \type {\Ustartmath} \NC Duplicates the functionality of
\type {$
},
% $
627 when used in non-math mode.
\NC \NR
628 \NC \type {\Ustopmath} \NC Duplicates the functionality of
\type {$
},
% $
629 when used in inline math mode.
\NC \NR
630 \NC \type {\Ustartdisplaymath} \NC Duplicates the functionality of
\type {$$
},
% $$
631 when used in non-math mode.
\NC \NR
632 \NC \type {\Ustopdisplaymath} \NC Duplicates the functionality of
\type {$$
},
% $$
633 when used in display math mode.
\NC \NR
636 The
\type {\Ustopmath} and
\type {\Ustopdisplaymath} primitives check if the current
637 math mode is the correct one (inline vs.\ displayed), but you can freely intermix
638 the four mathon|/|mathoff commands with explicit dollar sign(s).
640 \subsection{Allowed math commands in non-math modes
}
642 The commands
\type {\mathchar}, and
\type {\Umathchar} and control sequences that
643 are the result of
\type {\mathchardef} or
\type {\Umathchardef} are also
644 acceptable in the horizontal and vertical modes. In those cases, the
\type
645 {\textfont} from the requested math family is used.
649 The following items are still todo.
659 Flattened accents for high characters (maybe).
662 Better control over the spacing around displays and handling of equation numbers.
665 Support for multi|-|line displays using
\MATHML\ style alignment points.