1

I have resolved my earlier problem with LuaLaTeX not loading fonts, but now the \mathbf command does not produce bold math font.

As an example, the following code:

\[
    x + y = 10 \, \mathbf{bold text} \, \mathit{italic text} \, \mathrm{math text} 
\]

produces the following:

enter image description here

\mathbf seems to have no effect. I looked through this page to setup bold/italic font faces for the math font I chose since it doesn't seem there are other styles besides regular, but \mathbf does not appear.

Here is my current preamble snippet with respect to fonts:

% Font / LuaLaTeX setup
\RequirePackage{iftex}
\usepackage{iftex}
\ifluatex
    \RequirePackage{fontspec}
    \RequirePackage{unicode-math} 
    \unimathsetup{math-style=TeX}
    \RequirePackage[english]{babel}
    \defaultfontfeatures{Ligatures=TeX, Scale=MatchLowercase}
    \setmainfont[
    Path=/usr/share/fonts/opentype/linux-libertine/,
    Extension=.otf,
    BoldFont=LinLibertine_RB,
    ItalicFont=LinLibertine_RI,
    ]{LinLibertine_R}
    \setsansfont[
    Path=/mnt/c/Users/user/Appdata/Local/Microsoft/Windows/Fonts/,
    Extension=.otf,
    BoldFont=Kurier-Bold,
    ItalicFont=Kurier-Italic,
    ]{Kurier-Regular}
    \setmonofont[
    Path=/mnt/c/Users/user/Appdata/Local/Microsoft/Windows/Fonts/,
    Extension=.ttf,
    BoldFont=Inconsolata-Bold,
    ]{Inconsolata-Regular}
    \setmathfont{LibertinusMath-Regular.otf}
    \setmathrm[BoldFont=LinLibertine_RB.otf]{LinLibertine_R.otf}
    \setboldmathrm{LinLibertine_RB.otf}
\fi
% regular times
\ifpdftex
\RequirePackage[T1]{fontenc}
\RequirePackage{newtxtext}
\RequirePackage[smallerops]{newtxmath}
\fi

I looked through the documentation for fontspec, but I couldn't find anything regarding \mathbf. If there's something I missed or something that can fix this, that would be great. Thanks!

3
  • Usual question in a case like this: are you sure that LibertinusMath-Regular even has bold characters? If those are missing from the font, LaTeX can't make them up.
    – Miyase
    Aug 2, 2022 at 0:05
  • I do not think it does, so I subbed in fonts for the boldmathrm. Perhaps that doesn't do the trick?
    – Revise
    Aug 2, 2022 at 0:34
  • Urgh, my apologies, somehow I completely missed that last line in your code. However I had a look at fontspec's documentation, and page 18 the description of \setboldmathrm is phrased a bit strangely; it's not obvious that it works with \mathbf.
    – Miyase
    Aug 2, 2022 at 6:46

1 Answer 1

3

For unicode-math to automatically sync the text fonts into math mode, don't explicitly set \setmathrm, \setboldmathrm, \setmathsf, etc.

mathbf

MWE

\documentclass{article}
    \usepackage{xcolor}
    \usepackage{fontspec}
    \usepackage{unicode-math} 
    \defaultfontfeatures{Ligatures=TeX, Scale=MatchLowercase}
    \setmainfont{\detokenize{LinLibertine_R}}[
    Path=...longpath.../texlive/2020/texmf-dist/fonts/opentype/public/libertine/,
    Extension=.otf,
    BoldFont=*B,
    BoldFeatures={Colour=red},
    ItalicFont=*I,
    ItalicFeatures={Colour=blue},
    BoldItalicFont=*BI,
    ]
    \setsansfont{Kurier}
    \setmonofont{NotoSansMono}%Inconsolata} %don't have Inconsolata
%    \setmathrm[BoldFont=LinLibertine_RB.otf]{LinLibertine_R.otf}
%    \setboldmathrm{LinLibertine_RB.otf}

    \unimathsetup{math-style=TeX}
    \setmathfont{LibertinusMath-Regular}

\begin{document}

\[
    x + y = 10 \, \mathbf{bold text} \, \mathit{italic text} \, \mathrm{math text} 
\]

\end{document}
1
  • Thanks! This seems logical, but for some reason when I tried it out by adding to my preamble the changes are not reflected for some reason (and same with pasting the MWE onto a fresh document). Italic works as usual, but bold is still missing (prnt.sc/YROCS1ePo2o_). Perhaps it's something wrong with my machine? I'm quite unsure.
    – Revise
    Aug 2, 2022 at 18:42

You must log in to answer this question.

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