LuaLaTeX、Libertinus 和 unicode-math:在粗体数学版本中使用正确的无衬线字体

LuaLaTeX、Libertinus 和 unicode-math:在粗体数学版本中使用正确的无衬线字体

这是一个后续问题这个答案。原始问题处理的是选择纠正的问题罗马粗体数学字体。虽然无衬线字体样式不是讨论的一部分,但提出的解决方案也将无衬线字体样式调整为正确的字体。(也许是运气好?)

最近,我在安装操作系统时更新了 LaTeX 发行版。从那时起,我遇到了一种回归错误。使用旧安装,建议的解决方案对罗马字体和无衬线字体产生了正确的结果。更新后,无衬线字体\mathsf粗体数学版本的字体不正确。

数学家协会

数学家协会

\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}

最后一个定理环境意外地回退到 CMSS。我希望在新软件包版本中包含等效项\setboldmathsf,但似乎并非如此。如何恢复使用 Libertinus Sans Bold 作为\mathsf粗体数学版本字体的旧(和正确)行为?

我的旧安装:

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)

我的新安装:

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

答案1

首先,框架挑战

您确实需要\mathsf在标题内吗?有时您确实需要,例如当您 时\setoperatorfont{\mathsf},但\textsf\symsfup通常就足够了。

\mathsf和之间的区别在于\symsf\mathsf应该用于数学模式中的完整单词和\symsfit张量变量。然而,在经典 LaTeX 中,\mathsf具有双重功能,作者习惯于将其用于两者。

如果您需要无衬线文本中的完整单词,则可以使用\textsf而不是\mathsf,它将继承其周围文本的字体粗细。如果您还想覆盖形状,也可以使用\textup\textit。这在文本或数学模式下都有效。

如果您使用\mathsf无衬线张量符号,请传递包unicode-math选项[mathsf=sym]。然后,如果您将标题格式设置为\bfseries\boldmath\mathsf则会为您提供\symsf来自 Libertinus Math Bold 的格式。

您可能还想定义更多语义命令以在源代码中使用。如果您想要无衬线字变量,您可以声明一个\variablename\vn命令,稍后可以在一个地方进行更改。如果您需要常量张量的直立无衬线,您可以定义\ctensor,如果您需要将代码移植到 PDFLaTeX,您可以重新定义它。

一个办法

对于您提出的问题的字面答案是:

\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 样本

附录 B请参阅unicode-math用户手册以了解更多详细信息。

相关内容