# Different math-style options for different fonts with unicode-math package

I want to use several math fonts in my document, one of which is Neo Euler. With this font, Latin lowercase is upright, but I want to keep the slanted version for another font:

\setmathfont[version=euler,math-style=upright]{Neo Euler}
\setmathfont[version=bonummath,math-style=ISO]{TeX Gyre Bonum Math}


This doesn't produce any letters when Neo Euler is used:

If I swap the lines:

\setmathfont[version=bonummath,math-style=ISO]{TeX Gyre Bonum Math}
\setmathfont[version=euler,math-style=upright]{Neo Euler}


Bonum Math becomes upright:

How can this be fixed? Full MWE (I use LuaLaTeX):

\documentclass{article}

\usepackage{unicode-math}

\setmathfont[version=bonummath,math-style=ISO]{TeX Gyre Bonum Math}
\setmathfont[version=euler,math-style=upright]{Neo Euler}

\begin{document}

abc with Bonum: \mathversion{bonummath} $abc$

abc with Euler: \mathversion{euler} $abc$ and \textbf{symup} version: $\symup{abc}$

\end{document}

• I doubt very much that it is currently possible, you would probably have to make a feature request for unicode-math. Beside this I do find the idea of two math fonts -- and these with so different setup -- in one document rather dubious. – Ulrike Fischer Aug 10 '17 at 14:56
• @UlrikeFischer It is, indeed. But this is a special document, where I demonstate different fonts and see if the body/heading/math fonts look good with each other. – Michael Fraiman Aug 10 '17 at 15:17
• Then I would prepare external documents and insert them as graphics -- much less fuss ;-). – Ulrike Fischer Aug 10 '17 at 15:32
• @UlrikeFischer doesn't seem easier to me: having 100500 files is no a good idea. – Michael Fraiman Aug 10 '17 at 18:21

## In a Modern Toolchain

This example sets upright math letters, \symup and \symbfup, to Neo Euler. It leaves digits and operator names unchanged.

\documentclass[varwidth, preview]{standalone}

\usepackage{mathtools}
\usepackage{unicode-math}

\defaultfontfeatures{Scale=MatchLowercase}
\setmainfont{TeX Gyre Pagella}[
Scale=1.0,
Ligatures={Common, Discretionary, TeX}]
\setmathfont{Asana Math}
\setmathfont[range={up/{Latin,latin,Greek,greek},
bfup/{Latin,latin,Greek,greek},
cal, bfcal, frak, bffrak},
script-features={},
sscript-features={}
]{Neo Euler}

\newcommand\upi{\symup{i}}
\newcommand\upe{\symup{e}}

\begin{document}
\begin{align*}
\upe^{\upi x} &= \cos{x} + \upi \sin{x} \\
\upe^{\upi \uppi} + 1 &= 0
\end{align*}
\end{document}


This sets the Euler identities in Neo Euler, according to ISO style. Symbolic constants such as i, e and π are set upright, in Neo Euler, and everything else is from a Palatino clone. Variables are italic, and digits and operator names match the text font.

## In Legacy NFSS

\documentclass[varwidth, preview]{standalone}

\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage[utf8]{inputenc} % The default since 2018
\usepackage{mathtools}
\usepackage{newpxtext, newpxmath}
% If you also want to load Euler Script and Fraktur, you want mathalfa.

\DeclareSymbolFont{eulerup}{U}{zeur}{m}{n}
\DeclareMathSymbol{\uppi}{\mathalpha}{eulerup}{"19}
\DeclareMathSymbol{\upi}{\mathalpha}{eulerup}{"69}
\DeclareMathSymbol{\upe}{\mathalpha}{eulerup}{"65}

\begin{document}
\begin{align*}
\upe^{\upi x} &= \cos{x} + \upi \sin{x} \\
\upe^{\upi \uppi} + 1 &= 0
\end{align*}
\end{document}


This version gives similar output in pdflatex, but does not define a separate upright math alphabet. Instead, it declares the individual upright constants it needs from eulervm. The encoding is documented in the amsfonts User Guide, but is the same as OML.

It is also possible to make the upright font (Euler) the default by loading the right package (eulervm or eulerpx), and then load a separate \mathit alphabet. However, the LaTeX kernel does not define an upright math alphabet separate from \mathrm, like \symup in unicode-math.