From 3fcac469f8edfc53d6e77bb8bd39ccf8cce2e3a1 Mon Sep 17 00:00:00 2001 From: "anburasan.saravanan@syncfusion.com" Date: Thu, 1 Feb 2024 12:04:22 +0530 Subject: [PATCH] Added apply math justification --- File-Formats/DocIO/Working-with-LaTeX.md | 58 +++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/File-Formats/DocIO/Working-with-LaTeX.md b/File-Formats/DocIO/Working-with-LaTeX.md index 4b60fefa3..a82c80f8a 100644 --- a/File-Formats/DocIO/Working-with-LaTeX.md +++ b/File-Formats/DocIO/Working-with-LaTeX.md @@ -1835,4 +1835,60 @@ document.Save("Result.docx", FormatType.Docx) {% endtabs %} -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/Mathematical-Equation/LaTeX-equations/Format%20Equation). \ No newline at end of file +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/Mathematical-Equation/LaTeX-equations/Format%20Equation). + +## Apply Math Justification + +Apply justification, such as Left, Right, and more to the equation in a Word document using the .NET Word Library. + +The following code examples show how to apply the justification to equations in a Word document. + +{% tabs %} + +{% highlight c# tabtitle="C# [Cross-platform]" %} +// Create a new Word document. +using (WordDocument document = new WordDocument()) +{ + //Add one section and one paragraph to the document. + document.EnsureMinimal(); + //Append an border box equation using LaTeX. + WMath math = document.LastParagraph.AppendMath(@"\boxed{{x}^{2}+{y}^{2}={z}^{2}}"); + //Apply math justification. + math.MathParagraph.Justification = MathJustification.Left; + using (FileStream outputFileStream = new FileStream("Output.docx", FileMode.Create, FileAccess.ReadWrite)) + { + //Save Word document. + document.Save(outputFileStream, FormatType.Docx); + } +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +//Create a new Word document. +WordDocument document = new WordDocument(); +//Add one section and one paragraph to the document. +document.EnsureMinimal(); +//Append an border box equation using LaTeX. +WMath math = document.LastParagraph.AppendMath(@"\boxed{{x}^{2}+{y}^{2}={z}^{2}}"); +//Apply math justification. +math.MathParagraph.Justification = MathJustification.Left; +//Save Word document. +document.Save("Output.docx", FormatType.Docx); +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +'Create a new Word document. +Dim document As New WordDocument() +'Add one section and one paragraph to the document. +document.EnsureMinimal() +'Append a border box equation using LaTeX. +Dim math As WMath = document.LastParagraph.AppendMath("\boxed{{x}^{2}+{y}^{2}={z}^{2}}") +'Apply math justification. +math.MathParagraph.Justification = MathJustification.Left +'Save Word document. +document.Save("Output.docx", FormatType.Docx) +{% endhighlight %} + +{% endtabs %} + +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/Mathematical-Equation/Apply-math-justification).