In my document, I'm currently using chemformula for chemical formulae. To draw reaction mechanisms I'm trying to use chemfig, but it's proving very difficult to get chemfig to use the same sans-serif font that chemformula does.

I'm using XeLaTeX as my engine so I'm using fontspec and unicode-math with it.

My document's main font is a serif font (Palatino); the math font is Cambria Math, and finally the sans-serif font is Source Sans Pro. By default chemfig uses math mode to typeset atoms so they will appear in my math font.

How do I get it to use my sans-serif font?

I have tried:

Redefining \printatom to use \ch

Does not work. This would be the best solution (I think), but I can't figure out how to get \ch from chemformula to accept chemfig's input.


\setmainfont{Palatino Linotype}
\setmathfont[version=cm]{Cambria Math}
\setsansfont{Source Sans Pro}
\setmathfont[version=ssp]{Source Sans Pro}




I get this:

! Undefined control sequence.
<argument> \atom 1 \CF
l.19 \chemfig{C=Cl}

Redefining \printatom to use \mathsf


It builds, but \mathsf doesn't use Source Sans Pro but the Unicode mathematical sans-serif characters instead (because of unicode-math) and I'm not sure how to get it to actually use Source Sans Pro.

Redefining \printatom to use \mathversion


Does not work. TikZ doesn't like \mathversion outside of the math block it seems, and \mathversion cannot be used inside math mode.

! Package tikz Error: Giving up on this path. Did you forget a semicolon?.

See the tikz package documentation for explanation.
Type  H <return>  for immediate help.

l.18 \chemfig{C=Cl}

Other attempts

I also tried using \DeclareMathAlphabet to define Source Sans Pro as a math font, but I couldn't figure out how to get it to work.

1 Answer 1


Seems like wrapping \chemfig with the appropriate \mathversions works:


You must log in to answer this question.

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