MolDraw Docs

chemfig and LaTeX

Short answer: Click Download and pick chemfig (LaTeX) to save a .tex file that compiles with pdflatex. To copy only the code, right click and pick Copy as, then chemfig (LaTeX). To draw from chemfig, copy the code and press Ctrl+V on the canvas.

Last updated · By the MolDraw team at LabCanvas

View .mdSection PDF

chemfig is a LaTeX package for chemical structures. MolDraw writes chemfig code from your drawing and reads chemfig code back onto the canvas.

  1. Select what you want to export. With nothing selected, MolDraw exports the whole canvas.
  2. Click Download and look in the Text group.
  3. Click chemfig (LaTeX). MolDraw saves a .tex file.
  4. Compile the file with pdflatex.

Download or copy#

Way What you get Use it when
Download, chemfig (LaTeX) A full standalone document in a .tex file You want a PDF of the figure right away
Right click, Copy as, chemfig (LaTeX) The chemfig code only, with no document around it You paste the figure into your own paper or thesis

On a phone, open the More menu, then Copy as, then chemfig (LaTeX).

If you copy only the code, add these lines to your preamble:

\usepackage{chemfig} \usetikzlibrary{arrows.meta,decorations.pathmorphing}

What the export writes#

  • Bond angles and lengths come from your drawing, so the PDF matches the canvas. The code sets atom sep to 2.5em.
  • Reaction schemes become \schemestart to \schemestop, one per row.
  • Curly arrows and fish-hooks become \chemmove curves that follow the same path as on the canvas.

Some objects have no chemfig form. MolDraw leaves them out and lists them in the status line, so nothing goes missing silently:

Object What happens
Images, shapes, glassware, freehand strokes, orbitals Left out
Ring fills and highlights Left out
Query bonds Written as plain bonds
Curved or S-shaped scheme arrows Written as straight scheme arrows
Curly arrows not attached to a structure Left out
Text placed beside the drawing Kept as comments in the code
Brackets that cross more than two bonds Left out

Paste chemfig code#

  1. Copy chemfig code from your editor. A whole .tex file works too.
  2. Click the canvas and press Ctrl+V, or click Paste in the top bar.
  3. MolDraw draws the structures and selects them. The status line says "Pasted chemfig".

MolDraw spots chemfig when the text contains \chemfig or \schemestart. Pasted text uses a serif font so it looks like the LaTeX output. The open file dialog does not take .tex files, so paste the code instead.

What MolDraw reads#

  • Chains and branches, bond angles [n], [:a] and [::a], and length factors.
  • Bond types -, =, ~, <, >, <:, >: and their looks: wavy, bold, dotted, dative, colored or hidden.
  • Rings *n(...) and **n(...), ring closure hooks ?[...] and \definesubmol.
  • Atom groups with H, charges, colors, \lewis, \charge and \chemabove.
  • Schemes with \arrow text above and below, \+, \chemname captions and \subscheme.
  • \chemleft[ and \chemright] brackets and \polymerdelim.
  • Plain text lines, such as titles and notes.
  • \chemmove curly arrows between @{name} nodes.

Common problems#

Problem Fix
"Could not read that chemfig code" Check that every brace is closed. Paste one \chemfig{...} at a time to find the bad one.
The PDF has missing arrow tips or wavy bonds Add the two TikZ libraries above to your preamble.
Ctrl+V pastes a picture instead The clipboard held an image. Copy the code as plain text and paste again.

For worked examples, read the chemfig and MolDraw guide and the chemfig mechanism samples. For other formats, see Download and file formats.

Questions and answers

How do I convert a structure to chemfig?

Draw it in MolDraw, click Download and pick chemfig (LaTeX). Or right click, pick Copy as and choose chemfig (LaTeX) to copy only the code.

Which LaTeX packages does the chemfig export need?

It needs the chemfig package and the TikZ libraries arrows.meta and decorations.pathmorphing. The downloaded .tex file already includes them.

Can MolDraw read chemfig code?

Yes. Copy the code and press Ctrl+V on the canvas. MolDraw draws structures, schemes and \chemmove curly arrows.

Does the chemfig export keep curly arrows?

Yes. Curly arrows and fish-hooks attached to a structure are written as \chemmove curves.

Can I open a .tex file in MolDraw?

Not with the open file dialog. Open the file in a text editor, copy the code and paste it onto the canvas.

Last updated: