3

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! :)

Alex
  • 751
  • 1
  • 6
  • 34

2 Answers2

4

For me using MathJax 3, I had to replace MathJax.Hub.Queue(["Typeset",MathJax.Hub]); with MathJax.typeset(); in Alex's solution.

Faraz Ahmad
  • 515
  • 1
  • 6
  • 13
3

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

Alex
  • 751
  • 1
  • 6
  • 34