Re: [mathjax-users] MathJax v4.0.0 Released

37 views
Skip to first unread message

Lisa Johnson

unread,
Aug 5, 2025, 4:39:12 PMAug 5
to mathja...@googlegroups.com
Hi all!
I'm getting error messages for some but not all mathjax equations using Simple Mathjax plugin in Wordpress. Maybe I have the wrong URL; I'm using

This is what I use for Mathjax 3 (or so says the plugin - there are just dropdowns for versions 2 and 3 so far).

Maybe I'm pointing to the wrong URL? Below are examples of a page from using Mathjax 3 and then using Mathjax 4.

I'm not a programmer, so I hope I can continue using 3 if the problem persists? Or maybe I can add custom mathjax config to the Simply Mathjax - there is a box for that (or maybe just use another plugin)? I probably have thousands of mathjax equations on my site and don't want to change all these ;)
Mathjax 3.png

Mathjax 4.png
Thanks for any help!
Lisa





On Tue, Aug 5, 2025 at 6:43 AM <dp...@mathjax.org> wrote:

The MathJax team is pleased to announce the long-awaited release of MathJax v4.0.0.  This is the culmination of more than three years of work by the MathJax team, with major new features and important improvements.  It has been a long time in coming, but we hope the results are worth the wait.


Some of the new and improved features in v4 include:


  • Extended font support (11 new fonts).
  • A new default font with much greater character coverage.
  • Line-breaking support (for in-line as well as displayed equations).
  • An updated expression explorer that is now on by default.
  • Separation of speech generation into a webworker thread for better performance.
  • Support for HTML embedded in TeX and MathML expressions.
  • Availability as ES6 modules as well as CommonJS modules.
  • New TeX extensions, including the begingroup extension from v2 (with more features), and several font-related extensions.
  • Inclusion of the textmacros extension in all combined component files.
  • Updated mathtools package to include the changes from 2022 and 2024.
  • Improvements in the baseline alignment of text in CHTML output in WebKit-based browsers.
  • Improved stretchy delimiters in CHTML output.
  • More promise-based conversion and typesetting calls at the document level.
  • And much more.

For many sites, the only change that will be needed to use v4 is to change the URL where you load MathJax to refer to version 4 rather than version 3, and to remove the /es5 directory from the URL.  Most v3 configurations should still work with v4; but if you use the startup.ready() function to modify MathJax or create new TeX extensions, there may be some adjustments needed.  One important change of note is that, since the number of TeX packages has grown, the all-packages extension and the "-full" components have been removed, so if you are using those, you will need to change to a component without the "-full" and either rely on the autoload extension to load the needed packages, or load them explicitly.  


The MathJax documentation has been substantially updated for version 4, and now includes the missing or limited sections on using MathJax in node, including many examples and details. See the What's New in V4.0 section (more than 50 pages long) for much more information about the features described above, and in particular, check the Breaking Changes section for any changes that may affect your usage.


The MathJax web demos repository has been updated for v4.0, and reorganized for easier viewing. The demos now include a "Show Source" button that displays explanations and the important sections of the source code rather than using separate .md files, so there are fewer files to wade through, and you can compare the source code to the output more easily. There are also new examples in the documentation on using MathJax in a browser; most are listed in the Examples in a Browser section.


The MathJax node demos repository is being updated and reorganized as well, but work is still being done on that, as some of the documentation needs to be expanded (for now, you may need to read the comments in the code). The tools in this repository have been made more powerful and complete, and much of the functionality that is common across multiple tools have been moved to utility libraries that can be shared by several tools. That means the examples are no longer stand-alone files, but they are more complete in their ability to use the features of MathJax. For example, all the examples that produce CHTML or SVG output can select the font to use, or add speech labels, and so on, and because speech is now available in all those examples, there are no longer separate speech demos. The tools can now take several expressions at once to typeset, or take them from a file, or process a complete HTML page. This means there are no longer separate page-based tools, so the number of examples is reduced, but the functionality is expanded. The MathJax documentation now covers using MathJax in node application in more detail than for v3, with lots of examples; most of these are listed in the Examples in Node Applications section.


As always, you may report issues in the MathJax issue tracker for v4; this is a major update, and there are sure to be things that will need adjusting.

--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mathjax-users/570C592A-68DC-41FB-968A-34A7DC1002A7%40mathjax.org.

Davide Cervone

unread,
Aug 5, 2025, 5:34:49 PMAug 5
to mathja...@googlegroups.com
Lisa:

You haven't provided the actual expression that is causing the error (the LaTeX code), which is really what we need to see in order to help you.

Versions 3 and 2 of MathJax didn't always properly report incorrectly nested environments, and so I suspect you have done that without knowing it.  MathJax v4 is more careful about following LaTeX's rules, and so reports more of the situations that are invalid in LaTeX.  See the Other TeX Input Changes section of the What's New in MathJax v4.0 chapter of the documentation for more on this.

From the output, it looks like you may have used a \begin{align} ... \end{align} inside a larger expression (if the quadratic and "Explain" and "Solve for $x$" are part of the same expression).  If that's the case, you should use \begin{aligned} ... \end{aligned} instead.  If that's NOT the case, then send along the expression so we can look into what is happening.

Davide


On Aug 5, 2025, at 4:38 PM, Lisa Johnson <lis...@gmail.com> wrote:

Hi all!
I'm getting error messages for some but not all mathjax equations using Simple Mathjax plugin in Wordpress. Maybe I have the wrong URL; I'm using

This is what I use for Mathjax 3 (or so says the plugin - there are just dropdowns for versions 2 and 3 so far).

Maybe I'm pointing to the wrong URL? Below are examples of a page from using Mathjax 3 and then using Mathjax 4.

I'm not a programmer, so I hope I can continue using 3 if the problem persists? Or maybe I can add custom mathjax config to the Simply Mathjax - there is a box for that (or maybe just use another plugin)? I probably have thousands of mathjax equations on my site and don't want to change all these ;)
<Mathjax 3.png>

Lisa Johnson

unread,
Aug 5, 2025, 6:22:36 PMAug 5
to mathja...@googlegroups.com
Davide,
Thanks so much for your quick reply! 

I think you figured it out: here is the expression:
  $ \displaystyle \begin{align}a{{x}^{2}}+bx+c&=0;\,\,\text{Example:}\\a\left( {{{x}^{2}}+\frac{b}{a}x} \right)&=-c\\\,\left( {{{x}^{2}}+\frac{b}{a}x} \right)&=-\frac{c}{a}\\{{x}^{2}}+\frac{b}{a}x+{{\left( {\frac{b}{{2a}}} \right)}^{2}}&=-\frac{c}{a}+{{\left( {\frac{b}{{2a}}} \right)}^{2}}\\{{\left( {x+\frac{b}{{2a}}} \right)}^{2}}&=-\frac{c}{a}+{{\left( {\frac{b}{{2a}}} \right)}^{2}}\\\text{Solve for }x\text{!}\end{align}$

I get a lot of my expressions by copying and pasting from Mathtype in Word (I know - not ideal - but it has generally worked fine before now), so does that mean I will need to change these expressions from "aligned" from "align" in every case? (Maybe I could do a careful global search/replace in the HTML?!).

Or could I just continue with V3 indefinitely, since it works great? I imagine there are other problems that are similar to this - and I don't have a good test environment for having half of it working, and half of it not (although I could create one).
Thanks again as always!
Lisa

Davide Cervone

unread,
Aug 5, 2025, 7:47:16 PMAug 5
to mathja...@googlegroups.com
Lisa:

OK, as I expected, the use of \begin{align} ... \end{align} here is not valid LaTeX, as it is only allowed at the top level of an expression.  MathJax allows you to use align environments inside math delimiters (even in-line delimiters, which it really shouldn't), but the \displaymode macro causes MathJax to report this as invalid nesting, as the environment has to the be first thing inside the math delimiters if used in that way.

One solution would be to remove the \displaystyle, as the align environment sets that automatically.  Another would be to use a TeX input jax pre-filter to convert align to aligned when it is not at the top level.  Here is a configuration that implements one approach to that:

MathJax = {
  tex: {
    inlineMath: {'[+]': [['$', '$']]},
    preFilters: [
      ({math}) => {
        if (math.start.delim !== '\begin{align}') {
          math.math = math.math.replace(/(\\begin|\\end){align}/g, '$1{aligned}');
        }
      }
    ]
  }
}

If there are other environments that you are using this way, you can modify the code to replace those as well.

Hope that does the trick for you.

Davide


Lisa Johnson

unread,
Aug 6, 2025, 9:46:37 AMAug 6
to mathja...@googlegroups.com
Thanks so much for this - I really appreciate it!!

I tried it in the box on the plugin settings, but the equations didn't render. But I think I need to incorporate this code in the default code below that I was replacing? And I'm not sure how to do that?
image.png
There is also this option in the plugin settings:
image.png


Christian Lawson-Perfect

unread,
Aug 6, 2025, 10:08:22 AMAug 6
to mathja...@googlegroups.com
Hi Lisa,
I'm the current maintainer of the Simple MathJax plugin. You could just paste all of the code Davide gave into the "Custom MathJax config" box, but to keep the other settings that are WordPress-specific, here's the default code plus Davide's filter:

MathJax = {
  tex: {
    inlineMath: {'[+]': [['$', '$']]},
    preFilters: [
      ({math}) => {
        if (math.start.delim !== '\begin{align}') {
          math.math = math.math.replace(/(\\begin|\\end){align}/g, '$1{aligned}');
        }
      }
    ]
    processEscapes: true
  },
  options: {
    ignoreHtmlClass: 'tex2jax_ignore|editor-rich-text'
  }
};


Lisa Johnson

unread,
Aug 6, 2025, 3:04:58 PMAug 6
to mathja...@googlegroups.com
Thanks so much, Christian! I'm determined to use V4 :)

This code DID fix the problem with the erroneous nesting (except it left the "displaystyle" in it. But it broke many other equations.
Here's V3 and then V4 with adding your code in the Custom Mathjax config:
V3:
image.png
V4 with the code:
image.png
Here's the mathjax code:

$ \displaystyle \begin{align}y&amp;=-8{{\left( {\frac{1}{2}x+2} \right)}^{2}}+3=-8{{\left( {\left( {\frac{1}{2}} \right)\left( {x+4} \right)} \right)}^{2}}+3\\&amp;=-8{{\left( {\frac{1}{2}} \right)}^{2}}{{\left( {x+4} \right)}^{2}}+3=-2{{\left( {x+4} \right)}^{2}}+3\end{align}$, so the vertex is $ (–4, 3)$.


$ y=a(x-{{r}_{1}})(x-{{r}_{2}})$

If you want to try this in your environment to see if you get the same, that'd be great. Otherwise, I may have to resort to using V3 or going in with global search/replace to fix.
Lisa


Davide Cervone

unread,
Aug 6, 2025, 3:52:02 PMAug 6
to mathja...@googlegroups.com
Lisa:

It looks like the inlineMath setting isn't working, as the dollar signs are not being processed.  Can you show EXACTLY what you entered in the control panel for the configuration?

You might try going back to 

inlineMath: [['$', '$'], ['\\(', '\\)']],

again and see if that works or even just

inlineMath: [['$', '$']],

if you don't use the \(...\) delimiters.  Also, check the browser developer's console to see if there are any error messages.

Davide


On Aug 6, 2025, at 3:04 PM, Lisa Johnson <lis...@gmail.com> wrote:

Thanks so much, Christian! I'm determined to use V4 :)

This code DID fix the problem with the erroneous nesting (except it left the "displaystyle" in it. But it broke many other equations.
Here's V3 and then V4 with adding your code in the Custom Mathjax config:
V3:
<image.png>
V4 with the code:
<image.png>
Here's the mathjax code:

$ \displaystyle \begin{align}y&amp;=-8{{\left( {\frac{1}{2}x+2} \right)}^{2}}+3=-8{{\left( {\left( {\frac{1}{2}} \right)\left( {x+4} \right)} \right)}^{2}}+3\\&amp;=-8{{\left( {\frac{1}{2}} \right)}^{2}}{{\left( {x+4} \right)}^{2}}+3=-2{{\left( {x+4} \right)}^{2}}+3\end{align}$, so the vertex is $ (–4, 3)$.


$ y=a(x-{{r}_{1}})(x-{{r}_{2}})$

If you want to try this in your environment to see if you get the same, that'd be great. Otherwise, I may have to resort to using V3 or going in with global search/replace to fix.
Lisa

On Wed, Aug 6, 2025 at 9:08 AM Christian Lawson-Perfect <christia...@gmail.com> wrote:
Hi Lisa,
I'm the current maintainer of the Simple MathJax plugin. You could just paste all of the code Davide gave into the "Custom MathJax config" box, but to keep the other settings that are WordPress-specific, here's the default code plus Davide's filter:

MathJax = {
  tex: {
    inlineMath: {'[+]': [['$', '$']]},
    preFilters: [
      ({math}) => {
        if (math.start.delim !== '\begin{align}') {
          math.math = math.math.replace(/(\\begin|\\end){align}/g, '$1{aligned}');
        }
      }
    ]
    processEscapes: true
  },
  options: {
    ignoreHtmlClass: 'tex2jax_ignore|editor-rich-text'
  }
};


On Wed, 6 Aug 2025 at 14:46, Lisa Johnson <lis...@gmail.com> wrote:
Thanks so much for this - I really appreciate it!!

I tried it in the box on the plugin settings, but the equations didn't render. But I think I need to incorporate this code in the default code below that I was replacing? And I'm not sure how to do that?
<image.png>
There is also this option in the plugin settings:
<image.png>

Lisa Johnson

unread,
Aug 6, 2025, 5:41:41 PMAug 6
to mathja...@googlegroups.com
THis is the code (from Christian) I put in the Custom Math Config.
MathJax = {
  tex: {
    inlineMath: {'[+]': [['$', '$']]},
    preFilters: [
      ({math}) => {
        if (math.start.delim !== '\begin{align}') {
          math.math = math.math.replace(/(\\begin|\\end){align}/g, '$1{aligned}');
        }
      }
    ]
    processEscapes: true
  },
  options: {
    ignoreHtmlClass: 'tex2jax_ignore|editor-rich-text'
  }
};

I tried your two other suggestions (in the inlineMath line above) and it didn't work.
I do see a  Uncaught SyntaxError: Invalid left-hand side in assignment 
when I look at development tools in Chrome - here, it looks like:
image.png
Sorry - I know just enough to be dangerous, but it's all a little greek to me...
Lisa
    

Davide Cervone

unread,
Aug 6, 2025, 6:21:19 PMAug 6
to mathja...@googlegroups.com
Thank you, your picture of the error page gives the answer.  The ">" is being replaced by an HTML entity ("&gt;") which should not be done for the contents of a script, and that is is causing the configuration to fail to be run by the browser.  I'm not sure if Christian can do anything about that, but the HTML escaping should not be performed on script contents.

Fortunately, there is an alternative.  Replace the line

({math}) => {

with

function ({math}) {

instead, and that should be able to pass through the sanitization without being harmed.

I also spotted another error in my own script.  The line

if (math.start.delim !== '\begin{align}') {

should have "\\" rather than "\", so it should be

if (math.start.delim !== '\\begin{align}') {

instead.

See if that works for you.

Davide



On Aug 6, 2025, at 5:41 PM, Lisa Johnson <lis...@gmail.com> wrote:

THis is the code (from Christian) I put in the Custom Math Config.
MathJax = {
  tex: {
    inlineMath: {'[+]': [['$', '$']]},
    preFilters: [
      ({math}) => {
        if (math.start.delim !== '\begin{align}') {
          math.math = math.math.replace(/(\\begin|\\end){align}/g, '$1{aligned}');
        }
      }
    ]
    processEscapes: true
  },
  options: {
    ignoreHtmlClass: 'tex2jax_ignore|editor-rich-text'
  }
};

I tried your two other suggestions (in the inlineMath line above) and it didn't work.
I do see a  Uncaught SyntaxError: Invalid left-hand side in assignment 
when I look at development tools in Chrome - here, it looks like:
<image.png>

Lisa Johnson

unread,
Aug 7, 2025, 12:38:14 PMAug 7
to mathja...@googlegroups.com
Davide and Christian,

I think it's working - with one change - yeah! Thanks so much for all your help.

I still kept getting errors and checked to see that it was failing on processEscapes: true, so I just took this out. What does this do? Is that OK?

Lisa



Davide Cervone

unread,
Aug 7, 2025, 2:15:42 PMAug 7
to mathja...@googlegroups.com
Christian left out a comma after the close bracket before the "processEscapes" line, which is what was causing the error.  That is easy to do and I do it all the time, but putting in that comma should make it work, if you want the processEscapes to be on.  That allows you to use \$ to get a literal dollar sign (one that isn't treated as a math delimiter), for example.

Davide


Lisa Johnson

unread,
Aug 7, 2025, 5:32:13 PMAug 7
to mathja...@googlegroups.com
Yes - I added the comma and it's working now - and I do need that feature.
Thanks!
Lisa

Reply all
Reply to author
Forward
0 new messages