1

I am writing a document which is mostly typeset with the STIX TWO fonts and compiled via XeLaTeX. Math mode is configured via unicode-math.

In certain contexts, I need an Arial/Helvetica/Tex Gyre Heros type sans-serif font. (It's ok if these sections come out a bit rugged, i.e. the missing scshape is no problem at all. I want to manually annotate diagrams which are itself set in Arial.)

For the normal text font, I set up a newfontface. Now I want to do the same for the math font, which I tried to achieve by defining a dedicated mathversion. Unfortunately this blocks the use of unicode-math range parameters, as range and version do not play well together.

As there is no such math font (using Fira Math compiles, but it looks quite different from Arial), I tried to use NFSS commands for that version definition.

Eventually, this fails with:

LaTeX Font Warning: Font shape `TU/Arial/m/n' undefined
(Font)              using `TU/lmr/m/n' instead on input line 29.

! Math formula deleted: Insufficient symbol fonts.
\resetMathstrut@ ->\setbox \z@ \hbox {$($
                                         }\ht \Mathstrutbox@ \ht \z@ \dp \Ma...
l.29 \begin{equation}

I put together a minimal example that demonstrates my problem:

\documentclass[english]{scrartcl}
\usepackage[math-style=ISO, bold-style=ISO]{unicode-math}

\defaultfontfeatures{Scale = MatchUppercase}
\setmainfont[Scale=0.97]{STIX Two Text}
\setmathfont[Scale=0.97]{STIX Two Math}
\setsansfont[Scale=1.07]{Libertinus Sans}

\newfontface\rootsans{Arial}
%\setmathfont[version=rootsans]{Fira Math} % <-- This works but Fira!=Arial

\DeclareMathVersion{rootsans} %<-- Tried an alternative approach, so far without success
\SetSymbolFont{letters}{rootsans}{TU}{Arial}{m}{n}
\SetSymbolFont{operators}{rootsans}{TU}{Arial}{m}{n}
\SetSymbolFont{symbols}{rootsans}{TU}{Arial}{m}{n}
\SetSymbolFont{largesymbols}{rootsans}{TU}{Arial}{m}{n}
\SetMathAlphabet{\mathrm}{rootsans}{TU}{Arial}{m}{n}

\begin{document}

\textsc{Euler}'s identity in normal mode:
\begin{equation}
e^{i\phi} + 1 = 0
\end{equation}

\rootsans
\mathversion{rootsans}
\textsc{Euler}'s identity with special font setting: 
\begin{equation}
e^{i\phi} + 1 = 0
\end{equation}
\end{document}

If I omit the mathversion everything works, but equation (2) does not match its the preceding line.

Is there anything I can do or do I have to live with Fira Math as Arial companion?

2
  • Welcome to TeX.SE!
    – Mensch
    Jan 15 at 22:26
  • 1
    Arial doesn't have the Mathematical Alphanumeric Symbols unicode block (about 1k characters), and only 17 out of 256 Mathematical Operators, so there will be lots of blanks. What about Noto Sans Math (not a maths font, i.e., OpenType math features and tables, but has the symbols)?
    – Cicada
    Jan 16 at 10:30

1 Answer 1

3

Not quite clear how you want to use text mode as if it were math mode (if I understand correctly), but you would have to do layout "by hand", or create a set of "text as math" commands with \setmathfontface (regular, italic, bold, etc).

Here, version with Noto Sans Math, and Fira Math; and by-hand Arial (which does not have dedicated mathematical Unicode blocks but luckily has Greek and Latin in it as text).

example

Note that 𝑒 (U+1D452 MATHEMATICAL ITALIC SMALL E) is not the same as a text roman e rendered in an italic face. Likewise with the sans 𝘦 (`U+1D626 MATHEMATICAL SANS-SERIF ITALIC SMALL E).

MWE

\documentclass{scrartcl}
\usepackage{xcolor}
\usepackage[math-style=ISO, bold-style=ISO]{unicode-math}

\defaultfontfeatures{Scale = MatchUppercase}
\setmathfont[Scale=0.97]{STIX Two Math}
\setmainfont[Scale=0.97]{STIX Two Text}
\setsansfont[Scale=1.07]{Libertinus Sans}
%\setmathfontface{\textm}[Scale=0.97]{Arial} % regular face

\newfontfamily\mysans{Arial}
\setmathfont[version=rootsans,Colour=blue]{Noto Sans Math} %
\setmathfont[version=rootsansb,Colour=red]{Fira Math} %


\begin{document}

\textsc{Euler}'s identity in normal mode:
\begin{equation}
e^{i\phi} + 1 = 0
\end{equation}

%\rootsans
\mathversion{rootsans}
\textsc{Euler}'s identity with special font setting (Noto Sans Math): 
\begin{equation}
e^{i\phi} + 1 = 0
\end{equation}


\mathversion{rootsansb}
\textsc{Euler}'s identity with special font setting (Fira Math): 
\begin{equation}
e^{i\phi} + 1 = 0
\end{equation}

{\mysans This is Arial: \textit{e\textsuperscript{iφ}} + 1 = 0}

\end{document}

Edit

There are various ways of accessing the alphabets in a math font (here, STIX Two Math)...

alphabets

... and for a 'text as math' font which is not a math font (here, Arial), the input argument needs to be ordinary text (typeset from an italic face), not a mathematical symbol, i.e., Ο† (U+03C6 GREEK SMALL LETTER PHI) or Ο• (U+03D5 GREEK PHI SYMBOL) depending in the typeface, not πœ™ (U+1D719 MATHEMATICAL ITALIC PHI SYMBOL).

MWE

\documentclass{article}
\usepackage{xcolor}
\usepackage[math-style=ISO, bold-style=ISO]{unicode-math}

\defaultfontfeatures{Scale = MatchUppercase}
\setmathfont[Scale=0.97]{STIX Two Math}
\setmainfont[Scale=0.97]{STIX Two Text}


\setmathfontface{\textarial}[Colour=red,Scale=0.97]{arial.ttf} 
\setmathfontface{\textariali}[Colour=red,Scale=0.97]{ariali.ttf} 

\begin{document}

Default: e $\mapsto e$

\begin{equation}
e^{i\phi} + 1 = 0
\end{equation}

Direct input: $𝘦π˜ͺπœ™πŸ£πŸ’$

\begin{equation}
𝘦^{π˜ͺπœ™} + 𝟣 = 𝟒
\end{equation}

\texttt{\textbackslash sym...} command: \textbackslash symsfit\{e\} $\mapsto \symsfit{e}$

\begin{equation}
\symsfit{e}^{\symsfit{i}\symsfit{\phi}} + \symsf{1} = \symsf{0}
\end{equation}

Named macros\footnote{See ...texmf-dist/tex/latex/unicode-math/unicode-math-table.tex}: \textbackslash mitsanse $\mapsto \mitsanse$

\begin{equation}
\mitsanse^{\mitsansi\mitphi} + \msansone = \msanszero
\end{equation}

\setmathfont{STIX Two Math}[Scale=0.97,range={sfit/latin,it/greek,sfup/num},Colour=blue]

\texttt{range=} option: \texttt{[range=\{sfit/latin,it/greek,sfup/num\}]}

\begin{equation}
\symsfit{e}^{\symsfit{i}\phi} + \symsfup{1} = \symsfup{0}
\end{equation}

`text as math' font (here, Ο• = U+03D5, text Greek):


\begin{equation}
\textariali{e}^{\textariali{i}\textariali{Ο•}} + \textarial{1} = \textarial{0}
\end{equation}


\end{document}
7
  • Shouldn't Noto Sans Math have sans letters? Jan 16 at 11:39
  • I wan't to annotate plots (pdf graphics) further within the main document (e.g. via overpic or a subcaption). These plots use Arial as main font and I wan't the extra annotation to resemble them. As the typeset of the plots is of low quality, I can accept that such subtle differences like 𝑒 <-> 𝘦 would come out wrong. Also I will presumably never need too special math symbols within this context. That said, I would be nice if I could write these annotations in normal LateX code (text and math, siunitx, etc.), so that I can still shuffle pieces around without touching the markup
    – phi-mah
    Jan 16 at 13:18
  • @Apoorv Potnis Also STIX Two Math (main math font) should have sans letters. But as I need these extra math version, I cannot use a range map, e.g. range=up->sfup. This is simply not supported by unicode-math. Cf: github.com/wspr/unicode-math/issues/274
    – phi-mah
    Jan 16 at 13:23
  • With range, you can map sans to cal, say, or fraktur etc, and then use the matching \sym... command. Or map sans to all alphabets. And so on.
    – Cicada
    Jan 17 at 9:46
  • Example where (serif) upright and italic is mapped to bold sans upright.
    – Cicada
    Jan 17 at 9:58

You must log in to answer this question.

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