Notes and problem sets are increasingly drafted or “translated” by AI agents. The prose can be fine while the math pipeline silently breaks: the same bytes are valid in a PDF mental model but wrong for Markdown + Goldmark + MathJax on a static site. This post records the failure modes we hit on this blog and how to fix them.
1. Using \= as a “line-broken equals”
Symptom: A red backslash, a stray \backslash, or = shown next to garbage; KaTeX/MathJax may flag the line.
What went wrong: Agents sometimes emit \= to mimic handwritten layout (“equals starts the next line”). In browser math renderers, \= is not a portable “escaped equals” the way people imagine. It is easy for the engine to interpret incorrectly.
Fix: Use a normal equals inside math: =. For multi-line alignment, use a proper environment (e.g. aligned with &=) instead of inventing backslash-prefixed operators.
2. A line that contains only = inside $$ … $$
Symptom: Huge raw LaTeX on the page, random headings, or formulas split across the wrong HTML nodes.
What went wrong: This site uses Goldmark. A line that is only = (with optional spaces) can be parsed as a Setext underline: the previous line is promoted to a heading, and the $$ block is torn apart before MathJax ever sees a single well-formed display expression.
Replacing \= with = on its own line fixed the renderer complaint in (1) but triggered this Markdown trap in (2)—classic “fix one layer, break the next.”
Fix: Do not leave = alone on a line inside Markdown display math. Prefer:
- one line:
$$ LHS = RHS $$, or =at the end of the previous line, or- block delimiters that still avoid Setext patterns (and always re-run
hugoand inspect HTML).
Automated check (simple): inside each $$ … $$ span, reject any line matching ^\s*=\s*$.
3. A line that is only - (or “minus on its own line”) inside display math
Symptom: Similar class of breakage: list markers and block structure interact badly with multiline math in Markdown.
What went wrong: Agents like to break long ELBO-style lines visually:
\mathbb E[\cdots]
-
\mathrm{KL}(\cdots)
The isolated - is legitimate TeX spacing intent but ambiguous at the Markdown layer (list syntax, etc.).
Fix: Keep the subtraction on the same line as its left operand, or one continuous display line.
Three layers to keep straight
| Layer | Question to ask |
|---|---|
| LaTeX | Is every command defined in the subset your engine supports? |
| MathJax / KaTeX | Is this command allowed and spelled for web TeX, not a full TeXLive habit? |
| Markdown / Goldmark | Could this line be read as a heading, list, or other block syntax outside math? |
Agents often optimize the first row only. Static-site maintainers have to enforce all three.
Operational checklist
- Ban
\=as an “equals hack” in content repos that render with MathJax/KaTeX. - Ban standalone
=lines inside$$blocks in Hugo Markdown. - After bulk agent edits, run
hugoand spot-check HTML around headings and$$. - Encode (1)–(3) in Cursor rules or CI so the fix is repeatable, not heroic.
None of this replaces careful human review for exam-critical notes—but it stops the boring structural failures that make the whole page look “unrendered.”