Latex not render when string call from javascript?

好久不见. 提交于 2019-12-11 04:16:20

问题


In my below code:

function test() {
	document.getElementById('demo').innerHTML="$$\left[ x=0 \right] $$";//same code from demo1.but not rendered

}
test();
<script type="text/javascript" src="http://latex.codecogs.com/latexit.js"></script>

<p lang="latex"id="demo"></p>
<p lang="latex"id="demo1">$$\left[ x=0 \right] $$</p>

Same code applied from javascript. Its not rendering.kindly tell Whats wrong with my code & correct my code or give any alter suggestion for that .

Thanks in advance


回答1:


Javascript consider [\r as Carriage Return] so you have to use \\right.

function test() {	document.getElementById('demo').innerHTML="$$\\left[ x=0 \\right] $$";
}
test();
<script type="text/javascript" src="http://latex.codecogs.com/latexit.js"></script>

<p lang="latex"id="demo"></p>
<p lang="latex"id="demo1">$$\left[ x=0 \right] $$</p>


来源:https://stackoverflow.com/questions/39696835/latex-not-render-when-string-call-from-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!