LuaLaTeX 與 Noto CJK 和 babel onchar=ids 字體的奇怪錯誤

LuaLaTeX 與 Noto CJK 和 babel onchar=ids 字體的奇怪錯誤

當我將多語言項目轉換為 LuaLaTeX 時,它在chemfig命令中出現了一個奇怪的錯誤:

! LaTeX Error: Command \rmfamily invalid in math mode.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.13     \chemfig{\charge{135:4pt={+}}{H}-{F}}

將程式碼分開後,似乎配置babelonchar=ids fonts拉動NotoSerifCJK-VF是問題的根源(字體檔案已下載這裡,「可變OTC——TTF」之一)。我懷疑chemfig這可能不是問題的一部分,但我無法在其他地方重現它。

最小失敗範例:

\documentclass{article}
% Loading chemfig before, between, or after the babel stuff does not change the error
\usepackage{chemfig}

\usepackage[main=english]{babel}
% Either of these two lines,
\babelprovide[import,onchar=ids fonts]{chinese}
\babelprovide[onchar=ids fonts]{french}
% combined with this line,  will cause the error
\babelfont[chinese]{rm}[Path=./assets/fonts/]{NotoSerifCJK-VFttf.ttc} % make sure file name has only one dot

\begin{document}
    \chemfig{\charge{135:4pt={+}}{H}-{F}}
\end{document}

答案1

這似乎是一個錯誤babel。嘗試在序言中使用以下技巧:

\makeatletter
\let\bblorg@mapselect\bbl@mapselect
\def\bbl@mapselect{\ifmmode\else\bblorg@mapselect\fi}
\makeatother

但我還得再調查一下。

相關內容