Chemfig

Chemfig is a LaTeX package used for creating graphical representations of chemical structures, molecules, reaction schemes, and structural formulas. It provides a simple and flexible syntax to define atoms, bonds, angles, rings. It allows for the construction of both organic and inorganic molecules using LaTeX markup.

Features

  • Customizable bond angles and lengths
  • Support for single, double, triple, and aromatic bonds
  • Cyclic compounds and ring structures
  • Reaction arrows and mechanisms
  • Integration with TikZ for advanced diagramming and mhchem for typesetting chemical equations
  • Support for submolecules and nested chemical environments

Syntax

Package preamble:

\input chemfig.tex
\usepackage{chemfig}

Chemfig uses a simple syntax based on TeX commands. For example:

\chemfig{H-C(-[2]H)(-[6]H)-C(=O)-OH}

Produces a structural formula for acetic acid and a structure would render as: Acetic acid

There are 9 different bond types: Chemfig_bonds.png

\chemfig{A-B}\\
\chemfig{A=B}\\
\chemfig{A~B}\\
\chemfig{A>B}\\
\chemfig{A<B}\\
\chemfig{A>:B}\\
\chemfig{A<:B}\\
\chemfig{A>{{!}}B}\\
\chemfig{A<{{!}}B}\\ 

methane molecule Molecular angles of a methane molecule:

\chemfig{C(-[:0]H)(-[:90]H)(-[:180]H)(-[:270]H)}

See also

  • Comparison of TeX editors
  • Computational chemistry
  • Jmol - molecular modelling of chemical structures in 3 dimensions
  • List of TeX extensions
  • mhchem
  • Molecular geometry
  • Molecular graphics
  • Overleaf - web app that does chemfig package chemical structures
  • TikZ
  • XyMTeX - another LaTeX structural formula package