Typesetting Amino Acids in LaTeX with chemfig

This page is thought to be a personal reminder on how to draw amino acids in LaTeX with the chemfig package. The package documentation is very well written, but personally, I think that some tangible and simple ‘practical’ examples are missing. Especially when one starts using it, it’d be great to have a simple vademecum with some (possibly, biological) examples. So here are mine. All the code chunks are highlighted in the rounded box, in the spirit of Jupyter Notebooks.

The generic amino acid can be typeset in his neutral form in LaTeX as

\schemestart
  \chemfig{ H_2 N-[:-30,]C(<:[:-120,]R)(<[:-60]H)(-[:30,]C(=[:90,0.7]O)(-[:-30,]OH)) }
\schemestop

and the result is

We can do better, simply by removing the H bound to the Cα and specifying the sidechain R. Omitting all the \schemestart and \schemestop commands (which must be included!), here are reported the skeletal formulæ for the amino acids in their zwitterionic form.1 I am not sure all these formulæ are correct, though.

Nonpolar amino acids

Polar amino acids

Positively-charged amino acids

Negatively-charged amino acids


  1. That is, the form with ionized atoms. ↩︎

  2. This is tricky, since in chemfig you need to ‘split’ the phenil LaTeX chunk where the backbone connects. The 6-cycle has the priority when drawing it, and in chemfig it goes anticlockwise starting from the ‘bottom-left’ position. When we reach the branching point at the third carbon we add in brackets the rest of the amino acid, and then end coding the cycle. The same holds for tyrosine and all the other cycle-containing amino acids. ↩︎