C# insert math equation and symbol to Word document

Starts from version 7.6.5, Spire.Doc supports to add Latex math code to Word document in C#. This article will show you how to add Latex Math Symbols and equation to word document.

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);

            //add equation to the second paragraph
            Paragraph paragraph2 = section.AddParagraph();
            OfficeMath officeMath1 = new OfficeMath(doc);
            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);
            officeMath2.FromLatexMathCode(" \\alpha,\\beta, \\gamma, \\Gamma, \\pi, \\Pi, \\phi, \\varphi, \\mu, \\Phi");

            //save the document to file       
            doc.SaveToFile("Equation.docx", FileFormat.Docx);

Effective screenshot after adding latex math code and symbols to the word document:

C# insert math equation and symbol to Word document