Drawing molecules
In the previous recipe, we already encountered formulae for molecules. Now let's see how to draw them. This means drawing a group of atoms and connecting them by lines of various kinds.
How to do it...
This rather complex seeming task becomes manageable using the chemfig
package. It provides a compact syntax for drawing molecules. Let's draw some:
- Start with any document class:
\documentclass{article}
- Load the
chemfig
package:\usepackage{chemfig}
- Let's write molecules in a table. For this, we stretch the rows a bit and start a
tabular
environment with a right-aligned column and a left-aligned one.\renewcommand{\arraystretch}{1.5} \begin{tabular}{rl}
- For molecules, use the
\chemfig
command. Write atoms as letters and a single bond using a dash:Hydrogen: & \chemfig{H-H} \\
- Write a double bond using an equal-to sign:
Oxygen: & \chemfig{O=O} \\
- For a triple bond, use a tilde:
Ethyne: & \chemfig{H-C~C-H}
- End the table, and leave some space:
\end{tabular...