To follow-up the discussion in the comments of David Carlisle's answer about the unicode-math
package:
In LaTeX, there are two fonts in math mode:
- one for letters (variables), usually called math font (better called math letter font);
- one for words, usually called math text font (better called math word font),
and one text font in text mode, usually called text font.
The text font and the math text font may be different:
\documentclass{article}
\renewcommand{\familydefault}{ppl} % sets Palatino as text font
\begin{document}
$\mathnormal{affinity}$\par % math letter font
$\mathit{affinity}$\par % math word font
$\textit{affinity}$\par % text font
\end{document}

Here \mathnormal
, \mathit
and \textit
result in three different fonts being used: Latin Modern Math, Latin Modern and Palatino respectively.
With the unicode-math
package loaded, the output becomes different:
\documentclass{article}
\usepackage{unicode-math}
\setmainfont{Palatino} % sets Palatino as text font
\setmathfont{Latin Modern Math} % sets Latin Modern Math as math letter font
\begin{document}
$\mathnormal{affinity}$\par % math letter font
$\mathit{affinity}$\par % math word font
$\textit{affinity}$\par % text font
\end{document}

Here the package redefines \mathnormal
as nothing and \mathit
as math letter font (instead of math word font in classic LaTeX). So by default the unicode-math
package breaks the standard behaviour of LaTeX. That is why David Carlisle opened an issue at Github as said in his answer (there is another interesting Github issue about the same problem here).
As suggested by David Carlisle in the Github issue, I first thought about introducing new math font commands \mathwxx
for math word font in the unicode-math
package, to keep backward compatibility:

But finally I am wondering if those new math font commands \mathwxx
are needed, and even if they make sense: indeed, when do we need to use an upright math letter font after all? Math letter fonts are only for variables, therefore they should always be in italic, never upright. We only need an upright math font for non variables, that is for math word fonts, so we should better replace the math letter font of the Unicode ranges \mathup
and \mathbf
by a math word font:
\documentclass{article}
\usepackage{unicode-math}
\setmainfont{Palatino}
\setmathfont{Latin Modern Math}
\setmathfont[range=\mathup]{Latin Modern Roman} % sets a math word font instead of the default math letter font
\setmathfont[range=\mathbfup]{lmroman12-bold} % sets a math word font instead of the default math letter font
\let\mathnormal\mathit % redefines \mathnormal as before the unicode-math package
\begin{document}
\noindent
\texttt{\backslash mathup}: $\mathup{affinity}$\\
\texttt{\backslash mathbf}: $\mathbf{affinity}$\\
\texttt{\backslash mathit} or \texttt{\backslash mathnormal}: $\mathit{affinity}$ (default)\\
\texttt{\backslash mathbfit}: $\mathbfit{affinity}$\\
\end{document}

Thus with that setup we get the standard LaTeX behaviour.