[Proposal] MathJax provider API

There doesn’t seem to be a reliable way of customizing the MathJax configuration currently (the Extended MathJax plugin helps, but even that is a slightly hacky solution, and it only covers preambles).

There are a fair few feature requests surrounding MathJax in the Feature Requests category, but ultimately I think implementing totally customizable MathJax in Obsidian core will never feel elegant, since it would either involve a sizable effort in providing a good interface for it, or it would require the user to set up the MathJax object in JS themselves, which is scary for a large group of less technical users.

To cater to those who are heavy users of math in their vaults, full customization would be a very valuable thing.

The better solution I think would be implementing a MathJaxProvider, which could be subclassed and customised by plugins. The MathJaxProvider should:

  • Have a displayName attribute
  • Have a providerID attribute
  • Have a provide method, which would return an initialised MathJax3 object.

The default MathJax implementation would be turned into a MathJaxProvider (perhaps aptly named “Obsidian Default”).

Plugins could register MathJaxProviders.

In Options → Editor there would be a dropdown with:

  • Label: MathJax Provider (or perhaps something simpler like Math Provider)
  • Text: Which configuration of MathJax to use for rendering math
  • Options: List of registered MathJaxProviders

Relevant Feature Requests

Alternative Solutions

Alternatively there could be a mathjax.js file in .obsidian which would instanciate the MathJax object - this could then be overridden by users. This is less elegant and more prone to untechnical users breaking their configurations in hard-to-debug ways.


This would be quite easy to implement in Obsidian, I’d imagine, and it likely wouldn’t require significant effort to implement or maintain.

  • Should verify that object returned by provider is a mathjax instance
  • If a plugin is removed such that the configured value to the mathjax provider setting is no longer valid, it should default back to ‘Obsidian Default’.

I really hope this is something that could be added to Obsidian. It already has really good math support, but this (along with WYSIWYG eventually :eyes: ) would bring it to the next level.

P.S. MathJax 3.2 will be out soon, perhaps implementing this could be implemented when MathJax is upgraded to 3.2 in Obsidian anyway?