What is it?

mol2chemfig is a program that renders chemical structures from smiles format or MDL molfile format to LaTeX source code. The generated code can then be processed using the excellent and highly customizable chemfig LaTeX package.

Update: You don't want to mess with code of any kind and just want a pretty structure? Then go straight to py-chemist's excellent new web interface, provided by Vitali Coltuclu.

Here is a quick example: The smiles string CN1C=NC2=C1C(=O)N(C(=O)N2C)C describes caffeine. We can run this string through mol2chemfig as follows:

mol2chemfig -wz -i direct 'CN1C=NC2=C1C(=O)N(C(=O)N2C)C' > caffeine.tex

This writes the following output to caffeine.tex:


Compared to hand-coded chemfig code, this generated code is a bit verbose and not particularly pretty, but it works. We can paste it into LaTeX, or just input the file:

\usepackage{mol2chemfig}        % this package loads chemfig and defines
\pagestyle{empty}               % a few auxiliary macros


Coffee. Gimme some coffee.




If we run this through LaTeX, we get:

By giving mol2chemfig a few more options, we get the following result:

Thanks to the flexibility of the chemfig package, you can tweak the appearance of the chemical formulas to your heart's content from within LaTeX. Of course, you can also manually edit the generated chemfig code in your LaTeX document.

You can use mol2chemfig through its web interface (but also check out Vitali's py-chemist's excellent new web interface.), or you can download and install it on your computer. The code is freely available under the LaTeX project public license; that means, you are free to use and modify it, but modified programs must be renamed in order to avoid confusion.