[luatex] Missing math primitive & assorted remarks

Will Robertson wspr81 at gmail.com
Tue Jul 13 08:25:29 CEST 2010


I know this is a little late to be reporting the problem... I just 
realised that I missed documenting a maths primitive in xetexref, and 
LuaTeX is also missing it.

\XeTeXmathcharnumdef is the "logical" extension to \mathchar, which 
uses a single integer input to encode the fam/type/slot information. 
This primitive is used where legacy code would look like:

    \mathchardef\foo=\mathcode`\-  % (e.g., see amsmath)

I'm not stuck on any code that needs this feature (and I think that 
\omathchardef probably supports most uses anyway?) but the primitive 
should probably be included in some later version of LuaTeX.

* * *

I should probably just mention that the LuaTeX manual is a little 
unclear on the use of "num" variants of the primitives; they're 
intended for when the mathcode information needs to be passed around as 
in the example above; without the "num" primitives, you could query the 
single-integer mathcode information but you couldn't do anything useful 
with it.

(Not that you can do anything useful easily like break it apart to find 
out what fam your using for a math char, but I don't have any good 
ideas for how you'd approach doing that -- from a TeX programming 
perspective, anyway.)

* * *

While I'm on the topic, I've just discovered a small difference in the 
way XeTeX and LuaTeX handle the legacy "\mathcode" primitive when it is 
used to query the mathcode of a character. See attached example, 
compiled with both engines; the difference is that in LuaTeX, \mathcode 
behaves like \Umathcodenum always, whereas in XeTeX \mathcode retains 
its legacy behaviour.

I'm not sure if this causes any problems in practise (well, the reason 
I discovered it is that amsmath broke in LuaLaTeX but not XeLaTeX, but 
that code probably needs to be patched for unicode maths anyway) but I 
just wanted to mention it in case it's not intentional.


  \let \Umathcode\XeTeXmathcode
  \let \Umathcodenum\XeTeXmathcodenum
  \input luaotfload.sty\relax
  \let \Umathcode\luatexUmathcode
  \let \Umathcodenum\luatexUmathcodenum

\def\mth{Cambria Math}
\font\4="\mth:script=math;color=FF0000" at 10pt
\Umathcode `\( = "4 "4 "28



More information about the luatex mailing list