最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Reload Mathjax = forcing typesetting once again - Stack Overflow

programmeradmin2浏览0评论

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
Add a ment  | 

2 Answers 2

Reset to default 4

For 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

发布评论

评论列表(0)

  1. 暂无评论