Search code examples
javascriptmathjax

MathJax: hide math expression while processing


Im developing an application that shows a mathematical expression in function of the content of a form.

The webpage show the different states of the expression while its rendering, and I would like to show only the last state.

I have already hidden the mathematical expression while its shown in Tex language while MathJax is rendering.

But there are still two states more:

  • Processing: The expression is in a bigger font.
  • Typesetted: The final version, in a smaller font.

Im trying to hide one of them through:

Stopping MathJax before typesetting

or

Hide the expression while processing it

Is it possible?

This is the code to create the mathematial expression.

JAVASCRIPT

window.UpdateMath = function () {

values = document.getElementsByClassName('level');
arrayvalues = toArray(values);

var formula = "$10 \log (";
for (i = 0; i < arrayvalues.length; i++) {
if (i == 0){
 formula = formula + " 10^{ &#92;frac{" + arrayvalues[i] + "}{10}} ";
}else{
 formula = formula + " + 10^{ &#92;frac{" + arrayvalues[i] + "}{10}} ";
}
}
formula = formula + ")$";

document.getElementById('MathOutput').style.visibility = "hidden";
document.getElementById("MathOutput").innerHTML = formula;

//reprocess the MathOutput Element
MathJax.Hub.Queue(["Typeset",MathJax.Hub,"MathOutput"]);
MathJax.Hub.Queue(
function () {
document.getElementById('MathOutput').style.visibility = "";
}
);
}
})();

Full code here: http://jsfiddle.net/AqDCA/888/


Solution

  • You want to turn off preprocessor previews and the fast previews. Try setting your configuration to this

      MathJax.Hub.Config({
        "fast-preview": {disabled:true},
        tex2jax: {
          preview: "none",
          inlineMath: [["$","$"],["\\(","\\)"]]
        }
      });
    

    This should make things work a bit more like what you want.