[luatex] Question about tex.setmath(..., ..., ...) [hope this is the right list]
Ulrike Fischer
luatex at nililand.de
Wed Jul 20 14:31:20 CEST 2016
Am Mon, 18 Jul 2016 22:49:46 +0100 schrieb Graham Douglas:
> Hi All
>
> I'm exploring LuaTeX's OpenType maths capabilities and have a question
> about tex.setmath(...,...,...). A minimal working example is below.
> I can't get tex.setmath(...,...,...) to work and am stumped why---maybe
> I misunderstand its use. In the example below, if I use
>
> \Umathfractionnumup\displaystyle=2pt
> \Umathfractionnumvgap\displaystyle=2.5bp
>
> in the maths, it works fine and adjusts the spacing nicely (see second
> equation in PNG file). However, if I try to apply these settings
> globally via:
>
> \directlua{
> tex.setmath("global", "fractionnumup", "text", 131072)
> tex.setmath("global", "fractionnumvgap", "text", 163840)
> }
>
> then the spacing is not changed. See first equation in the attached PNG
> file (which is the output of the minimal example).
>
> What am I doing wrong, or what have I failed to understand? (Note, also
> tested the above with a recent build of experimental version, 0.97, but
> same result)
The problem is that math fonts in latex are not initialized by
default but only at the first math. So quite often you have to
typeset some formula first to see some effect. So this here works (I
used larger values to see the difference better):
\documentclass[a4paper,10pt,twoside]{book}
\usepackage{amsmath}
\usepackage{fontspec}
\usepackage[math-style=TeX]{unicode-math}
\setmainfont{Constantia}
\setmathfont{Cambria Math}
\def\IHb#1{{\hskip-#1bp\relax}} %
\begin{document}
%needed (or some math formula which calls \check at mathfonts
\makeatletter\check at mathfonts\makeatother
\directlua{
tex.setmath("global", "fractionnumup", "display", 1131072)
tex.setmath("global", "fractionnumvgap", "display", 1163840)
}
\[
\int_{\IHb{3}a}^{\IHb{1.5}b}u\frac{d^2v}{dx^2}\,dx
=\left.u\frac{dv}{dx}\right|_a^b
-\int_{\IHb{3}a}^{\IHb{1.5}b}\frac{du}{dx}\frac{dv}{dx}\,dx.
\]
\end{document}
It's similar with the commands:
\documentclass[a4paper,10pt,twoside]{book}
\usepackage{amsmath}
\usepackage{fontspec}
\usepackage[math-style=TeX]{unicode-math}
\setmainfont{Constantia}
\setmathfont{Cambria Math}
\def\IHb#1{{\hskip-#1bp\relax}} %
\begin{document}
%$a$ %<--- needed
\Umathfractionnumup\displaystyle=20pt
\Umathfractionnumvgap\displaystyle=25.5bp
\[
\int_{\IHb{3}a}^{\IHb{1.5}b}u\frac{d^2v}{dx^2}\,dx
=\left.u\frac{dv}{dx}\right|_a^b
-\int_{\IHb{3}a}^{\IHb{1.5}b}\frac{du}{dx}\frac{dv}{dx}\,dx.
\]
\end{document}
(tested on texlive 2016)
--
Ulrike Fischer
http://www.troubleshooting-tex.de/
More information about the luatex
mailing list