11

[Note that I am using LuaTeX for all compilations.]

Consider the following MWE which sets up several versions for maths using unicode-math's version key.

\documentclass{article}
\usepackage[math-style=TeX]{unicode-math}
\setmathfont{Latin Modern Math}
\setmathfont{Latin Modern Math}[version=lm]% sanity check
\setmathfont{Asana Math}[version=asana]
\setmathfont{TeX Gyre Schola Math}[version=tgs]
\setmathfont{Tex Gyre Termes Math}[version=tgt]
% \setmathfont{Tex Gyre Schola Math}[version=tgs, range=it]
% \setmathfont{Tex Gyre Termes Math}[version=tgt]
\newcommand*\testmaths{%
\begin{equation}
  \int_{t = 0}^{x^2} t dt
\end{equation}
\[
  \sin^2{\theta} + \cos^2{\theta} = 1
\]
}
\begin{document}
Latin Modern Math (\verb|normal|):
\testmaths

\mathversion{asana}
Asana Math (\verb|asana|):
\testmaths

\mathversion{tgt}
TeX Gyre Termes Math (\verb|tgt|):
\testmaths

\mathversion{normal}
Latin Modern Math (\verb|normal|):
\testmaths

{%
  \mathversion{tgs}
  TeX Gyre Schola Math (\verb|tgs|):
  \testmaths
}

Latin Modern Math (\verb|normal|):
\testmaths

\mathversion{lm}
Latin Modern Math (\verb|lm|):
\testmaths
\end{document}

This works fine.

expected output

However, this code cannot be combined with the use of range. Although the effect of range is to restrict the specified font to the given range, its use is not then restricted to the specified version. Instead, all versions are affected.

% \setmathfont{TeX Gyre Schola Math}[version=tgs]
\setmathfont{Tex Gyre Termes Math}[version=tgt]
\setmathfont{Tex Gyre Schola Math}[version=tgs, range=it]
% \setmathfont{Tex Gyre Termes Math}[version=tgt]

all versions affected

Or, changing the order, the specified range in the specified version simply ends up producing emptiness.

% \setmathfont{TeX Gyre Schola Math}[version=tgs]
% \setmathfont{Tex Gyre Termes Math}[version=tgt]
\setmathfont{Tex Gyre Schola Math}[version=tgs, range=it]
\setmathfont{Tex Gyre Termes Math}[version=tgt]

emptiness

Why is this and can it be corrected?

EDIT

It is, of course, true that the above examples are incomplete because they do not define sufficient stuff for an alternative maths version. To do this, additional configuration would be required to ensure that all ranges are set for the alternative maths version(s). However, this cannot be done unless a single font is used for all ranges for a given version. This is quite unlike the standard case, where you must use multiple fonts to ensure complete coverage.

Here's a non-LuaTeX example using various fonts from Arev. The commands are mostly from arevmath.sty. Note that the macros are, essentially, each setting a relevant range for the new version, sansserif. (Even here, things are not really complete: there are symbols and maths alphabets to worry about. But hopefully the basic idea is clear.)

\documentclass{article}
\usepackage{lmodern}
\DeclareMathVersion{sansserif}
% modified from arev - node that a complete set up would need additional stuff
\SetSymbolFont{operators}    {sansserif}{OT1}{zavm}{m}{n}
\SetSymbolFont{letters}      {sansserif}{OML}{zavm}{m}{it}
\SetSymbolFont{symbols}      {sansserif}{OMS}{zavm}{m}{n}
\SetSymbolFont{largesymbols} {sansserif}{OMX}{mdbch}{m}{n}
\SetMathAlphabet{\mathnormal}{sansserif}{OML}{zavm}{m}{it}
\SetMathAlphabet{\mathit}    {sansserif}{OML}{zavm}{m}{it}
\SetMathAlphabet{\mathrm}    {sansserif}{OT1}{zavm}{m}{n}
\SetMathAlphabet{\mathsf}    {sansserif}{OML}{zavm}{m}{it}
\SetMathAlphabet{\mathbf}    {sansserif}{OT1}{zavm}{b}{n}
\SetMathAlphabet{\mathtt}    {sansserif}{T1} {fvm} {m}{n}
\newcommand*\testmaths{%
\begin{equation}
  \int_{t = 0}^{x^2} t dt
\end{equation}
\[
  \sin^2{\theta} + \cos^2{\theta} = 1
\]
}
\begin{document}
Latin Modern Math (\verb|normal|):
\testmaths

\mathversion{sansserif}
Arev (\verb|sansserif|):
\testmaths

\mathversion{normal}
Latin Modern Math (\verb|normal|):
\testmaths
\end{document}

non-unicode case

The question is how to do the equivalent with unicode-math if you want letters to come from one maths font, say, and operators from another.

4
  • This question is the outcome of my attempting first to answer the linked question and then to diagnose the problems I encountered trying to do so. Hence, anybody who answers this one can probably scoop a double bounty from cjorssen ;).
    – cfr
    Aug 30, 2016 at 21:55
  • What you are trying to do is undefined behaviour. Usually setting \mathversion replaces the whole math font. What should happen when there is a range specified? Should it only display characters from this range and undefine all the others? Should it only apply to characters within range? (But then \mathversion does not work as expected. It is to replace the whole font.) I'd say, \mathversion is the wrong tool for the job. What you want (and need) is \setmathfont. Sep 4, 2016 at 8:37
  • @HenriMenke The example is overly minimal in that respect. That is, of course you would really need to define stuff to ensure that everything is covered by the new version and not just a fraction of it. But it is possible to use different fonts for different bits in standard TeX. (Indeed, it is mandatory.) But there doesn't seem to be a way of doing that here.
    – cfr
    Sep 4, 2016 at 12:49
  • @HenriMenke Please see edit.
    – cfr
    Sep 4, 2016 at 13:13

1 Answer 1

4
+50

Imho the answer to the question is "no". Currently it won't work. unicode-math implements the range option by defining a new math family and then points the symbol(s) to this family. The code is not "version aware".

\documentclass{article}
\usepackage[math-style=TeX]{unicode-math}

\begin{document}
$ a $
[class: \Umathcharclass`\a]
[family: \Umathcharfam`\a]
[slot: \Umathcharslot`\a]


\setmathfont{Tex Gyre Schola Math}[range="61]

$ a $
[class: \Umathcharclass`\a]
[family: \Umathcharfam`\a]
[slot: \Umathcharslot`\a]

\setmathfont{Tex Gyre Termes Math}[range="61]

$ a $
[class: \Umathcharclass`\a]
[family: \Umathcharfam`\a]
[slot: \Umathcharslot`\a]

\end{document}

It would be quite difficult to change this -- on the technical side but also regarding the "logic". unicode-math would have to either store long list of symbols which should be remapped to other fonts if the mathversion change, or remap math fonts and in both case it would have to pay attention to varying range blocks in the various math version versions -- a nightmare for a maintainer.

While I do understand that people like to change (or add) glyphs in a math font I think that the range option should be used with care and not for large scale font manipulations. Imho the future for complicated setups lies not in more unicode-math code but in the "combo" font feature of luaotfload.

5
  • I think you are right. That is, I looked at the code also. (But obviously not knowing as much about it.)
    – cfr
    Sep 4, 2016 at 15:56
  • Thanks Ulrike (+1). Would you mind adding a bit about "combo" font feature and how it could be used here?
    – cjorssen
    Sep 5, 2016 at 20:48
  • @cjorssen I may be mistaken, but I think that is rather a massive ask under current circumstances. Not only is the code developing fast with scant regard for backwards compatibility, but the documentation is not developing with it, leaving people to effectively try to write the documentation by inferring what various things are intended to do through trial-and-error as much as anything. (Or course, backwards compatibility is not really a consideration, as I understand it, because it is beta software. So this is not necessarily a criticism.)
    – cfr
    Sep 6, 2016 at 3:20
  • @cfr You are probably right. I was asking without knowing anything to those "combo" things.
    – cjorssen
    Sep 6, 2016 at 7:50
  • @cjorssen There is an example for a combo font here tex.stackexchange.com/questions/314397/…. Sep 6, 2016 at 8:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .