This Obsidian.md plugin lets you use MathJax preambles and switch them based on note paths.
.md
, .sty
, .tex
, and more.[[...]]
) or a path (relative to the vault root) to a preamble as "preamble" property....
) and math blocks ($$ ... $$
) will be automanically trimmed, so it's easy to edit preambles in Obsidian's markdown editor.[!note] Once a command is defined via
\newcommand
, it will not be removed unless it's overwritten by another\newcommand
or\renewcommand
. If you want to remove the effect of a certain command, you need to reload the app.
So suppose you want to use different probability symbols for different paths, say,
Folder A
Note B
Now you need to create two preamble files. Preambles can be any plain text files, but I recommend using markdown files because they can be easily edited from within Obsidian. In this example, the preamble for Folder A
can be written in either of the following syntaxes:
No formatting
\newcommand{\P}[1]{\mathbb{P} \left( #1 \right)}
Math block syntax
$$
\newcommand{\P}[1]{\mathbb{P} \left( #1 \right)}
$$
Inline math syntax
$\newcommand{\P}[1]{\mathbb{P} \left( #1 \right)}$
Code block syntax
\newcommand{\P}[1]{\mathbb{P} \left( #1 \right)}
I recommend using either of the $...$
or $$...$$
syntaxes. See here for details.
So now, we have the following two preambles:
Preamble A.md
$$
\newcommand{\P}[1]{\mathbb{P} \left( #1 \right)}
$$
Preamble B.md
$$
\newcommand{\P}[1]{\mathrm{Pr} \left[ #1 \right]}
$$
Before being able to use the preambles, you need to register them in the plugin settings.
Now, recall we wanted to apply Preamble A.md
for all notes inside Folder A
. This can be achieved by setting Preamble A.md
as the folder preamble for Folder A
.
preamble
propertyIn order to apply a preamble to a single note (as opposed to an entire folder), you can add a link to the preamble as the preamble
property of that note.
This plugin supports the normal markdown views (Reading view/Live preview), embeds, hover page preview, PDF export and Canvas, but slides (the core Slides plugin and the Advanced Slides plugin) are not supported.
However, you can still manually load markdown preambles with either of the $...$
or $$...$$
syntax into your slides by embedding them. For this reason, I recommend using this preamble format.
![[preamble]]
Slide 1
---
Slide 2
---
...
Since this plugin is still in beta, it's not on the community plugin browser yet.
But you can install the latest beta release using BRAT:
Options
. In the Beta Plugin List
section, click on the Add Beta plugin
button.RyotaUshio/obsidian-mathjax-preamble
in the pop-up prompt and click on Add Plugin.Auto-update plugins at startup
at the top of the page.Community plugins > Installed plugins
. You will find “MathJax Preamble Manager” in the list. Click on the toggle button to enable it.Here's a list of other math-related plugins I've developed:
If you find my plugins useful, please support my work by buying me a coffee!