Skip to content

Add 'upgreek' to the MathJax TeX packages allowlist (enables \uppi for ISO 80000-2 / GB 3102 upright constants) #423

Description

@sergeyFlakon

Summary

upgreek is missing from the MathJax TeX packages allowlist, so \uppi, \upmu, \upalpha … all fail with Undefined control sequence. The extension is already bundled and already registered — only the allowlist entry is missing, so this is a one-line change.

This blocks upright Greek constants, which ISO 80000-2 (adopted in China as GB 3102.11) requires: mathematical constants (π, e, i) set upright, variables italic. It is the standard convention in Chinese textbooks, and users following it currently have no supported way to get an upright π.

Current behavior

$\uppi$  ->  TeX error: Undefined control sequence \uppi

Cause

The allowlist at lib/mathjax/mathJaxConfig.js:6-8 omits 'upgreek':

packages: ['base', 'ams', 'boldsymbol', 'html', 'newcommand', 'unicode', 'color', 'mhchem', 'enclose', 'extpfeil', 'empheq', 'cases',
    'cancel',
    'fix-unicode', 'icon'],

Nothing else is missing:

  • mathjax-full 3.2.2 ships the extension at js/input/tex/upgreek/UpgreekConfiguration.js (it defines \uppi).
  • lib/mathjax/mathjax.js:14 already does require("mathjax-full/js/input/tex/AllPackages.js"), and AllPackages.js:34 requires ./upgreek/UpgreekConfiguration.js — so the package is registered, just not permitted.

Proposed fix

Add 'upgreek' to that array. No new require needed.

Verification

Patched the allowlist at runtime (packages.push('upgreek'), nothing else) against 3.0.1 with mathjax-full 3.2.2:

Input Before After
$\uppi$ Undefined control sequence <mi mathvariant="normal">π</mi> ✅ upright
$\upmu$ Undefined control sequence <mi mathvariant="normal">μ</mi> ✅ upright
$\pi$ <mi>π</mi> <mi>π</mi> — unchanged
$\alpha+\beta$ ok unchanged
$\ce{H2O}$ ok unchanged
$\begin{cases}…\end{cases}$ ok unchanged

Regression risk is essentially nil: \uppi and friends currently throw, so no existing document can depend on the present behavior, and \pi is untouched. Spot-checked that ams / mhchem / cases still resolve with the extra package present.

Context: the current workaround, and why it is not enough

The only thing that works today is a literal Unicode π inside \mathrm:

Input MathML OMML (DOCX)
\mathrm{π} (literal U+03C0) <mi mathvariant="normal"> m:sty="p" — upright
\mathrm{\pi} (the command) <mi> m:sty="i" — italic

\mathrm{\pi} does not work because MathJax ignores \mathrm for Greek commands, matching real TeX. So users must find/replace \pi\mathrm{π} and get the character right, which is fragile and not discoverable. \uppi is the idiomatic spelling and the one their LaTeX sources already use (\usepackage{upgreek}).

Out of scope

Not asking for any change to default rendering — \pi should stay italic, which is correct for most mathematics. This only makes the upright form expressible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions