latex3 / unicode-math

XeLaTeX/LuaLaTeX package for using unicode/OpenType maths fonts
http://ctan.org/pkg/unicode-math
LaTeX Project Public License v1.3c
239 stars 28 forks source link

For lualatex, if the main math font is TeX Gyre Termes Math, simplify and document getting new characters from STIX Math or STIX Two Math without causing unrelated issues. #637

Open AlMa1r opened 1 week ago

AlMa1r commented 1 week ago

(History: http://tex.stackexchange.com/a/721080 .)

Let's set our main math font as TeX Gyre Termes Math. We also wish to get some symbol(s) not existing in TeX Gyre Termes Math from another math font. To this end, we write

\setmathfont{TeX Gyre Termes Math}
\setmathfont[Extension=.otf,range={…}]{STIXTwoMath-Regular}% Specify the Unicode position(s) in the value of range.

However, this leads to a warning in the log (“Script 'Math' not explicitly supported within font 'STIXMath-Regular'”) and, if lualatex is used, superfluous vertical gaps in \substack{…\\…}, \stackrel{…}{…}, \frac{…}{…}, and \underbrace{…}_{…}. To remove these gaps, we append

\setmathfont[range={}]{TeX Gyre Termes Math}% Leave the value of the range parameter empty or put \int there.

Combined:

\documentclass{article}
\pagestyle{empty}
\usepackage{unicode-math}
\setmathfont{TeX Gyre Termes Math}
\setmathfont[Extension=.otf,range={"2040}]{STIXTwoMath-Regular}% Adding some char not present in the default math font.
\setmathfont[range={}]{TeX Gyre Termes Math}% Without this line, you get unwanted vertical space in the output below when compiling with lualatex.
\begin{document}
\(\stackrel{\text{def}}{\Longleftrightarrow} \frac{m}{n}\ \substack{1\\2} \underbrace{\langle\rangle\dotsm \langle\rangle}_{k\ \text{terms}}\)
\end{document}

Running lualatex on this yields: grafik This seems to work but is (1) undocumented (at least not visibly documented in unicode-math.pdf), (2) a bit bloated, and (3) misleading (the last \setmathfont[range=… doesn't really request a range of new characters; also, from a high-level viewpoint, a user doesn't really wish to mention TeX Gyre Termes Math twice just because of the way things currently work internally).

In this issue report, we ask to simplify and/or document the user's interface to adding new characters when using lualatex without causing unrelated issues (here: vertical gaps).

(Two asides are to be made. First, for xelatex, the issue doesn't exist; you may drop the last \setmathfont… line. Second, I have not tested other pairs of fonts; if you have, please feel free to change this report, including its title.)