我有
的基本MathJax
代码
<script type="text/javascript">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js"],
jax: ["input/TeX", "output/SVG"],
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<div>$$a = b + c$$</div>
我希望公式应该替换为SVG
代码,但结果与HTML输出相同,MathML代码:
<div>
<span class="MathJax_Preview" style="color: inherit; display: none;"></span>
<span class="mjx-chtml MJXc-display" style="text-align: center;">
<span id="MathJax-Element-1-Frame" class="mjx-chtml MathJax_CHTML" tabindex="0" data-mathml="
<math
xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mi>a</mi>
<mo>=</mo>
<mi>b</mi>
<mo>+</mo>
<mi>c</mi>
</math>" role="presentation" style="font-size: 113%; text-align: center; position: relative;">
<span id="MJXc-Node-1" class="mjx-math" aria-hidden="true">
<span id="MJXc-Node-2" class="mjx-mrow">
<span id="MJXc-Node-3" class="mjx-mi">
<span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.224em; padding-bottom: 0.279em;">a</span>
</span>
<span id="MJXc-Node-4" class="mjx-mo MJXc-space3">
<span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.058em; padding-bottom: 0.335em;">=</span>
</span>
<span id="MJXc-Node-5" class="mjx-mi MJXc-space3">
<span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.445em; padding-bottom: 0.279em;">b</span>
</span>
<span id="MJXc-Node-6" class="mjx-mo MJXc-space2">
<span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.279em; padding-bottom: 0.445em;">+</span>
</span>
<span id="MJXc-Node-7" class="mjx-mi MJXc-space2">
<span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.224em; padding-bottom: 0.279em;">c</span>
</span>
</span>
</span>
<span class="MJX_Assistive_MathML MJX_Assistive_MathML_Block" role="presentation">
<math
xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mi>a</mi>
<mo>=</mo>
<mi>b</mi>
<mo>+</mo>
<mi>c</mi>
</math>
</span>
</span>
</span>
<script type="math/tex; mode=display" id="MathJax-Element-1">a = b + c</script>
</div>
如何将输出作为SVG矢量元素?
答案 0 :(得分:3)
MathJax配置脚本的类型应为text/x-mathjax-config
而不是text/javascript
。此外,?config=TeX-MML-AM_CHTML
似乎以某种方式凌驾于output/SVG
。我用了?config=default
。您可以获得有关配置文件here
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js"],
jax: ["input/TeX", "output/SVG"],
})
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=default"></script>
<div>$$a = b + c$$</div>
&#13;
答案 1 :(得分:0)
如果有人仍在使用MathJax 2.7.x,则修改config参数将在初始加载时渲染svg。
因此将TeX-AMS_CHTML
更改为TeX-AMS_SVG
或将TeX-MML-AM_CHTML
更改为TeX-MML-AM_SVG
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS_SVG"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_SVG"></script>