Appearance
MathJax Fonts and TeX Packages
mathjax adds MathJax 4 components to the math renderer: fonts users can pick in Settings ▸ Markdown ▸ Math ▸ Math Font, and TeX packages that add commands and environments to every document. They apply everywhere Typora typesets math: the editor, HTML and PDF export, and command-line export.
json
"contributes": {
"mathjax": {
"fonts": [
{ "id": "mathjax-stix2", "name": "STIX Two", "path": "fonts/mathjax-stix2" }
],
"packages": [
{ "id": "chess", "path": "tex/chess.js", "macros": ["board", "move"], "environments": ["game"] }
]
}
}Fonts
| Field | Meaning |
|---|---|
id | The MathJax font name the component registers, such as mathjax-stix2. |
name | Shown in the Math Font menu. |
path | The font's folder in your extension: it holds svg.js, and svg/dynamic/ for fonts that split their glyph data. |
Ship the font folder the way its npm package does — for MathJax's own fonts, copy svg.js and svg/ from @mathjax/mathjax-<name>-font. Typora draws equations with MathJax's SVG output, so only the svg files are needed.
TeX packages
| Field | Meaning |
|---|---|
id | The TeX package name the component registers with MathJax (Configuration.create("chess", …)). It may not be one of MathJax's own packages. |
path | The component's .js file. |
macros, environments | Optional. When present, the package loads the first time one of these is used (MathJax's autoload); otherwise it loads with MathJax. Names are without the backslash. |
Build the component the way MathJax's own extensions are built: see Building a Custom Extension. It registers itself with the running MathJax through MathJax._.
Where they run
Components are code, so they never run in the editor page. MathJax runs in a Worker of its own, with a policy that lets it load scripts only from Typora and from the folders of the extensions that contribute components, and that blocks all network access. Your component has no Typora API there: it can only take part in typesetting. Typora checks the output before it reaches the document (SVG only, no scripts, event handlers or external references).
Fonts and packages need no permissions, so installing them asks for no consent. Users see them, with a switch, under Settings ▸ Markdown ▸ Math Extensions.
See also TeX Macros for macros that need no code.