Currently, Mathjax is loaded and operates on the whole vault.
This implies that definitions/commands/macros in one note affect other notes.
This is primarily due to the way both mathjax and obsidian are engineered to work.
However, it might be desirable in the future to have mathjax operate on a per document basis.
Apologies if this is like, unsolicited advice you’ve heard a million times but, I’ve personally switched from MathJax to Katex for math on my own website. I had many frustrations with MathJax, but Katex was a breath of fresh air, not just in implementation but also how fast it was in comparison. No clue if it’s viable for obsidian to switch at this point though
However, it might be desirable in the future to have mathjax operate on a per document basis.
As long as we’re left with a way to apply custom macro definitions easily to all (or selected) notes, without having to end up retyping those definitions for each markdown file and latex block.
A viable solution could be something like what this community plugin does, just supported officially by Obsidian as a core plugin.
It lets you:
Register multiple preambles (Add ⇨ Choose .sty/.tex/.md file in vault).
Apply preambles, from among those registered to any folder in the vault of your choice or the entire vault.
Or apply a preamble to a note by adding the path to a preamble file as a property.
In fact, this indeed ought to be part of the standard supported functionality, IMO. It just makes sense, considering Obsidian is so heavily used by people who need might need something like Latex/Mathjax.