Search code examples
mathjax

Can MathJax just leave the page blank when it fails to parse math instead of showing it red?


When MathJax fails to recognize a symbol (like \lightning) it displays the contents in red.

Is there a possibility to just leave the tag blank instead?


Solution

  • The errorSettings block controls the error messages produced when there is an internal error in MathJax (the "Math Processing Error"). TeX parsing errors are controlled by the TeX noErrors and noUndefined extensions. You can change the color from red to black, for example, using the options for noUndefined. Place

    <script type="text/x-mathjax-config">
    MathJax.Hub.Config({
      TeX: {noUndefined: {attribtues: {mathcolor: "black"}}}
    });
    </script>
    

    in your HTML file before the script that loads MathJax.js itself.

    Alternatively, if you really want unknown macros to be ignored completely, then you could use

    <script type="text/x-mathjax-config">
    MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
      MathJax.InputJax.TeX.Parse.Augment({csUndefined: function () {}});
    },20);
    </script>
    

    to replace the function that handles undefined control sequences by one that does nothing.