在将我的文档从 PDFLatex 迁移到 LuaLatex 时,我发现chemgreek
在使用字体包时会出现奇怪的行为Numito
。XITS
当我将字体格式设置为 时,chemformula
希腊\sffamily
字符不会在\ch{}
环境中打印。在该环境之外,它们会按要求打印。将 更改sans serif font
为TeX Gyre Heros
不会显示这种奇怪的行为。使用 PDFLatex 进行编译也不会产生该错误。
这是(扩展的)MWE,显示以下行为:
\documentclass[a4paper,12pt,twoside]{article}
\usepackage{polyglossia}
\setdefaultlanguage[variant=british]{english}
\usepackage[charter,cal]{mathdesign}
\usepackage[sans-style=upright]{unicode-math} % automatically loads fontspec package
\defaultfontfeatures{Scale = MatchLowercase}
\setmainfont{GFSArtemisia}[
Scale=1.00,
Extension = .otf,
UprightFont = *,
ItalicFont = *It,
BoldFont = *Bold,
BoldItalicFont = *BoldIt]
\setsansfont{Nunito}[
Extension = .otf,
UprightFont = *-Regular,
ItalicFont = *-Italic,
BoldFont = *-Bold,
BoldItalicFont = *-BoldItalic]
\setmathfont{XITSMath-Regular.otf}
\usepackage[body={17.0cm,26cm},top=2.0cm,left=2.0cm]{geometry}
\usepackage[modules={isotope}]{chemmacros}
\chemsetup{greek=fontspec,formula=chemformula}
%\chemsetup[chemformula]{format={\sffamily}} % <= needs to commented out as this locks the chemformula font setting
\begin{document}
\subsection*{Default selections in preamble}
\setchemformula{format=\sffamily}
In LuaLaTeX \chemdelta{} in \verb*|\ch{}| does not print: \textcolor{red}{\ch{^\chemdelta Hl}} (nor do any Greek characters), but they are printed in \verb*|\vec{}|: $\vec{\chemmu}$
\subsection*{Nunito}
\fontspec{Nunito}
\setchemformula{format={\sffamily}}
\selectchemgreekmapping{fontspec}
Selected font in \verb*|chemformula| is \textbf{sans serif font} \\
Selected \verb*|greekmapping| is \textbf{fontspec}:
In LuaLaTeX \chemdelta{} in \verb*|\ch{}| does not print: \textcolor{red}{\ch{^\chemdelta Hl}} (nor do any Greek characters), but they are printed in \verb*|\vec{}|: $\vec{\chemmu}$
\selectchemgreekmapping{mathdesign}
\noindent Selected \verb*|greekmapping| is \textbf{mathdesign}:
In LuaLaTeX \chemdelta{} in \verb*|\ch{}| does print: \textcolor{red}{\ch{^\chemdelta Hl}} (as do all Greek characters) as well as in \verb*|\vec{}|: $\vec{\chemmu}$
\subsection*{GFS Artemisia}
\fontspec{gfsartemisia}
\setchemformula{format={\rmfamily}}
\selectchemgreekmapping{fontspec}
Selected font in \verb*|chemformula| is \textbf{roman font} \\
Selected \verb*|greekmapping| is \textbf{fontspec}:
In LuaLaTeX \chemdelta{} in \verb*|\ch{}| does print: \textcolor{red}{\ch{^\chemdelta Hl}} (as do all Greek characters) as well as in \verb*|\vec{}|: $\vec{\chemmu}$
\selectchemgreekmapping{mathdesign}
\noindent Selected \verb*|greekmapping| is \textbf{mathdesign}:
In LuaLaTeX \chemdelta{} in \verb*|\ch{}| does print: \textcolor{red}{\ch{^\chemdelta Hl}} (as do all Greek characters) as well as in \verb*|\vec{}|: $\vec{\chemmu}$
\end{document}
上述 MWE 的输出为:
请注意 左侧的矩形,其中Hl
应该\chemdelta
打印 。将 的字体映射更改chemgreek
为mathdesign:charter
确实会在应有的位置打印字符。将的chemformula
字体更改为确实会使用(XITS) 或映射rmfamily
打印字符。\chemdelta
fontspec
mathdesign
将此 MWE 中的默认无衬线字体更改为TeX Gyre Heros
同时打印任一映射中的希腊字符,如下输出所示:
由于“Numnito”字体中的小写 l 在化学公式中的可读性远优于“TeX Gyre Heros”中的小写 l,我想知道是什么导致了 LuaLatex 下这种行为,当然以及如何解决它。
编辑 仔细查看日志文件可以发现以下情况:
Missing character: There is no δ (U+03B4) in font [Nunito-Regular.otf]:mode=nod
e;script=latn;language=dflt;+tlig;!
Missing character: There is no δ (U+03B4) in font Nunito:mode=node;script=latn;
language=dflt;!
Missing character: There is no δ (U+03B4) in font [Nunito-Regular.otf]:mode=nod
e;script=latn;language=dflt;+tlig;!
Missing character: There is no δ (U+03B4) in font [Nunito-Regular.otf]:mode=nod
e;script=latn;language=dflt;+tlig;!
] (./chemgreek_lualatex.aux
这很奇怪,因为三角洲清楚地打印在第一个默认行中。当您\printchemgreekmapping{fontspec}
在 MWE 末尾添加该行时,希腊字符将全部打印出来,包括三角洲。
阅读日志条目后应该会更清楚——请参阅答案
答案1
这实际上是我真傻....
导致这种行为的原因是缺乏满的字体中的希腊符号集Nunito
。GFS Artemisia
并且TeX Gyre Heros
确实拥有一套完整的希腊字符,因此将在模式'chemdelta
下打印\sffamily
。
在序言中\selectchemgreekmapping{fontspec}
(或选项\chemsetup{greek=fontspec}
使用提供的希腊字母GFS Artemisia
。但是当里面要使用的字体系列\ch{}
设置为时,\sffamily
希腊字母的映射将切换为不完整的集Nunito
。
在使用完整的希腊字符集的同时维护sans serif
设置的解决方法是使用以下格式:。\ch{}
GFS Artemisia
\ch{\textrm{\chemdelta} ..}
笔记: \mathrm{}
没有用。
以下 MWE 示例展示了此解决方法:
\documentclass[a4paper,12pt]{article}
\usepackage[body={17.0cm,26cm},top=2.0cm,left=2.0cm]{geometry}
\usepackage[sans-style=upright]{unicode-math} % automatically loads fontspec package
\defaultfontfeatures{Scale = MatchLowercase}
\setmainfont{GFSArtemisia}[
Scale=1.0,
Extension = .otf,
UprightFont = *,
ItalicFont = *It,
BoldFont = *Bold,
BoldItalicFont = *BoldIt]
\setsansfont{Nunito}[
Extension = .otf,
UprightFont = *-Regular,
ItalicFont = *-Italic,
BoldFont = *-Bold,
BoldItalicFont = *-BoldItalic]
\setmathfont{XITSMath-Regular.otf}
\usepackage{chemmacros}
\chemsetup{greek=fontspec,formula=chemformula}
\chemsetup[chemformula]{format=\sffamily}
\setlength{\parindent}{0pt}
\begin{document}
Using the settings in the preamble:
\printchemgreekalphabet
Missing character: \ch{\chemmu-ClO3\mch[]} \ch{\chemalpha-ClO3\mch[]} $\vec{\chemdelta}$
Correct character: \ch{\textrm{\chemmu}-ClO3\mch[]} \ch{\textrm{\chemalpha}-ClO3\mch[]} $\vec{\textrm{\chemdelta}}$
\bigskip
\fontspec{Nunito}
Normal font changed to Nunito font:
\printchemgreekalphabet
Missing character: \ch{\chemmu-ClO3\mch[]} \ch{\chemalpha-ClO3\mch[]} $\vec{\chemdelta}$
Correct character: \ch{\textrm{\chemmu}-ClO3\mch[]} \ch{\textrm{\chemalpha}-ClO3\mch[]} $\vec{\textrm{\chemdelta}}$
\end{document}
得出以下结果:
请注意默认设置和使用Nunito
普通字体之间的希腊字母映射的差异。
顺便提一句:检查了其他带有略微弯曲的小写字母的无衬线字体后,我发现很多字体没有完整的希腊字符集。因此,在选择字体时要小心谨慎...希望你能从我的愚蠢行为中吸取教训... ;-P