How to use structures in LaTeX (chemfig and mhchem)
Select the structure, press Ctrl+K and choose Copy as chemfig or Copy as mhchem formula, then paste into your .tex file. chemfig needs \usepackage{chemfig}; mhchem needs \usepackage[version=4]{mhchem}.
Steps
- Draw or insert the structure, for example aspirin (press / and type
aspirin), and select it. - Press Ctrl+K and choose Copy as chemfig or Copy as mhchem formula. A notice confirms it and names the package you need.
- Paste into your
.texfile and add the package to the preamble.
chemfig: the drawing
Copy as chemfig gives the structure as chemfig code, with each bond's angle and ring closures. For aspirin:
\usepackage{chemfig}
...
\chemfig{-[:30](=[:90]O)-[:330]O-[:270]?[a]-[:210]=[:270]-[:330]=[:30]-[:90]?[a,{=}]-[:30](=[:90]O)-[:330]O}The angles follow your drawing, so the LaTeX picture looks like the structure on the canvas. It works in Overleaf and any LaTeX install with chemfig.
mhchem: the formula
Copy as mhchem formula gives the molecular formula for running text:
\usepackage[version=4]{mhchem}
...
\ce{C9H8O4}Tip
For a figure that has to match a journal's style exactly, export a PDF or SVG with the journal preset instead and include it with \includegraphics. See export a figure for a paper.
Is this helpful?
Last updated Nov 12, 2026
- Still stuck? Read the FAQ or contact support.
- Something wrong on this page? Tell us.
- For AI tools: llms.txt
