Typeset TeX/LaTeX files

Typeset TeX/LaTeX files Java


TeX is known as a programming language and at the same time a computer typesetting system that employs this language. Using TeX, you are not supposed to format your text in the document. You need to enter plain text containing the text fragments of the document, as well as commands that control the output. TeX is the central core of the publication set system (computer typesetting).

To understand the concept of TeX typesetting better, 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:

  • Use the Aspose.TeX for Java API, which is a feature-rich, powerful and easy-to-use document processing and conversion API for Java platform.
  • You can download its latest version directly from Aspose Maven Repository and install it within your Maven-based project by adding the following configurations to the pom.xml:





Steps to typeset TeX in Java.

  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.

Java code example: Typesetting a TeX/LaTeX file

import com.aspose.tex.TeXOptions;
import com.aspose.tex.TeXConfig;
import com.aspose.tex.OutputFileSystemDirectory;
import com.aspose.tex.TeXJob;
import com.aspose.tex.rendering.XpsDevice;
// 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.setOutputWorkingDirectory(new OutputFileSystemDirectory(Utils.getOutputDirectory()));

// 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.