I use the mhchem
package for chemical formulas (with XeTeX). For one year or so, I’ve been experiencing some really strange bugs, seemingly without reason. Some characters in the chemical formulas, especially greek letters (\alpha
, \delta
, etc.) would disappear. This was really annoying and there was no way to solve the bug, so I ended up replacing \delta
with d, \alpha
with a, etc. Not optimal, but I felt like it was not worth more hassle.
Today I spent a long time trying to do a minimal working exemple to finally solve this issue and I found the cause of the problem: an evil interaction with fontspec
and packages linked to fontspec
such as xeCJK
(a package provides support for small parts in Chinese, Japanese or Korean).
Here are MWEs. In this case, no issue is encountered.
\documentclass[12pt]{article}
\usepackage{mhchem}
\begin{document}
$\ce{BaCe_{0.8}Y_{0.2}O_{3-\alpha}}$
\end{document}
In this case, the alpha is not typeset.
\documentclass[12pt]{article}
\usepackage{fontspec}
\usepackage{mhchem}
\begin{document}
$\ce{BaCe_{0.8}Y_{0.2}O_{3-\alpha}}$
\end{document}
Where could this problem come from, and how to solve it?
fontspec
from replacing math characters inmhchem
formulas with characters that don’t exist’ rather than ‘how to find fonts where these characters actually exist’xeCJK
is a package to typeset documents whose main language is CJK (especially Chinese). It does lots of things other than switching fonts (e.g., automatic insertion of spaces that are needed in CJK typography), and these can be harmful in Western language documents (I'm not sure what's your main language though). I think you shouldn't avoid the hassle, but this is just a personal opinion of course ;-)xeCJK
withfontspec
.