LuaLaTeX、ntheorem、unicode-math 和 Libertinus:定理标头加载中的数学计算机现代

LuaLaTeX、ntheorem、unicode-math 和 Libertinus:定理标头加载中的数学计算机现代

考虑这个 MWE 并使用 LuaLaTex 进行编译:

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

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

\newcommand*{\hybrid}{%
  \symsf{H}^{\mathrm{test\mathhyphen reduction}}_{5}%
}

\begin{document}

This is ok: $\hybrid$

{\bfseries This is ok, too: $\hybrid$}

\begin{theorem}[The hybrid $\hybrid$]
The font weight of $\hybrid$ adopts to the header style.
I really like that.
But it also loads Computer Modern Bold (cmbx8) and the hyphen does not work.
\end{theorem}

\end{document}

输出为

结果

第一行/段落没问题。第二行/段落使用\bfseries切换到粗体字体。但数学仍然以正常粗细打印。我认为这也是可以接受的。

定理标题包含两重错误:

  1. 最明显的是,缺少了连字符。
  2. 上标使用 Computer Modern。

当然,第一个错误是第二个错误的结果。日志文件显示:

Missing character: There is no ‐ (U+2010) in font cmbx8!

我不明白是什么引发了错误。\bfseries使定理标题以粗体打印的命令也在第二行中使用,没有任何问题。

我该如何解决这个问题?

实际上,我喜欢将数学字体的粗细应用于定理标题的粗细的想法。这确实使其成为标题的视觉部分。如果有一个解决方案可以保留这种行为,那将是一个加分项。但首先,解决方案应该使用正确的字体(Libertinus Math)并打印连字符。

附言:这是这个问题


附录:

我没有收到报告的 LaTeX 错误大卫·卡莱尔在他的回答如下。否则我就会报告那个错误了:)。

以下是包含可能需要的所有版本信息的简化日志文件:

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.
**math-bold-font.tex
(./math-bold-font.tex
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)

答案1

出现此错误的原因是libertinus加载unicode-math时未设置\mathrm字体\mathversion{bold}。您可以使用\setboldmathrm中的修复此问题fontspec

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

% 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*{\hybrid}{%
  \symsf{H}^{\mathrm{test\mathhyphen reduction}}_{5}%
}

\begin{document}

This is ok: $\hybrid$

{\bfseries\boldmath This is ok, too: $\hybrid$}

\begin{theorem}[The hybrid $\hybrid$]
The font weight of $\hybrid$ adapts to the header style.
I really like that.

The font is now correctly set to Libertinus Serif Bold.
\end{theorem}

\end{document}

Libertinus 样本

答案2

使用当前的 LaTeX,文档会产生错误

! LaTeX Error: Math alphabet identifier \mathrm is undefined in math version bold

任何错误 PDF 输出不是为了使用,而只是可能有助于调试。

对于旧版本,您会收到很多警告而不是错误,但问题本质上是相同的。

ntheorem假设您已\boldmath设置,但没有设置粗体。如果您添加

  \let\boldmath\relax

那么就不会使用粗体数学,也不会出现任何错误,并且文档中使用的字体是:

name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
MMNMPW+LibertinusSerif-Regular       CID Type 0C       Identity-H       yes yes yes      4  0
EXEWQA+LibertinusMath-Regular        CID Type 0C       Identity-H       yes yes yes      5  0
ACNUSM+LibertinusSerif-Regular       CID Type 0C       Identity-H       yes yes yes      6  0
UJTLVL+LibertinusMath-Regular        CID Type 0C       Identity-H       yes yes yes      7  0
EGXLNF+LibertinusSerif-Bold          CID Type 0C       Identity-H       yes yes yes      8  0
NFIGQN+LibertinusSerif-Italic        CID Type 0C       Identity-H       yes yes yes      9  0

相关内容