2

This is the code I used with pdflatex

\DeclareMathVersion{sans}
% Math letters from Latin Modern Sans
\SetSymbolFont{letters}{sans}{OML}{cmbr}{m}{it}
% Math operators
\SetSymbolFont{operators}{sans}{OT1}{lmss}{m}{n}
% Math symbols
\SetSymbolFont{symbols}{sans}{OMS}{lmsy}{m}{n}
% Large symbols
\SetMathAlphabet{\mathrm}{sans}{OT1}{lmr}{m}{n}
\SetMathAlphabet{\mathsf}{sans}{OT1}{lmss}{m}{n}
\SetMathAlphabet{\mathit}{sans}{OT1}{lmr}{m}{it}

and in the code I could select it using

\mathversion{sans}

Now I am looking for something similar with luatex. A Math version of Latin Modern Sans is not defined

\setmathfont{Latin Modern Sans Math}    % does not compile

The only known workaround is this, but

\setmainfont{Latin Modern Sans} 
\usepackage[italic]{mathastext}
\setmainfont{Latin Modern Roman}
\setsansfont{Latin Modern Sans}
\setmonofont{Latin Modern Mono}

it does not allow to select the math font in the code. How can I implement the code from above for lualatex und fontspec and unicode-math?

1 Answer 1

2

First, be aware that unicode-math has both \symsfup and \symsfit alphabets (for sans-serif math symbols) as well as \mathsfup and \mathsfit (for sans-serif words in math mode). You might not need a sans math version, if this covers your needs.

Assuming you do: you asked about Latin Modern Sans in the title, but you are in fact using Computer Modern Bright in your code sample, not Latin Modern Sans or Computer Modern Sans. In this MWE, I will use New Computer Modern Sans, which (unlike Latin Modern Sans) supports Greek.

If you want to use sans-serif math letters (but the default math symbols) all the time, you can use

\documentclass{article}
\usepackage{unicode-math}

\setmainfont{NewCM10-Book}
\setsansfont{NewCMSans10-Book}
\setmonofont{NewCMMono10-Book}
\setmathfont{NewCMMath-Book}
\setmathfont{NewCMSans10-Book}[range=up,
                               script-font=NewCMSans08-Book,
                               sscript-font=NewCMSans08-Book]
\setmathfont{NewCMsans10-BookOblique}[range=it,
                                      script-font=NewCMSans08-BookOblique,
                                      sscript-font=NewCMSans08-BookOblique]
% Define bfup and bfit fonts here, if needed.

\begin{document}

\[ v = \symup{e}^{\theta_t} + \symup{c} \]

\end{document}

New Computer Modern Book sample

If you still want New Computer Modern Bright with unicode-math, you must use CMUBright-Roman and CMUBright-Oblique, which support Greek.

This will not, however, give you a \mathversion{sans} that you can switch to. You can do that with the version= option of \setmathfont, but only to switch between a serif and sans-serif math font, e.g.:

\documentclass{article}
\usepackage{unicode-math}

\setmainfont{KPRoman}
\setmathfont{KPSans}
\setmonofont{KPMono}
\setmathfont{KPMath-Regular}
\setmathfont{KPMath-Sans}[version=sans]

\newcommand\sansmath{\mathversion{sans}}

\begin{document}

\[ v = \symup{e}^{\theta_t} + \symup{c} \]
\sansmath
\[ v = \symup{e}^{\theta_t} + \symup{c} \]

\end{document}

Kepler fonts sample

As of 2022, you unfortunately cannot combine range= and version= in the same document. You can either kitbash a math font with letters from a different text font, or define another math version, but not both.

Finally, you can keep using the same NFSS math-mode commands in LuaLaTeX. Loading fontspec will not change math mode, other than \mathrm, \mathsf, and so on.

You must log in to answer this question.

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