1

In mathspec the command \mathbitis not defined, I followed advice from Ulrike here in order to define it, but it desperately remains in Computer Modern:

\documentclass{article}
\DeclareMathAlphabet      {\mathbfit}{OML}{cmm}{b}{it}
\usepackage{mathspec}
\setmainfont{NotoSans-Regular}[
    Extension      = .ttf,
    Ligatures      = TeX,
    BoldFont       = NotoSans-Bold,
    ItalicFont     = NotoSans-Italic,
    BoldItalicFont = NotoSans-BoldItalic,
    Numbers        = Lining
]
\setmathfont(Digits,Latin,Greek)[
    Extension      = .ttf,
    Ligatures      = TeX,
    BoldFont       = NotoSans-Bold,
    ItalicFont     = NotoSans-Italic,
    BoldItalicFont = NotoSans-BoldItalic,
    Numbers        = Lining
]{NotoSans-Regular}
\setmathrm[
    Extension      = .ttf,
    Ligatures      = TeX,
    BoldFont       = NotoSans-Bold,
    ItalicFont     = NotoSans-Italic,
    BoldItalicFont = NotoSans-BoldItalic,
    Numbers        = Lining
]{NotoSans-Regular}
\setmathfont[range=\mathbfit/{num,latin,Latin,greek,Greek},
    Extension      = .ttf,
    Ligatures      = TeX,
    Numbers        = Lining]{NotoSans-BoldItalic} 
\begin{document}
Blabla $x, \mathbf{x}, \mathbfit{x}, \mathrm{sin}(x)$
\end{document}

gives

enter image description here

in other words, everything is in Noto Sans (not that I like Noto, but I use it to exemplify the problem with a widely available font) except for the \mathbfit part. How can I solve this issue?

(I read somewhere that I need to use the unicode-math. OK but, first, I have no intention to type math symbols in Unicode, and second, I get compatibility problems such as "amsmath package has to be loaded first" even though I didn't requested any amsmath package…)

yannis
  • 2,013
  • 19
  • 18

1 Answers1

2

You can set up a math alphabet based on the main font.

\documentclass{article}
\usepackage{mathspec}

\setmainfont{NotoSans}[ Extension = .ttf, NFSSFamily = NotoSans, Ligatures = TeX, UprightFont = -Regular, BoldFont = -Bold, ItalicFont = -Italic, BoldItalicFont = -BoldItalic, Numbers = Lining ] \setmathfont(Digits,Latin,Greek)[ Extension = .ttf, Ligatures = TeX, UprightFont = -Regular, BoldFont = -Bold, ItalicFont = -Italic, BoldItalicFont = -BoldItalic, Numbers = Lining ]{NotoSans} \setmathrm[ Extension = .ttf, Ligatures = TeX, UprightFont = -Regular, BoldFont = -Bold, ItalicFont = -Italic, BoldItalicFont = -BoldItalic, Numbers = Lining ]{NotoSans}

\DeclareMathAlphabet{\mathbfit}{TU}{NotoSans}{b}{it}

\begin{document} Blabla $x, \mathbf{x}, \mathbfit{x}, \mathrm{sin}(x)$ \end{document}

enter image description here

egreg
  • 1,121,712
  • The trick with NFSSFamily is great! Thank a lot! What is TU encoding? – yannis Feb 20 '21 at 22:03
  • @yannis It's the standard encoding used for Unicode fonts. When mathspec was written, it used to be EU1 (XeLaTeX) or EU2 (LuaLaTeX), but then a new encoding was defined. – egreg Feb 20 '21 at 22:31