如何将堆栈设置为mathjax?

编程入门 行业动态 更新时间:2024-10-09 18:17:57
本文介绍了如何将堆栈设置为mathjax?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想将堆栈的表达式设置为mathjax(动态地)

i want set expresion of stack to mathjax (dynamically)

这是我的堆栈

var showStack=[]; showStack.push({ Key: 'topic', Value:"سرمایه" }); showStack.push({ Key: 'operator', Value: "+" }); showStack.push({ Key: 'topic', Value: "مالیات" }); showStack.push({ Key: 'opeator', Value: "/" }); showStack.push({ Key: 'number', Value: "8569" }); showStack.push({ Key: 'opeator', Value: "-" }); showStack.push({ Key: 'topic', Value: "اندوخته قانونی - سال قبل" });

这段代码从我的堆栈创建了我的公式

and this code create my fomula from my stack

jQuery.each( showStack, function( i, val ) { if(val.Key=='topic'){ text+='`\\text{'+ val.Value+'}`'; } else text+=val.Value; });

createFormula用于创建mathjax公式

createFormula for create mathjax formula

function createFormula() { var text=""; MathJax.Hub.Config({ "HTML-CSS": { mtextFontInherit: true } }); document.querySelector('#formula').textContent =text; MathJax.Hub.Queue(["Typeset",MathJax.Hub,'formula']); }

但结果是

سرمایه+مالیات/8569-اندوخته قانونی - سال قبل

我的代码不起作用,我的问题在哪里? 谢谢

my code not work,Where is my problem? thanks

推荐答案

您只需更改此代码

var text=""; jQuery.each( showStack, function( i, val ) { if(val.Key=='topic'){ text+='\\text{'+ val.Value+'}'; // remove ` } else text+=val.Value; });

并添加此代码

var value='`'+text+'`'; document.querySelector('#formula').textContent =value; MathJax.Hub.Queue(["Typeset",MathJax.Hub,'formula']);

更多推荐

如何将堆栈设置为mathjax?

本文发布于:2023-11-25 21:44:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631460.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:堆栈   设置为   如何将   mathjax

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!