Files
KaTeX/contrib/mhchem
KaTeX bot 23b3950f7a chore(release): 0.14.0 [ci skip]
# [0.14.0](https://github.com/KaTeX/KaTeX/compare/v0.13.24...v0.14.0) (2021-10-30)

### Features

* conditionally export ECMAScript modules ([#3377](https://github.com/KaTeX/KaTeX/issues/3377)) ([15ee9b4](15ee9b4a5a))

### BREAKING CHANGES

* With module loaders that support conditional exports
and ECMAScript modules, `import katex from 'katex';` will import the
ECMAScript module.

You can now use:
|Before                                    |After                             |
|------------------------------------------|----------------------------------|
|`require('katex/dist/contrib/[name].js')` | `require('katex/contrib/[name]')`|
|`import katex from 'katex/dist/katex.mjs'`| `import katex from 'katex'`      |
|`import 'katex/dist/contrib/[name].mjs'`  | `import 'katex/contrib/[name]'`  |
2021-10-30 19:26:31 +00:00
..
2018-11-24 18:52:25 -05:00
2018-11-24 18:52:25 -05:00
2021-10-30 19:26:31 +00:00

mhchem extension

This extension adds to KaTeX the \ce and \pu functions from the mhchem package.

Usage

This extension isn't part of core KaTeX, so the script should be separately included. Write the following line into the HTML page's <head>. Place it after the line that calls katex.js, and if you make use of the auto-render extension, place it before the line that calls auto-render.js.

<script defer src="https://cdn.jsdelivr.net/npm/katex@0.14.0/dist/contrib/mhchem.min.js" integrity="sha384-UEY9IRPkV+TTTY7nK1wSrfhWPDJy9wr4PmYg3DLPcN5F4NDlIwGZkWtWveKR/45c"  crossorigin="anonymous"></script>

If you remove the defer attribute from this tag, then you must also remove the defer attribute from the <script src="https://../katex.min.js"> tag.

Syntax

See the mhchem Manual for a full explanation of the input syntax, with working examples. The manual also includes a demonstration box.

Note that old versions of mhchem.sty used \cf for chemical formula and \ce for chemical equations, but \cf has been deprecated in place of \ce. This extension supports only \ce. You can define a macro mapping \cf to \ce if needed.

Browser Support

This extension has been tested on Chrome, Firefox, Opera, and Edge.