.. _typeset-math:
**************************
Modifying Math on the Page
**************************
If you are writing a dynamic web page where content containing
mathematics may appear after MathJax has already typeset the rest of
the page, then you will need to tell MathJax to look for mathematics
in the page again when that new content is produced. To do that, you
need to use the :meth:`MathJax.Hub.Typeset()` method. This will cause
the preprocessors (if any were loaded) to run over the page again, and
then MathJax will look for unprocessed mathematics on the page and
typeset it, leaving unchanged any math that has already been typeset.
You should not simply call this method directly, however. Because
MathJax operates asynchonously (see :ref:`Synchronizing with MathJax
` for details), you need to be sure that
your call to :meth:`MathJax.Hub.Typeset()` is synchronized with the
other actions that MathJax is taking. For example, it may already be
typesetting portions of the page, or it may be waiting for an output
jax to load, etc., and so you need to queue to typeset action to be
performed after MathJax has finished whatever else it may be doing.
That may be immediately, but it may not, and there is no way to tell.
To queue the typeset action, use the command
.. code-block:: javascript
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
This will cause MathJax to typeset the page when it is next able to do
so. It guarantees that the typesetting will synchronize properly
with the loading of jax, extensions, fonts, stylesheets, and other
asynchornous activity, and is the only truely safe way to ask MathJax
to process additional material.
The :meth:`MathJax.Hub.Typeset()` command also accepts a parameter
that is a DOM element whose contents is to be typeset. That could be
a paragraph, or a ``

`` element, or even a MathJax math
``
Type some TeX code: