Skip to content

TeX Macros ​

texMacros adds macros to MathJax everywhere Typora typesets math: the editor, HTML and PDF export, and command-line export.

json
"contributes": {
  "texMacros": {
    "R": "\\mathbb{R}",
    "N": "\\mathbb{N}",
    "dd": "\\mathrm{d}",
    "argmax": "\\operatorname*{arg\\,max}",
    "abs": ["\\left\\lvert #1 \\right\\rvert", 1],
    "inner": ["\\left\\langle #1, #2 \\right\\rangle", 2]
  }
}

With this extension installed, $\abs{x} \in \R$ and $$\inner{u}{v}$$ work in any document.

Format ​

The shape is MathJax's tex.macros:

ValueMeaning
"body"A macro without arguments.
["body", n]A macro with n arguments (0–9), referenced as #1 … #n in the body.
  • Macro names are letters only. A leading backslash in the key is accepted and ignored ("\\R" is the same as "R").
  • Remember to escape backslashes in JSON: \mathbb is written "\\mathbb".

Precedence ​

  • Users can also define global macros in Settings ▸ Markdown ▸ Math ▸ TeX Macros (markdown.texMacros in settings.toml).
  • A \newcommand inside a document still works and wins over global macros for that document.

See the Math Pack sample, which combines macros with theorem and proof snippets.

Theme adapted from Nimbus (MIT).