Skip to main content

Math & Chemistry

The [latex]...[/latex] shortcode typesets mathematics, chemical formulas, and physical quantities. Equations render as real, selectable text in PDF and as native, editable equations in Word — never as images.

{ "p": "The roots are [latex]x = frac{-b pm sqrt{b^2 - 4ac}}{2a}[/latex] for a != 0." }

The body is captured verbatim: nothing inside [latex]...[/latex] is scanned for other shortcodes, so ^, _, { }, and [ ] belong to the math grammar, not to the tag parser.

Backslash-free LaTeX

Commands are written without backslashes: frac{a}{b}, sqrt{x}, alpha, sum_{i=1}^n. The parser recognizes command names by longest match inside letter runs, so alphax reads as alpha followed by the variable x, while unrecognized letters stay ordinary italic variables (dx is just d·x).

Pasted-in standard LaTeX also works: a leading backslash is tolerated and ignored, so \frac{a}{b} and frac{a}{b} are equivalent.

Whitespace in the source is insignificant — math spacing is automatic, with explicit spacing commands when you want more.

Inline vs. display

An equation that is the entire paragraph (nothing but whitespace around the shortcode) renders in display (block) style — centered sizing, with sum/product limits above and below:

{ "p": "[latex]sum_{n=1}^{infty} frac{1}{n^2} = frac{pi^2}{6}[/latex]" }

An equation embedded in surrounding text renders inline, sized to flow with the line:

{ "p": "Euler's identity [latex]e^{i pi} + 1 = 0[/latex] links five constants." }

Scripts, fractions, roots

SyntaxRendersNotes
x^2, x^{n+1}superscriptbraces group multi-token arguments
x_i, x_{i,t}subscriptcombine freely: x_i^2
frac{a}{b}stacked fractiondfrac, tfrac, cfrac are accepted synonyms
binom{n}{k}binomial coefficientdbinom, tbinom accepted
sqrt{x}square root
sqrt[3]{x}cube rootoptional bracketed degree, LaTeX-style
root{n}{x}n-th rootdegree first, then radicand
a / bslash fraction/ stays on the line; use frac for stacked

Fences and matrices

Parentheses ( ) and brackets [ ] render as grown fences around their content. Double brackets build a matrix — comma-separated cells in comma-separated rows:

{ "p": "[latex]A = [[a, b], [c, d]][/latex]" }

Commas inside a cell's own braces or scripts (for example p_{i,t}) never split the cell.

Pasted LaTeX environments are accepted and normalize to the same matrix rendering — begin{pmatrix} a & b \\ c & d end{pmatrix} and [[a, b], [c, d]] with parentheses produce identical output. Recognized environments: matrix, smallmatrix, pmatrix, bmatrix, Bmatrix, vmatrix, Vmatrix, cases (left brace only), and the aligned/align/gathered/gather/split family (fenceless rows). & separates cells and \\ separates rows. The double-bracket form is the native way to write it.

Greek letters

Written by name. Lowercase renders italic like variables; uppercase renders upright, per TeX convention.

LowercaseUppercase
alpha beta gamma deltaα β γ δGamma DeltaΓ Δ
epsilon varepsilon zeta etaε ε ζ ηTheta LambdaΘ Λ
theta vartheta iota kappaθ ϑ ι κXi PiΞ Π
lambda mu nu xiλ μ ν ξSigma UpsilonΣ Υ
pi varpi rho varrhoπ ϖ ρ ϱPhi PsiΦ Ψ
sigma varsigma tau upsilonσ ς τ υOmegaΩ
phi varphi chi psi omegaϕ φ χ ψ ω

Symbols and constants

NameGlyphNameGlyph
inftyforall
partialexists
nablaneg¬
emptysetdegree°
alephprime
ellcdots
hbarldots
Revdots
Imddots

Number sets have double-letter shorthands rendering in blackboard bold: RR → ℝ, NN → ℕ, ZZ → ℤ, QQ → ℚ, CC → ℂ.

Operators and relations

Common operators are typed directly: +, -, *, /, =, <, >, and the two-character forms != (≠), <= (≤), >= (≥), -> (→). The rest are written by name:

Binary operatorsRelations
pm mp± ∓ne / neq
times div cdot× ÷ ⋅le / leq, ge / geq≤ ≥
ast star circ bullet∗ ⋆ ∘ ∙ll gg≪ ≫
cap cup∩ ∪approx cong equiv≈ ≅ ≡
wedge vee∧ ∨sim simeq propto∼ ≃ ∝
oplus otimes odot⊕ ⊗ ⊙in notin ni∈ ∉ ∋
setminussubset supset subseteq supseteq⊂ ⊃ ⊆ ⊇
langle rangle⟨ ⟩

Arrows: to / rightarrow (→), leftarrow (←), leftrightarrow (↔), mapsto (↦), Rightarrow (⇒), Leftarrow (⇐), iff (⇔).

Functions

Function names render upright, distinguishing them from italic variable runs: sin, cos, tan, cot, sec, csc, sinh, cosh, tanh, coth, arcsin, arccos, arctan, exp, log, ln, lg, lim, limsup, liminf, max, min, sup, inf, det, dim, ker, deg, gcd, arg, hom, mod.

{ "p": "[latex]lim_{x -> 0} frac{sin x}{x} = 1[/latex]" }

Large operators

sum, prod, coprod, bigcup, bigcap, bigvee, bigwedge, bigoplus, bigotimes, bigodot place their _ and ^ limits above and below in display style. Integrals — int, iint, iiint, oint — place their bounds to the side:

{ "p": "[latex]int_0^infty e^{-x^2} dx = frac{sqrt{pi}}{2}[/latex]" }

Accents

One-argument commands placing a diacritic over the argument: hat{x}, widehat{x}, bar{x}, overline{x}, vec{F}, dot{x}, ddot{x}, dddot{x}, tilde{x}, widetilde{x}, check{x}, acute{x}, grave{x}, breve{x}.

Letter styles

Variant commands restyle every letter of their argument:

CommandStyleExample
mathbf{...}bold uprightmathbf{v}
boldsymbol{...}bold italicboldsymbol{beta}
mathbb{...}blackboard boldmathbb{R}
mathcal{...}calligraphic scriptmathcal{L}
mathfrak{...}Frakturmathfrak{g}
mathsf{...}sans-serifmathsf{T}
mathtt{...}monospacemathtt{x}
mathrm{...}upright romanmathrm{d}x

Spacing

Explicit horizontal gaps, in em: quad (1), qquad (2), enspace (0.5), thickspace, medspace, thinspace, negthinspace (negative).

Plain words in math

text{...} (and textrm, textbf, textit) unwraps to plain upright, bold, or italic words with real word spacing — nothing inside is scanned as commands. It exists for LaTeX paste-in compatibility; you rarely need it, because shortcode math already lives inside a normal paragraph, so ordinary words belong outside the [latex] span:

{ "p": "The solution [latex]x = 2[/latex] holds if the matrix is singular." }

Paste-in synonyms

A few AsciiMath habits are accepted as aliases: oo and infinity (∞), xx (×), -: (÷), +- (±), -+ (∓), ** (∗), @ (∘), EE (∃), AA (∀), O/ (∅).

Chemistry — ce{...}

Inside a [latex] span, ce{...} switches to chemical-formula rules (an mhchem-style subset, also backslash-free):

{ "p": "[latex]ce{2H2 + O2 -> 2H2O}[/latex]" }
  • Element symbols are upright; a trailing digit run is an automatic subscript: H2O → H₂O.
  • A leading or standalone digit is a coefficient: 2H2O.
  • Charges ride ^: SO4^2- → SO₄²⁻, Ca^2+, Cl^-.
  • Reaction arrows: -> (→), <- (←), <=> (⇌ equilibrium). An arrow takes optional condition labels above and below: ->[Delta] or ->[cat][heat].
  • Groups with ( ) or [ ] take a trailing subscript: Ca(OH)2.
  • Hydrate dot: CuSO4.5H2O → CuSO₄·5H₂O.
  • Nuclide prescripts lead the element: ^{14}_{6}C → ¹⁴₆C.
{ "p": "[latex]ce{N2 + 3H2 <=>[Fe] 2NH3}[/latex]" }

Physical quantities — pu{...}

pu{...} typesets a value-with-units: a number, a thin space, then upright units.

{ "p": "[latex]pu{9.81 m/s^2}[/latex] and [latex]pu{6.022e23 mol^-1}[/latex]" }
  • Scientific notation: 6.022e23 renders as 6.022 × 10²³ (an e not followed by digits is read as a unit letter).
  • Unit exponents with ^, including negatives: m/s^2, mol^-1, kg.m^{2}.
  • / is a per-slash; . or * is a product dot: kg.m → kg·m.
  • % and ° pass through: pu{25 °C}, pu{99.9 %}.

Errors are visible

An unrecognized command never disappears silently — it renders as a visible inline marker (for example ⟨foo?⟩) so a typo is caught on the proof, not discovered as a blank spot.

Where it works

Like every shortcode, [latex] renders inside any text element: paragraphs, headings, th/td cells, list items, and columns cells — so equations can sit in tables of constants, formulary grids, or exam layouts.

See it in action