# mhchem (chemical notation)

*mhchem* is a chemistry notation designed for writing and rendering molecular formulae and reaction equations. As this app can render *mhchem* syntax inside Markdown, we can create beautiful visuals. It recognises element symbols, turns formula numbers into subscripts, handles ionic charges, and renders reaction arrows, so `2H2 + O2 -> 2H2O` becomes a properly formatted equation.

Put the chemistry expression directly in an `mhchem`, `chem`, or `chemical` fenced block. Write familiar chemistry notation—use spaces where they improve readability, `->` for a reaction arrow, and `^` for a charge or oxidation state. Visual mode renders the formula; raw mode retains the source. For advanced reactions, bonds, states, and arrows, see the [mhchem manual for MathJax and KaTeX](https://mhchem.github.io/MathJax-mhchem/) and the [CTAN package documentation](https://ctan.org/pkg/mhchem).

This app has integrated mhchem, MathJax, LaTeX and KaTeX (and many more), so whatever you put into such a note SHOULD work. If it doesn't looks EXACTLY like it should, I kindly ask you to send a short bug report, a simple screenshot with the used code is enough, maybe with a quick note.

Let's look at 3 examples, with the same content, but different language indicators. All renderings should look **exactly** the same. Switch between raw Markdown and visual editor to see it in action:

Example 1: with ` ```mhchem ` syntax.
Example 2: with ` ```chem ` syntax.
Example 3: with ` ```chemica ` syntax.

```mhchem
2H2 + O2 -> 2H2O
```

```chem
2H2 + O2 -> 2H2O
```

```chemical
2H2 + O2 -> 2H2O
```

## Reversible reactions and states of matter

Use `<=>` for an equilibrium arrow and add states in parentheses. mhchem keeps the chemical parts upright and formats the charges and subscripts automatically.

```mhchem
H2O(l) <=> H+(aq) + OH-(aq)
```

## Reaction conditions and catalysts

Square brackets immediately after an arrow add a label above it; a second pair adds one below it. This is useful for temperature, pressure, catalysts, solvents, or light.

```mhchem
N2 + 3H2 ->[Fe, 450 °C][200 atm] 2NH3
```

## Ions, precipitates, gases, and oxidation states

Write ion charges with `^`, use `v` for a precipitate and `^` after a species for a gas. Oxidation states can be written in parentheses as ordinary text.

```mhchem
Ba^2+(aq) + SO4^2-(aq) -> BaSO4(s) v
```

```mhchem
2H2O2(aq) ->[MnO2] 2H2O(l) + O2(g) ^
```

```mhchem
Fe^3+ + e- -> Fe^2+
```

## Isotopes and physical units

Leading superscripts identify isotopes. You can also start the block with `\pu{...}` to render a physical quantity with its unit rather than a chemical equation.

```mhchem
^14C -> ^14N + e- + \bar{\nu}_e
```

```mhchem
\pu{6.022e23 mol^-1}
```

## Kröger-Vink Notation

```mhchem
$\ce{Li^x_{Li,1-2x}Mg^._{Li,x}$V$'_{Li,x}Cl^x_{Cl}}$
```

Note the upright V = Vanadium, italic V = vacancy

```mhchem
$\ce{V_{V,1}C_{C,0.8}$V$_{C,0.2}}$
```
