C# 在Word中添加Latex 数学公式和符号

C# 在Word中添加Latex 数学公式和符号,第1张

概述本篇内容介绍使用Spire.Doc for .NET在Word中添加Latex数学公式符号的方法。编辑代码前,将Spire.Doc.dll文件添加引用至VS程序。dll文件包可通过官网下载导入(如果

本篇内容介绍使用Spire.Doc for .NET在Word中添加Latex数学公式和符号的方法。编辑代码前,将Spire.Doc.dll文件添加引用至VS程序。dll文件包可通过官网下载导入(如果下载的是pack包,需要将Spire.Doc for .NET包解压安装到指定路径,dll文件可在安装路径下的Bin中找到;如果下载的是hotfix包,则无需安装,可直接在文件夹Bin下找到dll);或者通过Nuget搜索下载导入。

注意:@H_419_12@需要使用7.6.5@H_301_15@版本及以上的Spire.Doc for .NET,本文中下载使用的是hotfix 8.4.2版本

dll添加引用效果,如下图:

 

 

using Spire.Doc; Spire.Doc.documents; Spire.Doc.FIElds.OMath;namespace Create{    class Program    {        static voID Main(string[] args)        {            //新建word实例            document doc = new document();            添加一个section            Section section = doc.AddSection();            添加一个段落             Paragraph paragraph = section.AddParagraph();            在第一段添加公式            OfficeMath officeMath =  OfficeMath(doc);            paragraph.Items.Add(officeMath);            officeMath.FromLatexMathCode("x^{2}+\sqrt{x^{2}+1}=2");            添加第二个公式到第二段            Paragraph paragraph2 = section.AddParagraph();            OfficeMath officeMath1 =  OfficeMath(doc);            paragraph2.Items.Add(officeMath1);            officeMath1.FromLatexMathCode(\forall x \in X,\quad \exists y \leq \epsilon添加符号到第三段             Paragraph paragraph3 = section.AddParagraph();            OfficeMath officeMath2 =  OfficeMath(doc);            paragraph3.Items.Add(officeMath2);            officeMath2.FromLatexMathCode( \Alpha,\beta,\gamma,\Gamma,\pi,\Pi,\phi,\varphi,\mu,\Phi保存文档                   doc.Savetofile(result.docx,fileFormat.Docx);            System.Diagnostics.Process.Start();        }    }}

公式/符号添加效果:

 

(完)

 

总结

以上是内存溢出为你收集整理的C# 在Word中添加Latex 数学公式和符号全部内容,希望文章能够帮你解决C# 在Word中添加Latex 数学公式和符号所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/langs/1213400.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-04
下一篇 2022-06-04

发表评论

登录后才能评论

评论列表(0条)

保存