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:

  1. Start with any document class:
    \documentclass{article}
  2. Load the chemfig package:
    \usepackage{chemfig}
  3. 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}
  4. For molecules, use the \chemfig command. Write atoms as letters and a single bond using ...

Get LaTeX Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.