4

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:

\documentclass[12pt,openany,twoside,fleqn]{book}
\usepackage{amsmath,chemfig}
\usepackage[version=3,arrows=pgf-filled]{mhchem}
\usepackage{mathspec}
\setmainfont{ITC Berkeley Oldstyle Std} 
\setmathsfont(Digits,Greek,Latin){ITC Berkeley Oldstyle Std} 
\begin{document}
\chemfig{CH_3CH_2CH_3} different font from \ce{CH3CH2CH3} 
\end{document}

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

2
  • Try adding \setmathrm{ITC Berkeley Oldstyle Std}. 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
    Oct 31, 2021 at 12:15

1 Answer 1

3

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

\newcommand*\printatom[1]{\ensuremath{\mathrm{#1}}}

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.

2
  • Respect @Jasper
    – Kidegalize
    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
    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 .