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.
How it is laid out
Formulas are laid out as MathML Core lays out the MathML they correspond to: script shifts, fraction rules and gaps,
radical clearances, accent placement, operator spacing and stretchy fences all come from the constants of the math
font's OpenType MATH table. They are set in the engine's own math font; there is no key to choose another, and a
fontFamily on the paragraph does not reach the formula.
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. A word written as a command that names none - after a backslash (\left), or taking a braced argument (overset{a}{b}) - is reported as a WARNING and drawn as ⍰, never set as italic letters.
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 style (MathML's math-style: normal) — fractions at full size, with sum/product limits above and below. A display equation is placed as the paragraph's text is, by its textAlign:
{ "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
| Syntax | Renders | Notes |
|---|---|---|
x^2, x^{n+1} | superscript | braces group multi-token arguments |
x_i, x_{i,t} | subscript | combine freely: x_i^2 |
frac{a}{b} | stacked fraction | dfrac, tfrac, cfrac are accepted synonyms |
binom{n}{k} | binomial coefficient | dbinom, tbinom accepted |
sqrt{x} | square root | |
sqrt[3]{x} | cube root | optional bracketed degree, LaTeX-style |
root{n}{x} | n-th root | degree first, then radicand |
a / b | slash 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/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.
| Lowercase | Uppercase | ||
|---|---|---|---|
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
| Name | Glyph | Name | Glyph |
|---|---|---|---|
infty | ∞ | forall | ∀ |
partial | ∂ | exists | ∃ |
nabla | ∇ | neg | ¬ |
emptyset | ∅ | degree | ° |
aleph | ℵ | prime | ′ |
ell | ℓ | cdots | ⋯ |
hbar | ℏ | ldots, dots | … |
Re | ℜ | vdots | ⋮ |
Im | ℑ | ddots | ⋱ |
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 operators | Relations | ||
|---|---|---|---|
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 | ∈ ∉ ∋ |
setminus | ∖ | subset supset subseteq supseteq | ⊂ ⊃ ⊆ ⊇ |
lt gt | < > | ||
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}. widehat, widetilde and overline are drawn as wide as their argument; the others keep the mark's own width.
Letter styles
Variant commands restyle every letter and number of their argument, through any fraction, script, root or fence in it. A function name such as sin keeps its own style, and a variant command inside another wins for its own argument:
| Command | Style | Example |
|---|---|---|
mathbf{...} | bold upright | mathbf{v} |
boldsymbol{...} | bold italic | boldsymbol{beta} |
mathbb{...} | blackboard bold | mathbb{R} |
mathcal{...} | calligraphic script | mathcal{L} |
mathfrak{...} | Fraktur | mathfrak{g} |
mathsf{...} | sans-serif | mathsf{T} |
mathtt{...} | monospace | mathtt{x} |
mathrm{...} | upright roman | mathrm{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." }
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.022e23renders as 6.022 × 10²³ (anenot 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, ⍰, and the render report names the construct it could not read, so a typo is caught on the proof, not discovered as a blank spot.
Limits
| Limit | Default | What happens past it |
|---|---|---|
| Nesting inside one equation (braces, fences, a fraction's or a root's arguments) | 64 levels | The document is refused with EQUATION_TOO_DEEP |
| Equation source in one document, all equations together | 65,536 characters | The document is refused with EQUATIONS_TOO_LARGE |
A host may raise them, up to 128 levels and 262,144 characters; see Limits.
Accessibility
In a tagged PDF (a ua-1 or ua-2 claim), each formula is a Formula element with an alternate description written
in linear notation (x = (− b ± √(b² − 4 a c)) / (2 a) for the quadratic formula above, rather than the source's
control words), which is what a screen
reader reads aloud. Under PDF 2.0 each formula also carries its presentation MathML as an associated file, as PDF/UA-2
requires; with a PDF/A-4 claim that makes the file PDF/A-4F, and the report says so.
A formula that cannot be written as MathML (one drawing the ⍰ mark) withholds the PDF/UA-2 claim, and the report
names the construct.
DOCX
The DOCX writes each formula as native Office Math, editable in Word's equation editor. A display equation is an Office Math paragraph, aligned as the paragraph's text is.
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
- Math & chemistry showcase — one-page specimen of the full surface
- Quantum mechanics formulary and reaction kinetics formulary
- Category theory & homological algebra — heavy display-math layout
- Certificate of analysis and control system qualification —
ce{}andpu{}in lab documents