Attention
Version 3 is now the current version of MathJax. This document is for version 2.
MathJax Debugging tips¶
This page documents basic tips for debugging MathJax in your application.
Using unpacked resources¶
MathJax provides both packged (minified) and unpacked versions of all its components. For debugging, it is useful to switch to an unpacked versions.
For example, using a CDN just add unpacked/ before MathJax.js, e.g., from
<script type="text/javascript" async
src="https://example.com/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
to
<script type="text/javascript" async
src="https://cdn.mathjax.org/mathjax/latest/unpacked/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
Getting traceback information¶
MathJax.Hub.lastError
MathJax stores the error object from the last Math Processing Error in MathJax.Hub.lastError. This allow developers to access the stack trace information when needed.
Add listener for MathJax errors¶
MathJax provides a detailed signaling infrastructure which a developers can hook into.
The following example hooks into Math Processing Errors.
MathJax.Hub.Register.MessageHook("Math Processing Error",function (message) {
// do something with the error. message[2] is the Error object that records the problem.
});
Another example hooks into TeX parsing errors.
MathJax.Hub.Register.MessageHook("TeX Jax - parse error",function (message) {
// do something with the error. message[1] will contain the data about the error.
});
Note
For more information, see The MathJax API.