1

I know there are a lot of posts about this here on tex.stackexchange but all I can find are pretty old (almost ~ 5-10 years old by now) and I'm not sure if they still apply.

So is there a way to use a sans serif font for the normal text characters in math mode?

\documentclass{scrartcl}

\usepackage{fontspec}
\renewcommand{\familydefault}{\sfdefault}

\usepackage{amsmath}
\usepackage[math-style=ISO]{unicode-math}
\setmathfont{Latin Modern Math}
\setmathfont{Latin Modern Math}[version=bold,FakeBold={3}]
\setoperatorfont\mathsf

\begin{document}
    normal text

    $(a+\rho_i)^2 = a^2 + 2a\rho_i \rho_i^2 \quad \min\text{ text in math}$
\end{document}

output of code above

In this example it would be an issue for the i indices and the a variable.

2 Answers 2

1

Set any OpenType math font using unicode-math. it’s the simplest way.

The unicode-math package also lets you take Greek letters from another font with, e.g. \setmathfont[range=it/{Greek, greek}]{CMU Sans Serif Italic}, but all OpenType math fonts support Greek.

There are also solutions using mathastext and mathspec, or you could load fontspec over any legacy 8-bit sans-serif math package.

5
  • 1
    Alright, I'll have a look at the various fonts available. Note: For your \setmathexamle I get an error missing number. Seems like the range argument isn't completely correct.
    – atticus
    Commented Mar 3 at 9:22
  • 1
    @atticus Whoops! You got me. Should work now. There’are separate commands for upright, bold italic, and bold upright, should you need them. But any OpenType math font has those.
    – Davislor
    Commented Mar 3 at 9:41
  • In these tables like in ftp.rrzn.uni-hannover.de/pub/mirror/tex-archive/fonts/firamath/… do you know what it means if a glyph is grayed out? Does this mean it is not available (and I need to search for a font which includes that glyph)?
    – atticus
    Commented Mar 3 at 11:30
  • 1
    @atticus I believe that’s correct, but all the Greek letters used in math are available. The upright (\symup) alphabet is in the Greek and Coptic code block, which is missing only Coptic, and the other alphabets, including the default, are in Mathematical Alphanumeric Symbols.
    – Davislor
    Commented Mar 3 at 17:01
  • 1
    @atticus It does appear to be lacking \mathcal or \mathscr, however.
    – Davislor
    Commented Mar 3 at 17:02
1

To get a sans serif font you should set a sans serif font; Latin Modern isn't. You need a font with math support. See: Which OpenType Math fonts are available?.

For example, with FiraMath-Regular:

\documentclass{scrartcl}

\usepackage{fontspec}
\renewcommand{\familydefault}{\sfdefault}

\usepackage{amsmath}
\usepackage[math-style=ISO]{unicode-math}
\setoperatorfont\symup
\setmathfont{FiraMath-Regular}

\begin{document}
    normal text

    $(a+\rho_i)^2 = a^2 + 2a\rho_i \rho_i^2 \quad \min\text{ text in math}$

\end{document}

This gives: Code with FiraMath-Regular font

I set \setoperatorfont\symup to handle operator (like \min) with unicode-math.

1
  • Oh the symup note is a nice one. Sadly FiraMath-Regular seems to be lacking the \bigcup and \setminus symbols. But I get I have to look further into different fonts.
    – atticus
    Commented Mar 3 at 9:26

You must log in to answer this question.

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