Cannot get MathJax config working to load MathJax extension

MathJax version 3 support is built into recent versions of DEVONthink 3 (yay!). I want to load a certain MathJax 3 extension that is not part of the default DEVONthink MathJax configuration. In principle, this should be easy by doing the following. In my DEVONthink 3 preferences, in FilesMarkdown, I reference a JavaScript file,


and then in this mathjax-config.js file, I follow the MathJax 3 instructions for putting configuration settings in a <script> block and include the documented block of code that should load the extension, as follows (and note that surrounding this with <script>…</script> is unnecessary because DEVONthink does it automatically):

window.MathJax = {
  loader: {load: ['[tex]/mathtools']},
  tex: {packages: {'[+]': ['mathtools']}}
};

But it does not work: if I try to use one of the operators defined by the mathtools extension, DEVONthink does not render it. Here is an example:


I’ve tried replacing window.MathJax with just MathJax in the JavaScript file (as shown in some other examples like this in the MathJax documentation), but no luck. I’ve used DEVONthink’s command for converting Markdown to HTML and inspected the HTML, and inclusion of my mathjax-config.js happens before the MathJax extension is loaded, which is the order it’s supposed to be in, and so incorrect ordering is not the problem either.

How can I get MathJax extensions/configurations to work using the JavaScript inclusion feature in DEVONthink?

Notes, to forestall people going down the wrong paths:

  1. If you search for MathJax configuration, you may find instructions to use MathJax.Hub.Config. That’s for MathJax 2, not the present case.
  2. There are other approaches that do work in DEVONthink, in particular to load MathJax and the configuration using a file that is transcluded into the Markdown document. I’m trying to use the approach described here (i.e., using a JavaScript file in the FilesMarkdown preferences panel), without using a transclusion approach.
  3. My need is not actually for \bigtimes. That’s just an example.

Update: putting the following in a file (in my case, mathjax-config.js) works after all:

window.MathJax = {
  loader: {load: ['[tex]/mathtools']},
  tex: {packages: {'[+]': ['mathtools']}}
};

I am struggling to understand why it didn’t work earlier today. Best guess is that some kind of caching was at play. (I was editing the same mathjax-config.js file while testing different variations, and maybe that doesn’t work without restarting DEVONthink. This time I put the content in a separate file altogether, and it worked.)

2 Likes