Skip to content

Embedded math

Chemistry publications embed mathematics everywhere: equilibrium constants (K_c = [P]/[R]), rate laws (rate = k[A]^2[B]), Arrhenius (k = A e^{-E_a/RT}).

AsciiChem does not reinvent math typography. Backtick-delimited runs are parsed by Plurimath’s AsciiMath parser, then embedded in the chemistry model as an EmbeddedMath node wrapping a Plurimath::Math::Formula.

Surround any math expression with backticks:

`K_c = [P]/[R]`
K c = P R
`k = A e^{-E_a/(RT)}`
k = A e E a R T
`rate = k[A]^2[B]`
r a t e = k [ A ] 2 [ B ]

EmbeddedMath nodes can appear anywhere a top-level node can — at the formula root, inside a molecule (rare), or as a reaction condition (intended for v2).

The most common use is at the formula root, paired with chemistry:

H_2 + I_2 <=> 2HI `K_c = [HI]^2 / ([H_2][I_2])`
H 2 + I 2 2 H I K c = [ H I ] 2 [ H 2 ] [ I 2 ]

For MathML output, AsciiChem calls Plurimath::Math::Formula#to_mathml and strips the outer <math> wrapper so the fragment slots cleanly into AsciiChem’s surrounding <mrow>.

For text output, the original backtick-delimited source is reproduced verbatim — round-trip is exact.

  • It already handles AsciiMath, LaTeX, UnicodeMath, OMML, and MathML.
  • It’s model-driven, with the same architectural values as AsciiChem.
  • Reusing it keeps AsciiChem focused on chemistry; math is a solved problem with a good library.
  • Backticks cannot be nested in v1. Use Plurimath’s native syntax for complex expressions; the embedded source is opaque to AsciiChem.
  • Whitespace inside the backticks is preserved verbatim.