LaTeX is a powerful software for typeset math. Rendering LaTeX formulas to SVG images is a popular way to display equations on the web. We can write basic equations and mathematical formulas programmatically without using LaTeX and save as SVG image format. In this article, we will show you **how to render LaTeX formulas to SVG in C#**.

The following topics shall be covered in this article:

- C# API to Render LaTeX Formula to SVG
- Steps to Render LaTeX Formula to SVG
- Render LaTeX Formula to SVG

## C# API to Render LaTeX Formula to SVG

For rendering LaTeX formulas to SVG format, we will be using the Aspose.TeX for .NET API. It allows typesetting TeX files to different file formats like PDF, XPS, or images.

The MathRendererOptions class of the API enables to specify common Math formula rendering options. The SvgMathRenderer class provides the Render(string, Stream, MathRendererOptions, out SizeF) method for implementing the rendering of math formula to SVG.

Please either download the DLL of the API or install it using NuGet.

```
PM> Install-Package Aspose.TeX
```

## How to Render LaTeX Formula to SVG in C#

We can render inline math formulas or complex equations to SVG format by following the steps given below:

- Initialize and Specify the SVG math renderer options.
- Specify the LaTeX document preamble.
- Initialize SVG math renderer.
- Render formula to SVG using the Renderer method.

The following section describes how to transform these steps into C# and render LaTeX formula to SVG.

## Render LaTeX Formula to SVG using C#

Please follow the steps given below for rendering of math formulas to SVG format.

- Firstly, create an instance of the
**MathRendererOptions**class - Next, specify the LaTeX document preamble.
- Optionally, set various properties such as
*Scale, TextColor, BackgroundColor*, etc. - Next, create the output stream for the formula image.
- After that, create an instance of the
**SvgMathRenderer**class. - Finally, call the
**Render()**method to render the formula. It takes formula string, stream, MathRendererOptions, and the output image size as arguments.

The following code sample demonstrates **how to render a math formula to SVG in C#**.

## Get a Free License

You can get a free temporary license to try the library without evaluation limitations.

## Conclusion

In this article, we have learned how to render mathematical formulas and equations to SVG in C#. Besides, you can learn more about *Aspose.TeX for .NET* API using documentation. In case of any ambiguity, please feel free to contact us on our free support forum.