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 convert LaTeX to SVG in C#**.

The following topics shall be covered in this article:

## C# LaTex Library Installation

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
```

## Convert LaTex to SVG in C# - Code Sample

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.

Please follow the steps given below to convert LaTeX to SVG in C#.

- 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# using this C# LaTex library**.

## LaTex to SVG Online

You can use thgis LaTex online render application which is powered by Aspose.TeX for .NET. It is free and provides robust rendering features.

## 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 this C# LaTex library using documentation. In case of any ambiguity, please feel free to contact us on our free support forum.