My goal is to use a sans serif math font in all figures and I found several approaches with my favourite being the use of \mathversion
and the unicode-math
package to change between different math fonts.
However, I am not able to switch between fonts due to the warning
Package fontspec Warning: Font "Latin Modern Math" does not contain requested (fontspec) Script "Math".
that repeats for all fonts I import with a [version=]
parameter. However, I can change the math font for the whole document.
So my question: What am I doing wrong? I basically copied my code from another answer (will add the link when I find it again).
My mwe for testing is
\documentclass[authoryear,preprint,5p,11pt]{scrartcl}
\usepackage{amsmath}
\usepackage{pgfplots}
\usepackage{fontspec}
\usepackage[]{unicode-math}
\defaultfontfeatures{ Scale=MatchLowercase, Ligatures=TeX }
\setmathfont{XITS Math}
\setmathfont{Latin Modern Math}[version=lm]
\setmathfont{TeX Gyre Pagella Math}[version=pagella]
\begin{document}
This is some text.
And a figure with maths elements
\begin{figure}[ht]
% \mathversion{sansmath}
\begin{pgfpicture}
\pgftext[x=0.691229in,y=0.540666in,,top]{\sffamily\selectfont 125}%
\pgftext[x=0.354158in,y=0.432447in,left,base]{\sffamily\selectfont \(\displaystyle \frac{-\pi}{2}\)}%
\pgftext[x=1.054158in,y=0.432447in,left,base]{\sffamily\selectfont \(\displaystyle 10^{3123x} \cdot 12389\)}%
\end{pgfpicture}
\end{figure}
and a formula
\[ \frac{\pi}{2.42132}= \beta\]
and some math in another font
\mathversion{lm}
\[ \frac{\pi}{2.42132}= \beta\]
and yet another one
\mathversion{pagella}
\[\frac{123456} {some text}\]
\end{document}
The full logfile is here: https://pastebin.com/kS3quC7A
LatinModernMathJax_Size1-Regular/OT
and similar for Pagella:GyrePagellaMathJax_Symbols-Regular/OT
and this fonts confuses it. Try if it works if you use filenames likelatinmodern-math.otf
instead of the font name./usr/local/share/fonts/OTF
it's working well. You may raise your comment to an answer :)