跳到主要内容

CreateMath

根据线性文本字符串创建数学公式。生成的对象可以像文本块一样插入到段落中(例如,通过 ApiParagraph#AddElement 或 ApiParagraph#Push)。

语法​

expression.CreateMath(text, format);

expression - 表示 Api 类的变量。

参数​

名称必需/可选数据类型默认值描述
text必需string以线性文本字符串形式编写的公式。
format可选"unicode" | "latex" | "mathml""unicode"指定线性表示的格式。

返回值​

ApiMath

示例​

在文档中构建数学公式对象,并像文本运行一样将其插入段落。

// Create the equation from a Unicode math expression string before attaching it to the paragraph.

// Produce a reusable equation object and place it into paragraph content in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let math = Api.CreateMath("x^2 + y^2 = z^2", "unicode");
paragraph.AddElement(math);