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
- Have a
- Have a
providemethod, 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.
Options → Editor there would be a dropdown with:
MathJax Provider(or perhaps something simpler like
Which configuration of MathJax to use for rendering math
- Options: List of registered
Relevant Feature Requests
- Expose Mathjax configuration file
- A textbox in the settings used to enable physics package ---- the mathjax extension that redefines some commands
- Automatic equation numbering (Latex Math) - #4 by singhrac
- Is there a way to include an entire Mathjax config? · Issue #9 · xldenis/obsidian-latex · GitHub
- Custom MathJax extensions · Issue #6 · xldenis/obsidian-latex · GitHub
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 ) 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?