{{short description|LaTeX package for drawing chemical structures}} {{Infobox software | name = Chemfig | developer = Christian Tellechea | latest_release_version = | programming_language = TeX | operating_system = Cross-platform | platform = LaTeX | genre = Chemical structure drawing | license = LaTeX Project Public License | website = {{URL|https://www.ctan.org/pkg/chemfig}} }}
'''Chemfig''' is a LaTeX package used for creating graphical representations of chemical structures, molecules, reaction schemes, and structural formulas. It provides a simple and flexible syntax to define atoms, bonds, angles, rings.<ref>{{Cite web|url=https://www.overleaf.com/learn/latex/Chemistry_formulae#Using_chemfig_to_draw_molecules_(structural_formulae)|title=Chemistry formulae|website=www.overleaf.com}}</ref> It allows for the construction of both organic and inorganic molecules using LaTeX markup.<ref>{{Cite web |title=chemfig |url=https://tug.ctan.org/macros/generic/chemfig/chemfig-en.pdf |website=tug.ctan.org}}</ref><ref>{{Cite web|url=https://www.texdev.net/2012/08/25/exploring-chemfig-basics/|title=Exploring ChemFig: Basics|first=Joseph|last=Wright|date=August 25, 2012|website=Some TeX Developments}}</ref>
== Features == * Customizable bond angles and lengths * Support for single, double, triple, and aromatic bonds * Cyclic compounds and ring structures * Reaction arrows and mechanisms * Integration with TikZ for advanced diagramming and mhchem for typesetting chemical equations * Support for submolecules and nested chemical environments<ref>{{Cite journal|title=mol2chemfig, a tool for rendering chemical structures from molfile or SMILES format to LATE X code|first1=Eric K.|last1=Brefo-Mensah|first2=Michael|last2=Palmer|date=October 2, 2012|journal=Journal of Cheminformatics|volume=4|issue=1|pages=24|doi=10.1186/1758-2946-4-24|doi-access=free |pmid=23031664|pmc=3551648}}</ref>
== Syntax == Package preamble: <syntaxhighlight lang="latex"> \input chemfig.tex \usepackage{chemfig} </syntaxhighlight>
Chemfig uses a simple syntax based on TeX commands. For example: <syntaxhighlight lang="latex"> \chemfig{H-C(-[2]H)(-[6]H)-C(=O)-OH} </syntaxhighlight> Produces a structural formula for acetic acid and a structure would render as: [[File:Essigsäure - Acetic acid.svg|130px|thumb|center|Acetic acid]]
There are 9 different bond types: 120px|right <syntaxhighlight lang="latex"> \chemfig{A-B}\\ \chemfig{A=B}\\ \chemfig{A~B}\\ \chemfig{A>B}\\ \chemfig{A<B}\\ \chemfig{A>:B}\\ \chemfig{A<:B}\\ \chemfig{A>{{!}}B}\\ \chemfig{A<{{!}}B}\\ </syntaxhighlight>
[[File:Methane chemfig.png|thumb|right|120px|methane molecule]] Molecular angles of a methane molecule: <br> <syntaxhighlight lang="latex"> \chemfig{C(-[:0]H)(-[:90]H)(-[:180]H)(-[:270]H)} </syntaxhighlight>
== See also == {{Portal|Chemistry|Free and open-source software}} * Comparison of TeX editors * Computational chemistry * Jmol - molecular modelling of chemical structures in 3 dimensions * List of TeX extensions * mhchem * Molecular geometry * Molecular graphics * Overleaf - web app that does chemfig package chemical structures * TikZ * XyMTeX - another LaTeX structural formula package
==References== {{reflist}}
== External links == * [https://www.ctan.org/pkg/chemfig Chemfig on CTAN] * [https://en.wikibooks.org/wiki/LaTeX/Chemical%20Graphics Wikibooks on chemfig and chemical graphics] * [https://ctan.org/pkg/chemfig?lang=en chemfig software package]
Category:Free chemistry software Category:Free TeX software