3

I have javascript code that procedurally creates equations and stores them as strings. I want to use Mathjax to display these equations nicely, preferably using ASCIImath format. How can I pass these strings to Mathjax?

The reason I store the equations as strings is that otherwise javascript tries to evaluate them, which is something I dont want.

1 Answers1

0

You need to insert your content into the DOM and call MathJax to render it -- MathJax needs the DOM to properly render your content.

MathJax uses custom script tags to store math sources in the page. For asciimath the script type is <script type="math/asciimath"> math content </script>. See the documentation on the MathJax processing model for more details.

After you insert your content into the DOM, you need call MathJax. One way is MathJax.Hub.Queue(["Typeset",MathJax.Hub]); which will render all new content in the entire page (but not rerender everything).

You can also pass along DOM elements, e.g., via an id MathJax.Hub.Queue(["Typeset",MathJax.Hub,"mathId"]);. See the documentation on modifying math on a page for more details.

Peter Krautzberger
  • 5,145
  • 19
  • 31