世俱杯 2025

logo E-iceblue中文文档
文档世俱杯 2025>>E-iceblue中文文档>>将数学方程式和符号插入 Word 文档

将数学方程式和符号插入 Word 文档


从 7.6.5 版本开始,Spire.Doc 支持将 Latex 数学代码添加到 C# 中的 Word 文档中。本文将向您展示如何将 Latex 数学符号和方程式添加到 Word 文档中。

Spire.Doc for.NET 最新下载

展示代码:

using Spire.Doc;
using Spire.Doc.Documents;
using System;
namespace InsertMath;

class Program
{

static void Main(string[] args)
{
//create a word document
Document doc = new Document();

//add a section
Section section = doc.AddSection();

//add a paragraph to the section
Paragraph paragraph = section.AddParagraph();

//add a LatexMathcode to the first paragraph
OfficeMath officeMath = new OfficeMath(doc);
paragraph.Items.Add(officeMath);
officeMath.FromLatexMathCode("x^{2}+\\sqrt{x^{2}+1}=2");

//add equation to the second paragraph
Paragraph paragraph2 = section.AddParagraph();
OfficeMath officeMath1 = new OfficeMath(doc);
paragraph2.Items.Add(officeMath1);
officeMath1.FromLatexMathCode("\\forall x \\in X, \\quad \\exists y \\leq \\epsilon");

//add symbols to the third paragraph
Paragraph paragraph3 = section.AddParagraph();
OfficeMath officeMath2 = new OfficeMath(doc);
paragraph3.Items.Add(officeMath2);
officeMath2.FromLatexMathCode(" \\alpha,\\beta, \\gamma, \\Gamma, \\pi, \\Pi, \\phi, \\varphi, \\mu, \\Phi");

//save the document to file
doc.SaveToFile("Equation.docx", FileFormat.Docx);
System.Diagnostics.Process.Start("Equation.docx");
}
}
}

将latex数学代码和符号添加到word文档后的有效截图:

Add checkbox and picture content control to word document in C#


欢迎下载|体验更多E-iceblue产品

如需获取更多产品相关信息请咨询  


扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP