i wanted to reload Mathjax, i.e. force typesetting once again when clicking on a button.
Therefore i wrote the following code:
<button onClick="newTask()"></button>
The reload function contains:
function newTask(){
// This is a function creating a new task, i.e. replacing HTML between some tags
newCode();
// Now i want to renew typesetting by calling Mathjax
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
}
My script did not work. Where do I have to put the line "MathJax.Hub.Queue(["Typeset",MathJax.Hub]);" ? Any help would be greatly appreciated! :)
i wanted to reload Mathjax, i.e. force typesetting once again when clicking on a button.
Therefore i wrote the following code:
<button onClick="newTask()"></button>
The reload function contains:
function newTask(){
// This is a function creating a new task, i.e. replacing HTML between some tags
newCode();
// Now i want to renew typesetting by calling Mathjax
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
}
My script did not work. Where do I have to put the line "MathJax.Hub.Queue(["Typeset",MathJax.Hub]);" ? Any help would be greatly appreciated! :)
Share Improve this question asked Sep 9, 2014 at 20:32 AlexAlex 7511 gold badge9 silver badges35 bronze badges 5-
Any errors in the console? Does
newCode()
work as intended? – Owlvark Commented Sep 9, 2014 at 21:51 - newCode() works perfectly fine, it renders mathjax code like $$ my equation $$. – Alex Commented Sep 9, 2014 at 22:47
-
I only ask because the MathJax call seems ok. Have you verified
newCode()
by not calling MathJax at all? – Owlvark Commented Sep 9, 2014 at 22:58 - Is newCode asynchronous by any chance? – Peter Krautzberger Commented Sep 10, 2014 at 1:40
- Possible duplicate of How to recall or restart MathJax? – Vadzim Commented Jan 25, 2019 at 14:59
2 Answers
Reset to default 4For me using MathJax 3, I had to replace MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
with MathJax.typeset();
in Alex's solution.
I have no idea why it works now or did not before, but i changed the setup to the following:
inside the html file:
<button onClick="createBasicTask()">
where createBasicTask() is a new version of newTask()
and in the js file:
function createBasicTask(){
...
newTypeset();
}
with newTypeset being
function newTypeset(){
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
}
if you are interested, the whole script will be a task generator, the full source can be viewed here: Source
Live Demo (first task): Demo