obsidian-latex icon indicating copy to clipboard operation
obsidian-latex copied to clipboard

Is there a way to include an entire Mathjax config?

Open dzackgarza opened this issue 3 years ago • 5 comments

This isn't really an issue per se, but I'm wondering if there's an easy way to adapt this plugin to just use an entirely customized Mathjax configuration. For example, I have something of the following form I use for other previews:

image

Then e.g. I include it in my website in the following way (this gets compiled + embedding as a script on each webpage): image

Any idea if there's a way to point this plugin at a config like this (or something similar), as opposed to just a list of macros?

dzackgarza avatar May 09 '21 00:05 dzackgarza

As a plugin we can't control when MathJax gets loaded, this is actually a source of raciness in the plugin as is. If this is something that can be done after MathJax gets loaded then it should be possible to add as a feature otherwise I think it will be too unstable for widespread usage...

xldenis avatar May 09 '21 21:05 xldenis

I've quickly looked into this but in theory MathJax.startup.getComponents should allow us to reload the configuration? If I can get that to work it would be possible to accept arbitrary configurations.

xldenis avatar May 09 '21 21:05 xldenis

I'm not entirely sure how the library version of Mathjax works, but when it's included in web pages through a script tag, there are separate options for either loading the config strictly before Mathjax loads (https://docs.mathjax.org/en/v2.7-latest/configuration.html#using-in-line-configuration-options) or strictly afterward (https://docs.mathjax.org/en/v2.7-latest/configuration.html#configuring-mathjax-after-it-is-loaded).

dzackgarza avatar May 10 '21 02:05 dzackgarza

We can't count on anything which requires modifying HTML since we may get loaded after configuration has already started. In MathJax 3 there is a possibility to rebuild the internal objects after startup but it seems to only half work. What specific things would you hope to load? Is it really the configuration object itself or is there a specific bit of functionality you want (equation numbering?).

xldenis avatar May 10 '21 08:05 xldenis

The most pressing things would be the inline/displaymath delimiters, and maybe some kind of manual control over macros. Just feeding in my list of tex macros works fairly well (in fact I can just symlink my entire macro definition file), but there are certain macros that require different approaches in tex vs Mathjax.

One concrete example is that \coloneqq for a symbol like := is defined in a tex package which isn't available in Mathjax. So it's perfectly fine to leave in a tex macro file , but in Mathjax I usually have to use workarounds like this: image

dzackgarza avatar May 11 '21 02:05 dzackgarza