12

I'm trying to replace the letters in the math font so that it matches the main font. Curiously, this works for the italic version, yet not for bold and roman. Why is that?

\documentclass{article}

\usepackage{unicode-math}

\defaultfontfeatures{Extension = .otf}
\setmainfont[ItalicFont = *-Italic, 
             BoldFont = *-Bold]{BemboStd}
\setmathfont{latinmodern-math}
\setmathfont[range=\mathrm]{BemboStd}
\setmathfont[range=\mathit]{BemboStd-Italic}
\setmathfont[range=\mathbf]{BemboStd-Bold}

\begin{document}

\noindent
abc \textit{abc} \textbf{abc} \\
$ \mathrm{abc} \ abc \ \mathbf{abc} $

\end{document}

enter image description here

Edit: Just in case it might be helpful to the next person, I'm now using

\setmathfont[range=\mathup/{latin,Latin}]{BemboStd}
\setmathfont[range=\mathit/{latin,Latin}]{BemboStd-Italic}
\setmathfont[range=\mathbfup/{latin,Latin}]{BemboStd-Bold}

as to only substitute the normal letters, and leave all the greek and \partial glyphs alone.

  • 1
    Try \setmathfont[range=\mathup]{BemboStd} \setmathfont[range=\mathit]{BemboStd-Italic} \setmathfont[range=\mathbfup]{BemboStd-Bold} – karlkoeller Dec 15 '13 at 20:15
  • Thanks! This works. Although I don't know why. – Psirus Dec 15 '13 at 20:20
11

Substituting \mathrm with \mathup and \mathbf with \mathbfup works:

\documentclass{article}

\usepackage{unicode-math}

\defaultfontfeatures{Extension = .otf}
\setmainfont[ItalicFont = *-Italic,
             BoldFont = *-Bold]{BemboStd}
\setmathfont{latinmodern-math}
\setmathfont[range=\mathup]{BemboStd}
\setmathfont[range=\mathit]{BemboStd-Italic}
\setmathfont[range=\mathbfup]{BemboStd-Bold}

\begin{document}

\noindent
abc \textit{abc} \textbf{abc} \\
$ \mathrm{abc} \ abc \ \mathbf{abc} $

\end{document} 

enter image description here

You can find the reason why this works and your solution does not, in the following table (page 9 of unicode-math documentation)

enter image description here

As you can see \mathrm and \mathbf alphabets are not defined in Unicode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.