Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
271 changes: 269 additions & 2 deletions File-Formats/DocIO/Working-with-LaTeX.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ The following code example illustrates how to create border box equation using L
{% tabs %}
{% highlight c# tabtitle="C# [Cross-platform]" %}

{% raw %}
// Create a new Word document.
using WordDocument document = new WordDocument();

Expand All @@ -326,10 +327,11 @@ document.LastParagraph.AppendMath(@"\boxed{{x}^{2}+{y}^{2}={z}^{2}}");
using MemoryStream stream = new MemoryStream();
document.Save(stream, FormatType.Docx);


{% endraw %}
{% endhighlight %}
{% highlight c# tabtitle="C# [Windows-specific]" %}

{% raw %}
// Create a new Word document.
using WordDocument document = new WordDocument();

Expand All @@ -342,9 +344,11 @@ document.LastParagraph.AppendMath(@"\boxed{{x}^{2}+{y}^{2}={z}^{2}}");
//Save the Word document.
document.Save("Result.docx", FormatType.Docx);

{% endraw %}
{% endhighlight %}
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}

{% raw %}
' Create a new Word document.
Dim document As WordDocument = New WordDocument()

Expand All @@ -357,6 +361,7 @@ document.LastParagraph.AppendMath(@"\boxed{{x}^{2}+{y}^{2}={z}^{2}}")
'Save the Word document.
document.Save("Result.docx", FormatType.Docx)

{% endraw %}
{% endhighlight %}
{% endtabs %}

Expand All @@ -375,7 +380,7 @@ The following table demonstrates the LaTeX equivalent to professional format bor
<tr>
<td>1.</td>
<td><img src="WorkingwithMathematicalEquation_images/BorderBox1.png" alt="Border Box equation"></td>
<td>\boxed{{x}^{2}+{y}^{2}={z}^{2}}</td>
<td>{% raw %}\boxed{{x}^{2}+{y}^{2}={z}^{2}}{% endraw %}</td>
</tr>
</table>

Expand Down Expand Up @@ -1569,3 +1574,265 @@ The following table demonstrates the LaTeX equivalent to professional format Rig
<td>{\mathbf{100}}_{\mathbf{40}}^{\mathbf{20}}</td>
</tr>
</table>

## Format Equations

### Apply style to characters

Apply styles to characters, such as bold and bold-italic, for equations in a Word document using LaTeX with the .NET Word Library. Apply the following styles using LaTeX commands.

<table>
<thead>
<tr>
<th>Styles</th>
<th>LaTeX</th>
</tr>
</thead>
<tr>
<td>
Bold<br/><br/></td>
<td>
\mathbf<br/><br/></td>
</tr>
<tr>
<td>
BoldItalic<br/><br/></td>
<td>
\mathbit<br/><br/></td>
</tr>
</table>

The following code example demonstrates how to apply styles to characters within 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 accent equation with bold using LaTeX.
document.LastParagraph.AppendMath(@"\dot{\mathbf{a}}");
//Append an accent equation with bold-italic using LaTeX.
document.LastSection.AddParagraph().AppendMath(@"\dot{\mathbit{a}}");

//Save a Word document to the MemoryStream.
using (MemoryStream stream = new MemoryStream())
{
document.Save(stream, FormatType.Docx);
}
}
{% endhighlight %}

{% highlight c# tabtitle="C# [Windows-specific]" %}
// Create a new Word document.
using (WordDocument document = new WordDocument())
{

//Add one section and one paragraph to the document.
document.EnsureMinimal();

//Append an accent equation with bold using LaTeX.
document.LastParagraph.AppendMath(@"\dot{\mathbf{a}}");
//Append an accent equation with bold-italic using LaTeX.
document.LastSection.AddParagraph().AppendMath(@"\dot{\mathbit{a}}");

//Save a Word document.
document.Save("Result.docx", FormatType.Docx);
}
{% endhighlight %}

{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
' Create a new Word document.
Dim document As WordDocument = New WordDocument()

'Add one section and one paragraph to the document.
document.EnsureMinimal()

'Append an accent equation with Bold using LaTeX.
document.LastParagraph.AppendMath(@"\dot{\mathbf{a}}")
'Append an accent equation with Bold-Italic using LaTeX.
document. LastSection.AddParagraph().AppendMath(@"\dot{\mathbit{a}}")

'Save the Word document.
document.Save("Result.docx", FormatType.Docx)
{% endhighlight %}

{% endtabs %}

### Apply scripts to the equation

Apply scripts, such as double-struck, fraktur, and more, to equations in a Word document using LaTeX with the .NET Word Library. Apply the following scripts using LaTeX commands.

<table>
<thead>
<tr>
<th>Scripts</th>
<th>LaTeX</th>
</tr>
</thead>
<tr>
<td>
Double-struck<br/><br/></td>
<td>
\mathbb<br/><br/></td>
</tr>
<tr>
<td>
Fraktur<br/><br/></td>
<td>
\mathfrak<br/><br/></td>
</tr>
<tr>
<td>
Sans Serif<br/><br/></td>
<td>
\mathsf<br/><br/></td>
</tr>
<tr>
<td>
Script<br/><br/></td>
<td>
\mathscr<br/>\mathcal<br/></td>
</tr>
</table>

The following code examples show how to apply the scripts 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 accent equation with Double-Struck font using LaTeX.
document.LastParagraph.AppendMath(@"\dot{\mathbb{a}}");
//Append an accent equation with Fraktur font using LaTeX.
document.LastSection.AddParagraph().AppendMath(@"\dot{\mathfrak{a}}");
//Append an accent equation with Sans Serif font using LaTeX.
document.LastSection.AddParagraph().AppendMath(@"\dot{\mathsf{a}}");
//Append an accent equation with Script using LaTeX.
document.LastSection.AddParagraph().AppendMath(@"\dot{\mathcal{a}}");
//Append an accent equation with Script using LaTeX.
document.LastSection.AddParagraph().AppendMath(@"\dot{\mathscr{a}}");

//Save a Word document to the MemoryStream.
using (MemoryStream stream = new MemoryStream())
{
document.Save(stream, FormatType.Docx);
}
}
{% endhighlight %}

{% highlight c# tabtitle="C# [Windows-specific]" %}
// Create a new Word document.
using (WordDocument document = new WordDocument())
{
//Add one section and one paragraph to the document.
document.EnsureMinimal();

//Append an accent equation with DoubleStruck font using LaTeX.
document.LastParagraph.AppendMath(@"\dot{\mathbb{a}}");
//Append an accent equation with Fraktur font using LaTeX.
document.LastSection.AddParagraph().AppendMath(@"\dot{\mathfrak{a}}");
//Append an accent equation with SansSerif font using LaTeX.
document.LastSection.AddParagraph().AppendMath(@"\dot{\mathsf{a}}");
//Append an accent equation with Script using LaTeX.
document.LastSection.AddParagraph().AppendMath(@"\dot{\mathcal{a}}");
//Append an accent equation with Script using LaTeX.
document.LastSection.AddParagraph().AppendMath(@"\dot{\mathscr{a}}");

//Save a Word document.
document.Save("Result.docx", FormatType.Docx);
}
{% endhighlight %}

{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
' Create a new Word document.
Dim document As WordDocument = New WordDocument()

'Add one section and one paragraph to the document.
document.EnsureMinimal()

'Append an accent equation with DoubleStruck font using LaTeX.
document.LastParagraph.AppendMath(@"\dot{\mathbb{a}}")
'Append an accent equation with Fraktur font using LaTeX.
document.LastSection.AddParagraph().AppendMath(@"\dot{\mathfrak{a}}")
'Append an accent equation with SansSerif font using LaTeX.
document. LastSection.AddParagraph().AppendMath(@"\dot{\mathsf{a}}")
'Append an accent equation with Script using LaTeX.
document. LastSection.AddParagraph().AppendMath(@"\dot{\mathcal{a}}")
'Append an accent equation with Script using LaTeX.
document. LastSection.AddParagraph().AppendMath(@"\dot{\mathscr{a}}")

'Save a Word document.
document.Save("Result.docx", FormatType.Docx)
{% endhighlight %}

{% endtabs %}

![Apply scripts to the equation](WorkingwithMathematicalEquation_images/scripts.png)

### Preserve as normal text

By default, characters in equations in a Word document are in italics. However, you can also include normal text within an equation using LaTeX.

The following code example shows how to preserve text as normal text, without any default formatting, within an equation using LaTeX.

{% 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 accent equation as normal text using LaTeX.
document.LastParagraph.AppendMath(@"\dot{\mathrm{a}}");

//Save a Word document to the MemoryStream.
using (MemoryStream stream = new MemoryStream())
{
document.Save(stream, FormatType.Docx);
}
}
{% endhighlight %}

{% highlight c# tabtitle="C# [Windows-specific]" %}
// Create a new Word document.
using (WordDocument document = new WordDocument())
{
//Add one section and one paragraph to the document.
document.EnsureMinimal();

//Append an accent equation as normal text using LaTeX.
document.LastParagraph.AppendMath(@"\dot{\mathrm{a}}");

//Save a Word document.
document.Save("Result.docx", FormatType.Docx);
}
{% endhighlight %}

{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
' Create a new Word document.
Dim document As WordDocument = New WordDocument()

'Add one section and one paragraph to the document.
document.EnsureMinimal()

'Append an accent equation as normal text using LaTeX.
document.LastParagraph.AppendMath(@"\dot{\mathrm{a}}")

'Save a Word document.
document.Save("Result.docx", FormatType.Docx)
{% endhighlight %}

{% endtabs %}

You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main/Mathematical-Equation/LaTeX-equations/Format%20Equation).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions File-Formats/Release-Notes/v24.1.47.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ documentation: ug

{% include release-info.html date="January 23, 2024" version="v24.1.47" %}

<style>
#license {
font-size: .88em!important;
margin-top: 1.5em;
margin-bottom: 1.5em;
background-color: #def8ff;
padding: 10px 17px 14px;
}
</style>

<div id="license">
With the 2024 Volume 1 release, we will discontinue support for .NET Framework 4.5, 4.5.1, and 4.6 in WinForms, WPF, and the File-Format Frameworks. Instead, we will provide support for .NET 4.6.2.
</div>

## DocIO

Expand Down