Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Nov 16, 2023 3:55 pm

I'd like to display the 'Not Greater Than', 'Not Greater Than Or Equal To', 'Not Less Than' and
Not Less Than Or Equal To' symbols using LaTex formatting and office math. When I use the latex text for these symbols (\ngtr, \ngeq, \nleq and \nless), the correct symbol is not included in the document. Can you confirm this is a bug or there is additional formatting I can include?

nataliegracegibbons
 
Posts: 13
Joined: Tue Oct 03, 2023 4:45 pm

Fri Nov 17, 2023 2:23 am

Hi,

Thank you for your inquiry.
I put the complete code below for your reference:
Code: Select all
            // Define an array of LaTeX math code strings
            string[] latexMathCode = {
              "{0}>={-1} \\not\\geq{10}",
              "{0}\\not<{-1}<={10}",
              "{0}<{11} \\not\\leq{10}",
             };

            // Create a new document object
            Document doc = new Document();

            // Add a section to the document
            Spire.Doc.Section section = doc.AddSection();

            // Create a paragraph and add text to it
            Spire.Doc.Documents.Paragraph textPara = section.AddParagraph();
            textPara.AppendText("Creating equations from LaTeX code");
            textPara.ApplyStyle(BuiltinStyle.Heading1);
            textPara.Format.HorizontalAlignment = HorizontalAlignment.Center;

            // Iterate through the LaTeX math code array
            for (int i = 0; i < latexMathCode.Length; i++)
            {
                // Create a new OfficeMath object
                OfficeMath officeMath = new OfficeMath(doc);

                // Convert the LaTeX math code to Office Math format
                officeMath.FromLatexMathCode(latexMathCode[i]);

                // Create a new paragraph and add the OfficeMath object to it
                Paragraph paragraph = section.AddParagraph();
                paragraph.Items.Add(officeMath);

                // Add a blank paragraph after each equation
                section.AddParagraph();
            }

            // Save the document to a file
            doc.SaveToFile(@"add.docx", FileFormat.Docx2013);

            // Dispose the document object to free resources
            doc.Dispose();

If you have any issue just feel free to contact us.

Sincerely,
Ula
E-iceblue support team
User avatar

Ula.wang
 
Posts: 282
Joined: Mon Aug 07, 2023 1:38 am

Return to Spire.Doc