3

This is a follow up question to this answer. The original question dealt with the problem of selecting to correct roman font in bold math version. Although the sans-serif style was not part of the discussion, the proposed solution also adjusted the sans-serif style to the correct font. (Maybe by luck?)

Recently, I updated my LaTeX distribution as part of my OS installation. Since then, I am experiencing a sort of regression bug. Using the old installation the proposed solution yielded correct results for roman and sans-serif fonts. After the update, the sans-serif fonts are wrong for \mathsf in bold math version.

The MWE

The MWE

\documentclass{article}
\usepackage{libertinus}
\usepackage{ntheorem}

% Fix \mathrm in math version bold, see https://tex.stackexchange.com/a/528865/47156.
% Enable \mathrm in \mathversion{bold}
\setboldmathrm{Libertinus Serif Bold}[Ligatures=Common, ItalicFont=Libertinus Serif Bold Italic]

% Solely to format the width of a MWE on TeX.SX:
\usepackage[paperwidth=10cm]{geometry}

\theoremstyle{plain}
\theoremheaderfont{\normalfont\bfseries}
\newtheorem{theorem}{Theorem}

\newcommand*{\A}{\symrm{aaa}}
\newcommand*{\B}{\symsf{bbb}}
\newcommand*{\C}{\mathrm{ccc}}
\newcommand*{\D}{\mathsf{ddd}}

\begin{document}

\begin{theorem}[Test of $\A$]
$\A$: \verb#\symrm# yields correct results in normal and bold math version.
\end{theorem}

\begin{theorem}[Test of $\B$]
$\B$: \verb#\symsf# yields correct results in normal and bold math version.
\end{theorem}

\begin{theorem}[Test of $\C$]
$\C$: \verb#\mathrm# yields correct results in normal and bold math version.
\end{theorem}

\begin{theorem}[Test of $\D$]
$\D$: \verb#\mathsf# only yields correct results in normal math version, but fails in bold math version.
In bold math it falls back to cmss.
\end{theorem}

\end{document}

The last theorem environment accidentally falls back to CMSS. I hoped there would be an equivalent \setboldmathsf included into the new package versions, but it does not seem so. How do I get back the old (and correct) behaviour which uses Libertinus Sans Bold as the font for \mathsf in bold math version?

My old installation:

This is LuaTeX, Version 1.10.0 (TeX Live 2019 Gentoo Linux)  (format=lualatex 2020.1.1)  17 FEB 2020 19:39
 restricted system commands enabled.
LaTeX2e <2018-12-01>
Lua module: luaotfload-main 2019-05-18 2.97 luaotfload entry point
Lua module: luaotfload-init 2019-05-18 2.97 luaotfload submodule / initialization
Lua module: lualibs 2019-05-18 2.65 ConTeXt Lua standard libraries.
Lua module: lualibs-extended 2019-05-18 2.65 ConTeXt Lua libraries -- extended collection.
Lua module: luaotfload-log 2019-05-18 2.97 luaotfload submodule / logging
Lua module: luaotfload-parsers 2019-05-18 2.97 luaotfload submodule / filelist
Lua module: luaotfload-configuration 2019-05-18 2.97 luaotfload submodule / config file reader
luaotfload | init : Context OpenType loader version “3.108”
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
File: size10.clo 2018/09/03 v1.4i Standard LaTeX file (size option)
Package: libertinus 2018/09/03 v. 0.01 (Herbert Voss) Supports libertinus fonts for pdflatex/lualatex/xelatex
Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional
Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO)
Package: xkeyval 2014/12/03 v2.7a package option processing (HA)
Package: libertinus-otf 2019/04/04 v. 0.14 (Herbert Voss and Bob Tennent) Supports libertinus fonts for lualatex and xelatex.
Package: textcomp 2018/08/11 v2.0j Standard LaTeX package
File: ts1enc.def 2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
Package: expl3 2019-05-09 L3 programming layer (loader) 
Package: expl3 2019-05-09 L3 programming layer (code)
Package: unicode-math 2019/03/04 v0.8o Unicode maths in XeLaTeX and LuaLaTeX
Package: unicode-math-luatex 2019/03/04 v0.8o Unicode maths in XeLaTeX and LuaLaTeX
Package: xparse 2019-05-03 L3 Experimental document command parser
Package: l3keys2e 2019-05-03 LaTeX2e option processing using LaTeX3 keys
Package: fontspec 2019/03/15 v2.7c Font selection for XeLaTeX and LuaLaTeX
Package: fontenc 2018/08/11 v2.0j Standard LaTeX package
Package: filehook 2011/10/12 v0.5d Hooks for input files
Package: lualatex-math 2019/01/21 v1.8 Patches for mathematics typesetting with LuaLaTeX
Package: ntheorem 2011/08/15 1.33
Package: ifthen 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)

My new installation:

This is LuaTeX, Version 1.12.0 (TeX Live 2020 Gentoo Linux)  (format=lualatex 2020.6.4)  14 JUL 2020 17:12
 restricted system commands enabled.
LaTeX2e <2020-02-02> patch level 5
Lua module: luaotfload-main 2020-02-02 3.12 luaotfload entry point
Lua module: luaotfload-init 2020-02-02 3.12 luaotfload submodule / initialization
Lua module: lualibs 2020-02-02 2.70 ConTeXt Lua standard libraries.
Lua module: lualibs-extended 2020-02-02 2.70 ConTeXt Lua libraries -- extended collection.
Lua module: luaotfload-log 2020-02-02 3.12 luaotfload submodule / logging
Lua module: luaotfload-parsers 2020-02-02 3.12 luaotfload submodule / filelist
Lua module: luaotfload-configuration 2020-02-02 3.12 luaotfload submodule / config file reader
luaotfload | conf : Root cache directory is /home/matthias/.texlive/texmf-var/luatex-cache/generic-dev/names.
luaotfload | init : Loading fontloader “fontloader-2020-01-26.lua” from kpse-resolved path “/usr/share/texmf-dist/tex/luatex/luaotfload/fontloader-2020-01-26.lua”.
luaotfload | init : Context OpenType loader version “3.11”
Lua module: luaotfload-loaders 2020-02-02 3.12 luaotfload submodule / callback handling
Lua module: luaotfload-database 2020-02-02 3.12 luaotfload submodule / database
Lua module: luaotfload-unicode 2020-02-02 3.12 luaotfload submodule / Unicode helpers
Lua module: luaotfload-colors 2020-02-02 3.12 luaotfload submodule / color
Lua-only attribute luaotfload_color_attribute = 5
Lua module: luaotfload-resolvers 2020-02-02 3.12 luaotfload submodule / resolvers
luaotfload | conf : Root cache directory is /home/matthias/.texlive/texmf-var/luatex-cache/generic-dev/names.
Lua module: luaotfload-features 2020-02-02 3.12 luaotfload submodule / features
Lua module: luaotfload-letterspace 2020-02-02 3.12 luaotfload submodule / color
Lua module: luaotfload-embolden 2020-02-02 3.12 luaotfload submodule / color
Lua module: luaotfload-notdef 2020-02-02 3.12 luaotfload submodule / color
Lua module: luaotfload-auxiliary 2020-02-02 3.12 luaotfload submodule / auxiliary functions
Lua module: luaotfload-fallback 2020-02-02 3.12 luaotfload submodule / fallback
Lua module: luaotfload-multiscript 2020-02-02 3.12 luaotfload submodule / multiscript
Lua module: luaotfload-script 2020-02-02 3.12 luaotfload submodule / Script helpers
Lua module: luaotfload-tounicode 2020-02-02 3.12 luaotfload submodule / tounicode
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
File: size10.clo 2019/12/20 v1.4l Standard LaTeX file (size option)
Package: libertinus 2018/09/03 v. 0.01 (Herbert Voss) Supports libertinus fonts for pdflatex/lualatex/xelatex
Package: ifxetex 2019/10/25 v0.7 ifxetex legacy package. Use iftex instead.
Package: iftex 2019/11/07 v1.0c TeX engine tests
Package: ifluatex 2019/10/25 v1.5 ifluatex legacy package. Use iftex instead.
Package: xkeyval 2014/12/03 v2.7a package option processing (HA)
Package: libertinus-otf 2020/02/22 v. 0.24 (Herbert Voss) Supports libertinus fonts for lualatex and xelatex.
Package: textcomp 2020/02/02 v2.0n Standard LaTeX package
Package: expl3 2020-02-25 L3 programming layer (loader) 
Package: unicode-math 2020/01/31 v0.8q Unicode maths in XeLaTeX and LuaLaTeX
Package: unicode-math-luatex 2020/01/31 v0.8q Unicode maths in XeLaTeX and LuaLaTeX
Package: xparse 2020-02-25 L3 Experimental document command parser
Package: l3keys2e 2020-02-25 LaTeX2e option processing using LaTeX3 keys
Package: fontspec 2020/02/21 v2.7i Font selection for XeLaTeX and LuaLaTeX
Lua module: fontspec 2020/02/21 2.7i Font selection for XeLaTeX and LuaLaTeX (/usr/share/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty
Package: fontspec-luatex 2020/02/21 v2.7i Font selection for XeLaTeX and LuaLaTeX
Package: fontenc 2020/02/11 v2.0o Standard LaTeX package
Package: fix-cm 2015/01/14 v1.1t fixes to LaTeX
Package: amsmath 2020/01/20 v2.17e AMS math features
Package: amstext 2000/06/29 v2.01 AMS text
Package: amsbsy 1999/11/29 v1.2d Bold Symbols
Package: amsopn 2016/03/08 v2.02 operator names
Package: lualatex-math 2019/01/21 v1.8 Patches for mathematics typesetting with LuaLaTeX
Package: etoolbox 2019/09/21 v2.5h e-TeX tools for LaTeX (JAW)
Package: filehook 2020/02/03 v0.7 Hooks for input files
2

First, a Frame Challenge

Do you in fact need \mathsf within a header? There are times when you really do, such as when you \setoperatorfont{\mathsf}, but \textsf or \symsfup will often suffice.

The difference between \mathsf and \symsf is that \mathsf is supposed to be for full words in math mode and \symsfit for tensor variables. However, in classic LaTeX, \mathsf did double duty, and authors are in the habit of using it for both.

If you need a full word in sans-serif text, you can use \textsf instead of \mathsf, and it will inherit the font weight of the text around it. If you also want to override the shape, also use \textup or \textit. This works in either text or math mode.

If you use \mathsf for sans-serif tensor symbols, pass unicode-math the [mathsf=sym] package option. Then, if you set your header formatting to \bfseries\boldmath, \mathsf will give you \symsf from Libertinus Math Bold.

You might also want to define more semantic commands to use in your source. If you want sans-serif word variables, you might declare a \variablename or \vn command that you can change later in one place. If you need upright sans-serif for constant tensors, you might define \ctensor, and if you ever need to port the code to PDFLaTeX, you could redefine it.

A Solution

The literal answer to the question you asked is:

\documentclass{article}
\usepackage{libertinus} % Includes unicode-math

\SetMathAlphabet{\mathsf}{bold}{\UnicodeEncodingName}{\sfdefault}{b}{n}

\begin{document}
\section{\bfseries\boldmath Test of \(\mathsf{sans\, serif}\)}
\end{document}

Libertinus sample

See Appendix B of the unicode-math user manual for more details.

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.