Inconsistent math rendering when switching note previews due to Latex definitions

Steps to reproduce

  1. Create a new note (A) and input
$$
	\DeclareMathOperator{\cov}{cov}
	\DeclareMathOperator{\var}{var}
	\newcommand{\E}{\mathbb E}
$$
  1. Create a second note (B) and input
    $$\cov(X,Y) = E((X-\E X)(Y-\E Y))$$
  2. Restart Obisidian and open note B without first opening note A
  3. Switch to preview mode. Result:
    image
  4. Now preview note A and then switch back to preview note B. Result:
    image

Comment

Although this is not a bug per se, it seems like inconsistent behavior to me.

It is obviously caused by the fact that Obsidian uses a global Mathjax interpreter. If Mathjax first interprets the definitions in note A, it then understands how to display note B.

I would, in fact, like some consistent version of this behavior. For example, Neuron uses a head.html file that is included in every note. You can place your Latex header definitions in there. Is there anything like this for Obsidian at this point? I don’t want to copy all my definitions for math notes to every single note.

Environment

  • Operating system: Windows 10
  • Obsidian version: v0.12.15

this is not a bug. there is a plugin that adds a shared macro to all files.

Understood. I just thought that notes causing side-effects to other unrelated notes may be considered a bug. Feel free to close this. What is this plugin called please?

Got it. Extended MathJax