[Tex/LaTex] 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:


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?

Best Answer

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.