Appearance
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:
| Value | Meaning |
|---|---|
"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:
\mathbbis written"\\mathbb".
Precedence
- Users can also define global macros in Settings ▸ Markdown ▸ Math ▸ TeX Macros (
markdown.texMacrosinsettings.toml). - A
\newcommandinside 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.