Skip to content

Fix HTML equation numbers lost with --mathml or --math-method - #15358

Merged
cderv merged 2 commits into
mainfrom
fix/math-method-cli-equation-numbers
Nov 13, 2026
Merged

cderv merged 2 commits into
mainfrom
fix/math-method-cli-equation-numbers

Conversation

@cderv

@cderv cderv commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

When the math method is chosen on the command line, quarto render doc.qmd --mathml (or --math-method=mathml, --math-method=plain) drops cross-referenced equation numbers from HTML output. The same document with html-math-method: mathml in YAML shows (1) next to the equation.

This matters more now that the deprecation warning for --mathml, --katex, etc. points users to --math-method (#15321 made Quarto honor it).

Root cause

Equation numbering appends \tag{1} for MathJax and KaTeX, which render it as a right-aligned number, and \qquad(1) for other methods, which have no \tag support. It chose between the two from the html-math-method value in the format options only, never from the command line flags. Bootstrap HTML defaults to mathjax, so with --mathml the equation got \tag{1}, which MathML and plain output drop.

Fix

The numbering now uses resolveHtmlMathMethod() when a command line flag chose the method, as the KaTeX post-processor, the template math setup and llms.md output already do. Without a flag, the value from the format options is used as before.

The flag is not written back into the format options: the template math setup relies on telling a flag apart from html-math-method, to leave the math library to Pandoc when a flag is used.

One visible change: --katex or --mathjax on HTML without Bootstrap (theme: none, minimal: true) now numbers equations with \tag{1} instead of \qquad(1), as Bootstrap HTML already does. KaTeX renders the number right-aligned (checked in a browser).

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes
  • updated the appropriate changelog in the PR
  • ensured the present test suite passes
  • added new tests
  • created a separate documentation PR in Quarto's website repo and linked it to this PR
AI-assisted PR
  • AI tool used: Claude Code
  • Codebase grounding: local clone, DeepWiki MCP
  • Human review: I have reviewed, tested, and verified the AI-generated content before submitting.

Crossref equation numbering picks \tag{n} for MathJax and KaTeX and
\qquad(n) for every other method, reading the html-math-method filter
param. That param came from the Pandoc defaults only, so a method chosen
on the command line never reached the filter. On Bootstrap HTML the
defaults say mathjax, so --mathml, --math-method=mathml and
--math-method=plain got \tag{1}, which those methods drop: the equation
number disappeared from the output.

The param now comes from resolveHtmlMathMethod when a flag chose the
method, as the KaTeX post-processor, the template patch and llms.md
output already do. Without a flag it keeps the defaults value, so the
default webtex URL Quarto fills in is unchanged. The flag is not written
into the defaults or format.pandoc: the template patch relies on telling
a flag apart from html-math-method.

One visible change: --katex or --mathjax on HTML without Bootstrap now
numbers with \tag{1} instead of \qquad(1), as Bootstrap HTML already does.
@posit-snyk-bot

posit-snyk-bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cderv
cderv marked this pull request as ready for review November 13, 2026 16:33
@cderv
cderv merged commit 5bf4366 into main Nov 13, 2026
51 of 52 checks passed
@cderv
cderv deleted the fix/math-method-cli-equation-numbers branch November 13, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants