2011-12-03 28 views
0

我在我的網站中使用MathJax 1.1。我需要在處理器遇到的每個數學前後放置一些html(在我的例子中是tex2jax)。如何在數學前後使用MathJax來渲染一些html

我該怎麼做?

  • 我應該註冊一個回調嗎?

  • 我應該在配置中使用一些選項嗎?

回答

1

此問題在MathJax user's forum上進行了討論。你可以嘗試像

<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> 

數學後增加\displastyle{之前和}。您應該在之前將此腳本加載到MathJax.js的腳本中。

0

如果你所有的元素都在一個父元素,你也許可以試試這個:

parent_element * { 
width: auto; 
} 

它爲我工作。