Search code examples
mathjax

Get error when MathJax 3.0.1 typeset fails


I'm migrating from MathJax 2 to MathJax 3. In the previous version, when the Tex equation was wrong, MathJax displayed an error. Since version 3, the error is no longer displayed. Is there a way to detect when the typeset fails and get the error ?

I already try to get the promise returned by Typeset to get the error, but the promise successes.

I would like

  • to display the error as in previous version
  • or (better option) fire an event to get the error

Here is a JSFidle I made for my problem: https://jsfiddle.net/Geequette/aqsxv54d/

HTML

<!-- Valide formula -->
\[ e=mc^2 \]

<!-- Non valide formula -->
\[ {e=mc^2 \]

JS

MathJax.typesetPromise()    
    .then(() => console.log ('Typeset successful'))
    .catch((err) => console.log('Typeset failed: ' + err.message));

Solution

  • MathJax version 3 still displays errors. I updated your JSFiddle: https://jsfiddle.net/Imabot/u50cfsw1/

    Try it:

    \[ e=mc^2 \]
    
    \[ {e=mc^2 \]
    
    \[ e=mc^ \]