LaTeX and Chemistry

LaTeX is very useful for typesetting Chemistry.

A few examples are below

Normally we would the chemical formula for Methane as

$CH_4$

How do we achieve this in LaTeX? We to use maths mode.

$CH_4$

So the underscore gives us the required Subscript 4. The $ tells latex to use maths mode.

If we want to include both the Atomic number and Mass of an element. For example Hydrogen.

$H^1_1$

$H^6_12$

Or Carbon (illustrating how to type 2 numbers)

$C^6_{12}$

$C^6_{12}$

Puts one number above the other. So in the case the ^ gives us our superscript.

If we wanted to write Sodium as an ion we would put

$Na^{1+}$ Note that the 1+ has been put inside curly braces {1+}

$Na^{1+}$

So far this is pretty straightforward

You can also type chemical equations, which is a little more involved:

$H_2O(l) \hspace{0.5cm} \xrightarrow[\text{}]{\text{heat}}\hspace{0.5cm} = \hspace{0.5cm} H_2O (g)$

The first \text{} would put any text under the arrow, while clearly the second puts the text on top.

As per instructions you need to tell LaTeX to use the package mathtools

\usepackage{mathtools}

I have also added some horizontal spacing so the equation is not squashed together.

however writefreely does not seem to render this fully. You can view this equation in Overleaf here

#LaTeX, #Learn, #typesetting, #chemistry, #basics

cc-by logo

Licenced under Attribution 4.0 International (CC BY 4.0)


MastodonPeertubeJoin Mastodon

AI statement : Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity. Consent CANNOT be assumed, it has to be granted.

Donate using Liberapay