Unable to get MathJax to work

Hi, I’m unable to get MathJax to work on Devonthink 3. I can get Mermaid and Prism to both work fine, but not MathJax.

I have all three extensions enabled in my preferences and Javascript is enabled in the Web preferences.
I tried adding the two script lines in the previous post about MathJax not working, but that didn’t work. I tried quitting and restarting DT3, but that didn’t work. I am using this at work and I’m connected to the internet.

Here are screenshots of my preferences settings

And this is what I keep getting using a test of MathJax

Any help getting MathJax to work would be gratefully appreciated.

The only thing I can think of is that the university has some filters in place that are blocking MathJax, but I have no idea why that should be.

Thanks,

Adrian

Why do you use asterisks around your script tags? The beginning of your MD file looks utterly broken.

I hadn’t noticed that, it was what happened when I cut and pasted from

But it still doesn’t work when they are removed and the script tag formatted correctly. It also doesn’t work if the script lines are not included.

Why are you including the script lines in the first place? You’re referencing a three year old forum post.

I use MathJax in DEVONthink Pro and DEVONthink to Go. First, whatever problems you’re having ultimately turn out to be, it is extremely unlikely that your university has some kind of filters that would block MathJax. There are a number of reasons why that’s extremely unlikely, and we could get into them, but instead, I think it’ll be more fruitful to look at the example posted.

There’s a lot in the posted example that is unnecessary for using MathJax in DEVONthink, and at the same time, the MathJax parts that are there are incomplete, so I think that those are the reasons why it hasn’t worked in your environment. As pointed out by others, the first couple of lines in the file, involving scripts, are not necessary. Perhaps they’re from a forum posting from a time before DEVONthink incorporated MathJax support? In any case, I haven’t found it necessary to use such preambles in my files to get MathJax content to work.

A complication with using MathJax in DEVONthink is that the Markdown engine used (MultiMarkdown) seems to interfere with the interpretation of the delimiters for MathJax notation. In particular, I find that it’s not possible to follow the instructions in the MathJax documentation, specifically where in the section on Writing mathematics for MathJax it’s written:

The default math delimiters are $$...$$ and \[...\] for displayed mathematics, and \(...\) for in-line mathematics. Note in particular that the $...$ in-line delimiters are not used by default.

In DEVONthink, turns out that $…$ is used, and personally I have not been able to get the \[ … \] form or the double dollar sign form to work. I’ve seen postings in this forum where people show the use of $$ … $$ to get display math, and I don’t know why it doesn’t work for me. This tracker issue in the GitHub repository for MultiMarkdown 5 discusses the math delimiters in MultiMarkdown 5 and it seems clear that MultiMarkdown is getting in the way of some of the MathJax forms. (Note: I’m not certain that’s the same version of the MMD parser used in DEVONthink. I think there was a past discussion about this but I can’t find it right now.)

Anyway, here’s what seems to work:

  • $ … $ for inline math
  • \\[ … \\] for display math

Here’s an example of input and output. First, the settings used:

and a sample input and output:

4 Likes

The behavior is expected and documented in the MMD 6 user manual:

https://fletcher.github.io/MultiMarkdown-6/MMD_Users_Guide.html#math

A single \[ in your MD would probably be converted to a [ in HTML (which is what MathJAX deals with, I think). So, you have to escape the \ to achieve a \[ in the HTML. The same should go for \( vs. \\(.

@BLUEFROG: Maybe one sentence about the delimiters for MathJAX in the DT documentation could be added?

1 Like

Many thanks for your detailed and very helpful message. This cleared things up for me, and it does seem that there are issues between MultiMarkdown and MathJax: I’ve not used MathJax before, but use Markdown daily with my own pandoc filters. Together with chrillek’s response I was able to get things working as expected.

Many thanks again!

Many thanks for your response. Together with mhucka’s response I was able to get things working as expected.

Many thanks!

Noted.

No. There are no issues, the behavior is expected and documented.

You’re right, and.now I remember having run into this a couple of years back, and concluding the same.

Here’s a new quick test case:

For whatever it’s worth, note that the LaTeX equation environments work too, and without the need for the delimiters above.

If I got the MMD6 doc correctly, no space must follow nor precede the $$ delimiters:

To quote:

In order to be correctly parsed as math, there must not be any space between the $ and the actual math on the inside of the delimiter, and there must be space on the outside. ASCII punctuation can also serve as “space” outside of the math.

1 Like

Well spotted! That’s the issue. (Used outside of mmd, spaces are allowed, so of course I made assumptions. I have to read more carefully …)