# How to Display Decimal Numbers in Chemical Equations with LaTeX mhchem Package?

Like many people who use LaTeX, I like using the mhchem package to type chemical equations, but there was a problem I met when I was typing numbers with decimal in mhchem package, e.g. if an equation is written as follows,

\ce{3.043 Fe2O3}

mhchem would gives the result 3·043 Fe2O3 instead of the expected 3.043 Fe2O3. The dot here is actually for the center dot in chemistry equations. But we need the mathematical decimal dot (period).

because mhchem normally does not render the dot as decimal. I tried several methods to make the decimal dot does not display at the middle, e.g. a possible method can be

\ce{\text{3.043} Fe2O3}

though it is not so handy and looks a bit weird (numbers display as plain texts). Finally, I found the following trick works:

\ce{$3.043$ Fe2O3}

just use maths-escape mode, using $$to embrace the number. There should not be any white spaces between  and the number otherwise the compiling would go wrongly, though this is not the case in normal equations. 中文：在LaTeX mhchem包中输入带小数点数字的化学公式时，用美元符号$$将小数点数字包括起来，就可以正常显示小数点而不是在中间位置的点，$与数字之间不得有空格。 ## 《How to Display Decimal Numbers in Chemical Equations with LaTeX mhchem Package?》有20个想法 1. Okt.Schwein 不是应该所有的数学公式都是可以用$$来表达么？ 我没有使用过mhchem这个package，但是直接键入$3.043Fe_2O_3$或者$3.043 Fe_2O_3\$（和前者区别在于中间有空格，但LaTeX会忽略这个空格）不是你想要的效果么？

回复
1. 土木坛子

对于少量的化学公式，可以用数学模式，不过，数学模式下的化学式是斜体显示，而且，上标下标需要人工输入。而这个化学包mhchem模式下，直接输入数字，自动标成下标，有明显的优势。

回复
1. 土木坛子

如果有较多的化学式和数学公式时，LaTeX的优势就出来了。我主要是习惯了，不愿意再研究PPT之类的，所以现在能用LaTeX的时候就用它，包括做报告文档 Presentation.

回复