Typeset TeX/LaTeX files

Typeset TeX/LaTeX files C# .NET


TeX is known as one of the data markup languages and a typesetting language at the same time. This means that you do not format your text in the document, but enter plain text containing the text fragments of the document along with commands that control the output. TeX is the central core of the publication set system (computer typesetting).

To gain deeper a understanding of TeX typesetting, learn the What Is TeX? and What Is LaTeX? sections of the Documentation. And on this page, you will find a code snippet explaining how to typeset a TeX/LaTeX file.

To run the examples we need:

  • The Aspose.TeX for .NET API which is a feature-rich, powerful, and easy-to-use document manipulation and conversion API for C# platform.

  • Open the NuGet package manager, search for Aspose.TeX, and install it. You may also use the following command from the Package Manager Console:

Package Manager Console Command

PM> Install-Package Aspose.TeX

Steps to typeset TeX using C#.

  1. Create conversion options for Object TeX/Object LaTeX upon the Object TeX engine extension using the ConsoleAppOptions() method of the TeXOptions class. Use the ObjectTeX() configuration if the TeX file you want to typeset is in Plain TeX format, or even contains only TeX primitives besides text data. If your TeX file is in LaTeX format, ObjectLaTeX configuration must be used instead.
  2. Specify a file system working directory for the output using the OutputFileSystemDirectory class.
  3. Create an instance of the TeXJob class with a newly created XpsDevice object and run the job by calling the Run() method.

C# code example: Typesetting a TeX/LaTeX file

using Aspose.TeX.IO;
using Aspose.TeX.Presentation.Xps;
// Create conversion options for the Object TeX/Object LaTeX format upon the Object TeX engine extension.
TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX()); // TeXConfig.ObjectLaTeX
// Specify a file system working directory for the output.
options.OutputWorkingDirectory = new OutputFileSystemDirectory(RunExamples.OutputDirectory);
// Run the job.
TeXJob job = new TeXJob("hello-world", new XpsDevice(), options);


1. What is typesetting in LaTeX?

LaTeX supports various typesetting features useful for a document author called packages. In these packages you can find advanced tools for math formulas, drawing graphics, creating tables and templates, etc.

2. Is LaTeX a typesetting software?

Yes, LaTeX is a typesetting software that is widely used for creating various types of elaborated documents like, science works, research papers, articles, term papers, books, and many more.

3. How to typeset TeX files?

To typeset TeX files using the Aspose.TeX API Solution, you need to create conversion options for the Object TeX or Object LaTeX format based on the Object TeX engine extension. Then specify a file system working directory for the output. Finally, create an instance of the TeXJob class and run the typesetting process using the TeXJob.Run() method.

LaTeX What is LaTeX File Format

LaTeX is a TeX format if said briefly. LaTeX files are plain text files written in their own markup language. They may require the inclusion of other data like images and/or other LaTeX files. LaTeX provides you with plenty of advanced features to create tables, include graphics, write math equations and formulas, etc. All these features are available in so-called packages.