Load TeX source files from disk

.NET API Solution to load TeX/LaTeX files from disk

 

TeX is known as a typesetting language. This means that you do not format your text in the document, but rather enter plain text containing the text fragments of the document along with commands that control the output. At the output, you will get the formatted file of the desired (specified) format. TeX is the central core of the publication set system (computer typesetting). A TeX job runs on an explicitly specified TeX file. To gain a deeper understanding of TeX input and output, learn the TeX I/O section of the Documentation.

As it is known, the main purpose of TeX is to help create mathematical or technical text writing. But before any manipulations, the file must first be loaded. Here you will find code snippets explaining how to load TeX source files from disk using the file system directory for input, direct the output to an XPS file, and write terminal output to console.

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 load TeX from disk C#.

  1. Create conversion options for the Object TeX format upon the Object TeX engine extension using ConsoleAppOptions() method of the TeXOptions class.
  2. Specify a file system working directory for the input. Use the InputFileSystemDirectory class.
  3. Specify a file system working directory for the output using the OutputFileSystemDirectory class.
  4. Specify the console as the output terminal using the OutputConsoleTerminal class.
  5. Specify a memory terminal as an output terminal if you need. To do so use the OutputMemoryTerminal class.
  6. 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: Loading TeX from disk

using Aspose.TeX.IO;
using Aspose.TeX.Presentation.Xps;
using System.IO;
// Create conversion options for the default Object TeX format upon the Object TeX engine extension.
TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());
// Specify a file system working directory for the input.
options.InputWorkingDirectory = new InputFileSystemDirectory(RunExamples.InputDirectory);
// Specify a file system working directory for the output.
options.OutputWorkingDirectory = new OutputFileSystemDirectory(RunExamples.OutputDirectory);
// Specify the console as the output terminal.
options.TerminalOut = new OutputConsoleTerminal(); // Default value. Arbitrary assignment.
// Specify a memory terminal as the output terminal, if you don't want the terminal output to be written to the console.
// options.TerminalOut = new OutputMemoryTerminal();
// Run the job.
TeXJob job = new TeXJob("hello-world", new XpsDevice(), options);
job.Run();

TeX What is TeX File Format

TeX is not actually a format. It is both a programming language and also an interpreter engine that understands this language. A TeX file is a plain text file created using TeX syntax to be converted to some target format by being processed by a TeX engine. This output document may include graphics, tables, lists, formulas, and equations.



FAQ

1. How can I read TeX files online?

To read TeX files online there is a free Viewer application. With it, you will need only to upload files and get the result on the screen in just a moment. You may also use the LaTeX Include Graphics application which lets you create a LaTeX file that includes graphics.

2. What classes are used to load TeX files from disk?

To provide the input of TeX files from disk, use the InputFileSystemDirectory class.

3. How do I load a TeX file from disk?

First, create conversion options using ConsoleAppOptions(). Then specify a file system working directory for the input and output. Define the saving options and, finally, run the job.