# How to use MathJax mhchem \pu{} command in LaTex?

As title says I would like to use MathJax mhchem \pu{} command in my LaTeX document. FYI it is widely used in chemistry stackexchange for putting units.

But when used I get the error:

Undefined control sequence. ... \pu

Missing $inserted. ... \pu{ .... Extra }, or forgotten$. ... \pu{....}

I have included the usepackage command on my preamble:

\usepackage[version=3]{mhchem}

also tried different versions, all same error. I have also tried putting the \pu{...} with and without .

I would appreciate if you could help me know what is the problem and how I can solve it? maybe you can provide me a working example of \pu{} command?

• We will likely need a clue as to what this does: it's not a command from the LaTeX mhchem package. – Joseph Wright Dec 11 '17 at 10:50
• @JosephWright oh I thought it is a regular command of MathJax mhchem! it is widely used in chemistry stackexchange for putting units. – Foad Dec 11 '17 at 10:51
• use the siunitx package for typesetting units instead – Troy Dec 11 '17 at 11:03

You cannot. The \pu (physical unit) command is a goodie specific to MathJax/mhchem. It is not part of LaTeX/mhchem.

For a LaTeX document, I recommend using the siunitx package. With that, you can achieve document-wide consistency of units.

The reasons to add \pu to MathJax/mhchem:

• There was (is) no reasonable siunitx implementation for MathJax.
• The concept of centrally defining a style, then using it for the rest of the document is not suited for sites like StackExchange.
• MathJax/mhchem's \ce was frequently misused to typeset upright units.
• Reusing the MathJax/mhchem parser and pre-renderer, an implementation of \pu was possible with just a few lines of code.

As you see, none of these reasons apply to LaTeX. Therefore, I never considered implementing \pu for LaTeX.

I found it used in https://chemistry.stackexchange.com/a/76935

From the above we can see that the first and second coefficients
in the polynomial fit correspond directly to $A$ and $B$,
respectively. In this example, the energies are in wavenumbers
($\pu{cm^{-1}}$). Most quantum packages print in atomic units
(Hartrees) and dynamics packages print in kJ/mol, which is fine,
but be aware that in the above fit the units are incorporated into
$A$ and $B$.

A proper LaTeX setting would be with the siunitx package:

\documentclass{article}
\usepackage{siunitx}

\begin{document}

From the above we can see that the first and second
coefficients in the polynomial fit correspond directly
to $A$~and~$B$, respectively. In this example, the energies
are in wavenumbers~(\si{\per\centi\meter}). Most quantum
packages print in atomic units (Hartrees) and dynamics
packages print in~\si[per-mode=symbol]{\kilo\joule\per\mol},
which is fine, but be aware that in the above fit the units
are incorporated into $A$~and~$B$.

\bigskip

From the above we can see that the first and second
coefficients in the polynomial fit correspond directly
to $A$~and~$B$, respectively. In this example, the energies
are in wavenumbers~(\si{cm^{-1}}). Most quantum
packages print in atomic units (Hartrees) and dynamics
packages print in~\si{kJ/mol},
which is fine, but be aware that in the above fit the units
are incorporated into $A$~and~$B$.

\end{document}

You can directly use representations of the symbols, but it's much more flexible when names are used.