Markdown Flow

Back to Blog

How to Write Chemistry Formulas in Markdown

Standard Markdown has no way to represent a chemical formula - subscripts, superscript charges, and reaction arrows all need special notation. Markdown Flow supports mhchem chemistry syntax on top of its LaTeX math rendering, so formulas and full reactions render correctly.

Writing a Simple Formula

Wrap a formula in math delimiters using the \ce{} command:

Water: HX2O\ce{H2O}

Sulfuric acid: HX2SOX4\ce{H2SO4}

Numbers after an element automatically render as subscripts - no manual formatting needed.

Writing Full Reactions

Reactions with arrows, conditions, and multiple compounds work the same way, typically as display equations:

COX2+C2CO\ce{CO2 + C -> 2 CO}

Ions, Charges, and Reaction Conditions

mhchem also handles charges and conditions written above reaction arrows:

HgX2+IXHgIX2IX[HgIX4]X2\ce{Hg^2+ ->[I-] HgI2 ->[I-] [HgI4]^2-}

That single line renders a full mercury-iodide reaction sequence, complete with charges and the reagent labeled above each arrow.

Where This Comes Up

  • Chemistry homework and lab reports written with the help of an AI assistant.
  • Study guides that mix explanatory text with formulas and reaction equations.
  • Technical documentation in materials science, pharmacology, or environmental science.

Exporting Chemistry Notation

Chemistry equations follow the same export rules as regular math: PDF export renders them exactly as shown in the preview, and DOCX export keeps them as readable text so they display correctly in Word.

Frequently Asked Questions

Do I need special syntax knowledge beyond \ce{}? For most simple formulas, no - just wrap the formula in \ce{} inside math delimiters. Reactions with arrows and conditions use the same command with a few extra symbols (->, ^, [ ] for reagents).

Does this work alongside regular math equations? Yes - you can mix \ce{} chemistry notation and standard LaTeX math freely in the same document.

Can I ask ChatGPT to generate the formula for me? Yes - ask for a chemical equation and most AI assistants will already respond with \ce{} syntax, since it's a recognized LaTeX chemistry convention.

Try pasting a chemistry problem set into Markdown Flow - formulas and reactions render live, ready to export.