Search code examples
javascriptmathjax

How to reset Mathjax span id


Is it possible to reset the MathJax-Span-Id?

I want to highlight different parts of formulas, but i load several latex formulas dynamically without reloading the page with MathJax.Hub.Queue(["Typeset",MathJax.Hub, "somename"]); . Because of that the ids keep incrementing and i can't determine which id i'd have to choose to highlight the correct part of the formula.

Normally the spans start with ids like #MathJax-Span-1 to #MathJax-Span-40, but after loading some formulas i get ids like #MathJax-Span-715.

Is there any way to set the id back to zero to properly select the correct divs?


Solution

  • You can use \cssId{name}{math} to set the id for the subexpression given by math to be name. That way it is constant, and you can refer to it directly. E.g.

    \cssId{term1}{x^2} + \cssId{term2}{3x} - \cssId{term3}{5}
    

    would let you refer to the x^2 via the css ID term1, the x via term2 and the constant via term3.