Question

I am using MathJax 1.1 in my web site. I need to place some html before and after every math encountered by the processor (tex2jax in my case).

How can I do this?

  • Should I register a callback?

  • Should I use some options in configuration?

Was it helpful?

Solution

This issue was discussed on the MathJax user's forum. You could try something like

<script type="text/x-mathjax-config">
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
  var TEX = MathJax.InputJax.TeX;
  var PREFILTER = TEX.prefilterMath;
  TEX.Augment({
    prefilterMath: function (math,displaymode,script) {
      math = "\\displaystyle{"+math+"}";
      return PREFILTER.call(TEX,math,displaymode,script);
    }
  });
});
</script>

to add \displastyle{ before and } after the mathematics. You should put this script before the script that loads MathJax.js.

OTHER TIPS

If all your elements are in one parent element, you maybe could try this:

parent_element * {
width: auto;
}

It worked for me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top