
多言語プロジェクトを 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}}
コードを分解してみると、設定とプルが問題の原因のようですbabel
(onchar=ids fonts
フォントNotoSerifCJK-VF
ファイルがダウンロードされますここ、"Variable OTCs -- 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
しかし、もう少し調査する必要があります。