I've made a bunch of chemfig
examples because I often find the package confusing if it has been a while. I prefer it to ChemDraw et al., for drawing structures and reactions as it is free in both sense of the word (and because I'm broke and no longer affiliated with an academic organisation).
I also enjoy the more "programmatic" approach to creating structures as they can easily be fine-tuned, duplicated, tweaked, etc. with nothing but a text editor.
Each file is commented with some descriptions and explanations on how things were achieved. This is not currently as comprehensive as I would like it to be, however, so feel free to email/message me with any questions or assistance requests :)
I've done a bunch of customisation (visible in config.tex
) to get the produced images looking like I want them to.
Some of these configurations include:
- The optional use of the FreeSans font, which is freely available and permissively licensed. The font is easily changed to any system fonts picked up by
lualatex
- Optionally
pdflatex
can be used instead and a font package (e.g.mathptmx
,arev
, etc.) can be used
- Optionally
- A 12 pt font size, with most other measurements defined using em and ex, to scale cleanly when the font size is changed
- A base angle increment of 30º to easily facilitate the 60º angles standard in typical chemical drawings
- Custom widths for the wedge and dashed bonds and a custom bond length to look clean and familiar
- Some predefined element colours that will adjust brightness whether the drawing is in dark or light mode, to keep things legible
- Note that colouring the atoms is done manually and hence entirely optional
- Some custom commands to simplify styling conditions in reaction schemes and floating stereochemistry markers -- i.e. (S), (R), (E), (Z), etc.
The build
script is a bash
script that automates the process of exporting the structures/schemes as .svg
images for both light and dark backgrounds, as well as performing some organising and cleanup each time it is run. The script requires pdf2svg
, pdfcrop
and sed
.
Note that I have built this on debian unstable and hence I haven't tested on anything else. Generally, though, if you have a full texlive
distribution and GNU bash
and sed
, things should compile. Depending on your system you may need to adapt the method to produce .svg
files from the produce .pdf
.
(Simple) organic molecules are usually the easiest to produce as they can be drawn mostly using multiples of the base angle. Each example is generally included as it includes something new, like the inclusion of charges, lone pairs, shifted double bonds, stereochemistry, psuedotransparency, etc.
-
Aripiprazole -- a simple example showcasing the basics, how to colour atoms, how to construct lone and joined rings and the use of the base angle increment
-
Venlafaxine showing the phenethylamine backbone -- shows how to construct rings using hooks and custom angles, rather than the normal ring syntax, which is done to construct a cyclohexane ring in the chair conformation. Also includes the use of the psuedotransparent colours for both atoms and bonds
-
Escitalopram -- shows how to place a stereochemistry marker at a stereocentre as well as introducing the use of triple bonds
-
Memantine -- shows the use of multiple hooks to create complex multicyclic/cage-like/diamondoid structures as well as how to place a lone pair
-
Quetiapine -- shows how to rotate a part of the molecule by a custom angle, done so the 7 membered ring takes the preferred orientation
-
Scopolamine -- another example of creating a multicyclic ring structure using hooks
-
8-Chlorotheophylline -- just a typical caffeine-like molecule for fun and because I'd made it for a separate prohject :)
-
Myristicin -- shows how to shift a double bond so that it is above/below a main chain for a cleaner look
-
Benzydamine -- shows the use of relative angles (i.e. defined relative to the angle of the previous bond) which allows the side chains to have the angles they do
-
Coronene/Superbenzene -- a more complicated multi-ring example
-
Maitotoxin -- I included this both to challenge me and to show that even complicated molecules can be created with a relatively simple (if a bit long) process following the molecule from one end to another and adding side chains (it wasn't as bad as it looks, I promise!)
-
Ferrocene derivative -- shows the use of invisible bonds used for alignment and creating nodes that can be used to add information -- in this case the ellipses on the rings
-
Ir(ppy)3 -- shows how invisible bonds can be used to create big structures and keep their alignment relatively simply without doing a lot of annoying hooks or math
-
Cycloaddition reaction (tetradehydro Diels-Alder (TDDA)) -- reinforces the use of invisible bonds as a means to keep alignment between separate fragments and place nodes for drawing; also shows the use of arrows, reaction conditions and how to align molecules relative to some feature; shows the use of mechanistic arrows with custom contours
-
Decarboxylation of cyclic peroxyester to excited ketone -- shows how to place information adjacent to brackets surrounding a whole molecule using the same tools used to draw mechanistic arrows
-
Nucleophilic aromatic substitution reaction -- shows the use of invisible arrows to space reactants out, as well as demonstrating that mechanistic arrows can be drawn between separate molecules, shows the placement of circled charges, shows that once you have one set of mechanistic arrows drawn, it's just a matter of copy/pasting and tweaking the controls and nodes