2

Consider this MWE and compile it with 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}

The output is

Result

The first line/paragraph is OK. The second line/paragraph uses \bfseries in order to switch to a bold font face. But the math is still printed in a normal weight. I deem this acceptable, too.

The theorem header contains a two-fold error:

  1. Most obviously, the hyphen is missing.
  2. Computer Modern is used for the superscript.

Of course, the first error is a consequence of the second error. The log file says:

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

I do not understand what triggers the error. The command \bfseries, which makes the theorem header to be printed in a bold face, is also used in the second line without any problem.

How do I fix the problem?

Actually, I like the idea that the weight of the math font is adopted in the weight of the theorem header. This really makes it a visual part of the header. If there is a solution which keeps this behavior, that would be a plus. But in the first place, a solution should use the right font (Libertinus Math) and print a hyphen.

PS: This is a follow up of this question.


Addendum:

I do not get a LaTeX error as reported by David Carlisle in his answer below. Otherwise I would have reported that error :).

Here is the reduced log file with all version information one might need:

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)
4
  • When I try your example in texlive 2019 I get ! LaTeX Error: Math alphabet identifier \mathrm is undefined in math version bold'.` Feb 17, 2020 at 18:19
  • @DavidCarlisle That's weird, I have TexLive 2019, too. Did you run LuaLaTeX? I extend the question and post the version of all package from the log file.
    – nagmat84
    Feb 17, 2020 at 18:41
  • I just tried it with texlive2018 and got no error (but lots and lots of warnings) perhaps you are not fully up to date with LaTeX2e <2020-02-02> patch level 2 L3 programming layer <2020-02-14> Feb 17, 2020 at 18:51
  • yes as I guessed you have LaTeX2e <2018-12-01> OK I should re-word my answer a bit to not assume that you had an error (but the fix is the same) Feb 17, 2020 at 18:52

2 Answers 2

2

You get this error because the libertinus loads unicode-math without setting a \mathrm font for \mathversion{bold}. You can fix this with \setboldmathrm, from 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 sample

2
  • I wonder why you set \mathrm in math version bold to be Libertinus Serif Bold. How does this interact with unicode-math? Are there any surprising side effects? Would it not be more correct to set it to Libertinus Math and tell LaTeX to use the glyphs from the range U+1D400-U+1D433 and from U+1D468-U+1D49B for bold italic, would it?
    – nagmat84
    Feb 19, 2020 at 17:52
  • @nagmat84 no \symbf is designed to access the U+1D... slot bold, \mathbf is designed to pick up a separate bold font (in particular one with kerning and ligatures suitable for multi-letter identifiers) that's the distinction between the two commands. Jul 14, 2020 at 16:17
3

With current LaTeX, the document produces the error

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

After any error the PDF output is not intended to be useable, just possibly an aid to debugging.

With older releases you get a lot of warnings rather than an error but the issue is essentially the same.

ntheorem is assuming you have \boldmath setup but there is no bold set up. If you add

  \let\boldmath\relax

then bold math is not used and you get no error and the fonts used in the document are:

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

4
  • Unfortunately, I do not see a lot of warnings. The only warning is about the missing glyph at U+2010 for cmbx8. Also the fix does not work for me. I added \let\boldmath\relax even twice, in the preamble and after \begin{document}. The result is still the same and Latin Modern is used. I will check tomorrow, if I can update my TeX distro outside the package system of my Linux Distro. Nonetheless, it would be interesting to know what is different. It seems that my version of ntheorem does not rely on \boldmath.
    – nagmat84
    Feb 17, 2020 at 19:29
  • @nagmat84 I tried tl2018 and an up to date tl2019, You are using a not updated tl2019 so the exact behaviour is a bit different, but the basic issue is that it won't work, it's just a matter of where that is detected. Feb 17, 2020 at 19:32
  • It’s possible to get bold math working, rather than disabling it.
    – Davislor
    Feb 17, 2020 at 23:07
  • @Davislor bold math is evil anyway:-) Hmm but yes I don't think I can delete this as it's accepted but if the OP moves the tick I'll delete. Feb 17, 2020 at 23:14

You must log in to answer this question.

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