Combine arevmath (or similar) with unicode-math

fontspecluatexunicode-math

Say I need to use a certain sans serif font (not Arial, but I am using this in the example, because it is widely available). As a consequence, I need to use a sans serif math font.

The main font obviously does not have the full math palette, so I need a sans serif math. My idea was to use the arevmath package, because I like the symbols and think they fit quite well — except for the numbers. So my idea was to use unicode-math in order to use upright numbers and latin letters from the main font.

\documentclass{article}

\usepackage{fontspec}
\usepackage{arevmath}
\usepackage{unicode-math}

\setmainfont{arial}
%\setmathfont{firamath}  %% <--- using this, it will work
\setmathfont{arial}[range={up/{num,latin}}]


\begin{document}
test 123 $123$
\end{document}

The above code yields the following error:

Package unicode-math Error: No main maths font has been set up yet.
(unicode-math)                If you simply want ‘the default’, use: 
(unicode-math)                  \setmathfont{latinmodern-math.otf}

I suppose this comes from the fact that arevmath uses "classic" LaTeX font selection methods whereas unicode-math relies on newer techniques, so the font is not properly "registered".

If I uncomment the line \setmathfont{firamath}, it works, except that IMHO the fonts do not match very well.

How can I use Arev (and associates) for mathematical symbols, but still use the main font for numbers and latin letters?

Best Answer

If you want to use arevmath you can try to use the text font with it as operator font:

\documentclass{article}

\usepackage{fontspec}
\setmainfont{arial}[NFSSFamily=arial]

\usepackage{arevmath}
\SetSymbolFont{operators}    {normal}{TU}{arial}{m}{n}
\SetSymbolFont{operators}    {bold}{TU}{arial}{b}{n}

\begin{document}
test 123 $123 test$ \mathversion{bold} $123 test$
\end{document}

enter image description here

Related Question