When writing chemical formula I use both \chemfig{} and \ce{} commands but I noticed that the two bring outputs having different font style as shown below.

enter image description here

Currently working with these codes:

\setmainfont{ITC Berkeley Oldstyle Std} 
\setmathsfont(Digits,Greek,Latin){ITC Berkeley Oldstyle Std} 
\chemfig{CH_3CH_2CH_3} different font from \ce{CH3CH2CH3} 

Kind help of how change the chemfig font to ITC Berkeley Oldstyle Std.

  • Try adding \setmathrm{ITC Berkeley Oldstyle Std}. Commented Oct 31, 2021 at 8:33
  • Background knowledge: mhchem's \ce{} uses the current text font. This is particularly useful for chemistry in section titles, where the text gets repeated in page headers and table of contents, each using another text font.
    – mhchem
    Commented Oct 31, 2021 at 12:15

1 Answer 1


According to the documentation, the chemfig package uses the following macro to print atoms:


Therefore, since you already use mathspec, you should be able to select the font for atoms using \setmathrm{ITC Berkeley Oldstyle Std} in your preamble. You could of course also redefine the macro.

  • Respect @Jasper
    – Kidegalize
    Commented Oct 31, 2021 at 8:42
  • 1
    and the community, in my main TeX I found this ! LaTeX error: Too many math alphabets used in version normal.
    – Kidegalize
    Commented Oct 31, 2021 at 9:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .