latex3 / unicode-math

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

Provide \addmathfontfeature, \mathfontspec etc #496

Open stone-zeng opened 5 years ago

stone-zeng commented 5 years ago

Description

In fontspec package, one can use \addfontfeature to add features for a loaded font, and can use \fontspec to specify a font in the document. Could you please consider to add the commands for math font, e.g. \addmathfontfeature and \mathfontspec etc.?

At present, to use different math font or different features, we must use mathversion, which is not convenient.

Check/indicate

Minimal example demonstrating the issue

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{XITS Math}
\begin{document}
% This formula is in XITS Math
\[ a = b \]

% This formula is in Latin Modern Math
{\mathfontspec{Latin Modern Math} \[ a = b \]}

% This formula is in XITS Math with upright integrals (ss08)
{\addmathfontfeature{StylisticSet=8} \[ a = b \]}
\end{document}

Further details

wspr commented 5 years ago

Hmm, I’m not sure about this.

For sure I need to improve the interfaces here, but changing maths font mid-document is a very “heavy” operation and I don’t want to encourage it (in fact, LaTeX is not in any way designed for this, and it’s a bit of a hack that I made it work in unicode-math at all).

OTOH if there are particular use cases (like switching integral style?) maybe there are other ways to accommodate this so I’ll leave the issue open.