I'm writing my thesis about the gas NO2. The correct way to write this is $NO_2$
. Currently, I have a macro defined to make typing easier:
\newcommand{\notwo}[0]{\chem{NO_2}\xspace}
\chem
is a macro defined in the Copernicus package:
\def\testbx{bx}
\DeclareRobustCommand*{\chem}[1]{\ensuremath{%
\mathcode`-="0200\mathcode`\=="003D% no space around "-" and "="
\ifx\testbx\f@series\mathbf{#1}\else\mathrm{#1}\fi}}
However, I'd like to expand this a bit more. Especially, when I'm in sans-serif, I want \notwo
to be sans-serif, and when I'm in sans-serif-bold, I want \notwo
to be sans-serif-bold.
I'm using xelatex, and I'm using system-wide installed Myraid Pro font (OTF) via the line
\setsansfont[Mapping=tex-text,ItalicFont={MyriadPro-It},BoldFont={MyriadPro-Bold}]{Myriad Pro}.
How can I achieve this?
mhchem
package for a general approach to chemical formulas.mhchem
needs to be loaded afteramsmath
to avoid some package option clash errors, though.