tikz.dev / chemfig Manual

chemfig

Operation of chemfig

2 Groups of atoms

Drawing a molecule consists inherently of connecting groups of atoms with lines. Thus, in the molecule Compiled output, there are two groups of atoms, each consisting of a single atom “O”.

1pt However, in this molecule

Compiled output

there are four groups of atoms: “\(\mathrm{H_3C}\)”, “C”, “O” and “OH”. For reasons which we shall see later, chemfig splits each group into single atoms. Each atom extends up to the next capital letter or one of these special characters: - = ~ ( ! * < > @. chemfig ignores all characters inside braces when splitting groups into atoms.

Therefore the first group of atoms “\(\mathrm{H_3C}\)” is split into two atoms: Compiled output and Compiled output. In terms of chemistry, of course, these are not real atoms; \(\mathrm{H_3}\), for example, consists of three hydrogen atoms. In what follows the word atom refers to chemfig’s definition. Thus chemfig sees the preceding molecule as follows:

Compiled output

A space is ignored when at the beginning of a group of atoms.