Create custom TeX input

C++ API Solution to customize TeX input

 

TeX is known as a machine typesetting system capable of processing programs written in the TeX language. Instead of formatting your text directly in the document, users write programs that include text fragments of the document along with commands controlling the output. As outlined in the TeX I/O documentation article, a TeX job is typically executed on an explicitly specified TeX file. Therefore, this file must be included in the input for a particular TeX job.

Within the Aspose.TeX API, there are built-in TeX input implementations for loading data from files within the local file system and from files packaged in a ZIP archive.

This page guides on implementing custom TeX input, taking into account that TeX files should adhere TeX syntax and, ideally, contain only commands “known” to the engine. Additionally, other files, such as data files or graphics files, may be included.

To customize TeX input, we need:

  • The Aspose.TeX for C++ API, - a feature-rich, powerful, and easy-to-use document processing and conversion API for the C++ platform.
  • Open the NuGet package manager, search for Aspose.TeX.Cpp and install it. You may also use the following command from the Package Manager Console:

Package Manager Console Command

PM> Install-Package Aspose.TeX.Cpp

Hints on how to customize TeX input C++:

  1. The TeX engine refers to data volumes as files, which means ‘by name’. As a consequence, the part of the TeX input subsystem responsible for feeding automatically processed data provides data volumes in response to queries by name.
  2. The Aspose.TeX API for C++ introduces the IInputWorkingDirectory interface, declaring a single method GetFile() which retrieves ‘files’ by name. In other words, an Input Working Directory functions as a dictionary that associates file names with data volumes.
  3. Along with the ‘file’, the GetFile() method returns the ‘full name’ within an instance of the composite NamedStream object. For example, in the InputFileSystemDirectory implementation, the ‘full name’ will be the full path to the requested file on disk - the path that will be written to the transcript (.log) file.



FAQ

1. How do I read input from TeX and LaTeX?

In primitive TeX there are four commands responsible for input from files other than the main input file like \\input <file name>, \\openin<number>=<file name>, \\closein<number> and \\read<number> to <control sequence>. The first command makes the engine process the file whose name is specified as a parameter. The next two open and close auxiliary data files. And the last one reads a line from an auxiliary file as a list of tokens and assigns this list to a control sequence (or command). In LaTeX, input is easier. Additional files for immediate processing are most often so-called packages, which must be included in a LaTeX file’s preamble using the \\usepackage{<package name>} command when needed. Auxiliary data input is also most often wrapped in macros provided by specific packages.

2. How to work with TeX input?

To provide TeX input in the most common ways (from files on disk or files packed in a ZIP archive) using the Aspose.TeX API Solution, use classes that implement the IInputWorkingDirectory interface.

3. How to customize TeX input?

To customize TeX input using this API Solution, you need to develop your own implementation of the IInputWorkingDirectory interface and then use it as the value of the InputWorkingDirectory property in TeX job options.

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.