If you're typing up a post with quite a bit of LaTeX, and you're looking at your post preview to check your formulae as you type them up, then every time you press a key, the site re-renders all of the latex formulae you've already typed, causing your entire post to flicker. This isn't a huge problem, but it is a bit distracting.

Surely MathJax has a feature allowing you to re-render one specific formula rather than re-rendering all formulae on the page, no? Only the formula being edited needs to be re-rendered.

The flowchart seems pretty simple:

If the user inserts a character:

  1. If it's inside a LaTeX formula (it's inserted somewhere between two dollar signs), the re-render that formula.

  2. If it's a closing dollar sign ending an incomplete LaTeX formula, render that formula.

  3. Otherwise, don't re-render anything.

If the user deletes a character:

  1. If it's inside a formula, re-render that formula.

  2. If it's a dollar sign and removing it causes a formula to break, then de-render that formula.

  3. Otherwise, don't re-render or de-render anything.

  • 1
    $\begingroup$ This is fairly complicated to do reliably (and even then, there will still be flickering, since small changes in the forumla may cause all the remaining text to need a reflow). $\endgroup$
    – mrf
    Nov 10, 2015 at 10:43
  • $\begingroup$ This is not what you are asking for, but it might work as a temporary workaround - robjohn created bookmarklets to turn off/on the math rendering: meta.math.stackexchange.com/questions/8233/… math.ucla.edu/~robjohn/math/mathjax.html $\endgroup$ Nov 10, 2015 at 11:47
  • $\begingroup$ Davide Cervone wrote a userscript which had an effect very similar to this. It has since stopped working due to changes in the site. $\endgroup$ Nov 10, 2015 at 13:05
  • $\begingroup$ Such a feature would require major changes to how the editor works. it currently operates by replacing the current preview with the results of running Markdown on the content of the editor type-in area, and running MathJax on that. To do what you suggest would require that the preview not be replaced but updated incrementally, and that would require a much more complex editor. I doubt anyone at SE is interested in putting in the needed effort. $\endgroup$ Nov 10, 2015 at 23:18
  • $\begingroup$ Also, your suggestion doesn't take into account the possibility of cutting and pasting large chunks of text that includes multiple equations. It also doesn't handle labels and references, or user-defined macros, which (when the math that defines them changes) may require updates to other equations on the page. So while it is a good idea in principle, it is a more complex problem than it may at first appear. $\endgroup$ Nov 10, 2015 at 23:21


You must log in to answer this question.

Browse other questions tagged .