tikz.dev / chemfig Manual

chemfig

Introduction

2 Presenting chemfig

To use this package, start by adding the following code to the preamble:

  • \input chemfig.tex with \(\varepsilon\);

  • \usepackage{chemfig} with ;

In all cases, the TikZ package, if not loaded before, is loaded by chemfig.

The most important command for drawing molecules is \chemfig{⟨code⟩}. The argument code is a set of characters describing the structure of the molecule according to the rules which are described in this manual.

Care has been taken to make it possible to draw the greatest possible number of molecular configurations, while maintaining a simple, flexible, and intuitive syntax. Despite this, the ⟨code⟩ which describes the 2D structure of the molecule increases in complexity in proportion to that of the molecule being drawn.

The command \chemfig draws a molecule using the commands provided by the TikZ package, placed inside a tikzpicture environment. The choice of TikZ implies that:

  • the user has a choice of compilation method: pdf can be used equally well in dvi mode (tex \(\longrightarrow\) dvi \(\longrightarrow\) ps \(\longrightarrow\) pdf) or in pdf mode (tex \(\longrightarrow\) pdf). In effect TikZ, via the underlying pgf, gives identical graphical results in the two modes;

  • the bounding box is automatically calculated by TikZ and the user need not worry about any overlap with the text. However, care must be taken with alignment when the molecule is drawn in a paragraph. In the following example, we have drawn the bounding box for the molecule: 0pt Compiled output.