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}

decimal numbers in chemical equations

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}

decimal numbers in chemical equations

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. 土木坛子


    1. 土木坛子

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


chojemmy进行回复 取消回复

电子邮件地址不会被公开。 必填项已用*标注