MathJax extensions

As Silver and StrachuDotNet recommended it on Discord, I’m opening a feature request for MathJax extensions: here is my original post from Discord.

I’m a total newbie to Obsidian, loving it so far!
But would it be possible to use MathJax extensions (like color.js , etc: some of them are crucial for me (especially xypic for commutative diagrams))?

Usually, the way it’s done in javascript, if I’m not mistaken, is to go something like this:

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
tex2jax: {inlineMath: [["$","$"],["\\(","\\)"]]},
TeX: {
extensions: ["AMSmath.js","AMSsymbols.js","MathMenu.js", "MathZoom.js",
"color.js", "https://sonoisa.github.io/xyjax_ext/xypic.js"],
Macros: {
// custom macros, quite important too
}
}
});
</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS_HTML"></script>

It would be awesome if it could be added indeed, lots of people doing math research can’t make do with vanilla MathJax unfortunately (especially in fields like category theory, where commutative diagrams are everywhere :smile:)

19 Likes

I definitely second this! This would also be really useful for me, even if at first it was just restricted to standard packages like amsmath, tikz etc.

2 Likes

This would be handy for more complex latex requirements, e.g. I DO like having my proofs in a very specific format and custom macros are useful.

3 Likes

Please include mhchem.js as well.

1 Like

Yes! If we could tell Obsidian to load a custom file like this, that would be amazing.

1 Like

We will add the full set of mathjax input packages in a future release. If you want other packages, maybe you can load them when the plugin interface will be available.

3 Likes

Perhaps there could be a general mechanism that allows injecting arbitrary html for advanced users (similar to obsidian.css allowing injection of css)

You can use plugins for that.
It is not wise to allow arbitrary html from markdown files because you can effectively send a markdown files to somebody and have it do nasty things to their computer. We cannot run that risk.

1 Like

Sure, I was thinking of, say, a general obsidian.js file similar to the css one.

You can always make a similar feature to Typora, where you just directly insert $'s into the file.