Other managing TeX options | Python

Setting the interaction mode

As mentioned in TeX interaction parapraph, Aspose.TeX for Python provides the capability to set the initial interaction mode in which the engine starts. Here is an example of how it can be done:

1# Create conversion options instance.
2...
3# Set interaction mode.
4options.interaction = Interaction.NONSTOP_MODE

Setting the job name

When the main input file is provided as a file name, the resulting output files will have the same name but with different extensions. The TeX engine refers to the input file’s name as the job name and uses it for the output files. The exception is auxiliary files with explicitly specified file names. However, when the main input file is passed as a stream, the TeX engine uses the default job name, which is texput. In both scenarios, overriding the job name by assigning the appropriate conversion option is possible.

1# Create conversion options instance.
2...
3# Set the job name.
4options.job_name = "my-job-name"

“Stopping time”

To automatically generate a title from certain definitions in the preamble, LaTeX offers a feature that typically includes the current date. However, there might be instances where we want to fix the date to a specific value. Here is a method to achieve that:

1# Create conversion options instance.
2...
3# Force the TeX engine to output the specified date in the title.
4options.date_time = datetime(2022, 12, 18)

Ignoring missing packages

If we have a LaTeX file that includes references to packages that are not supported by the Aspose.TeX for Python library, the TeX engine will encounter an error and stop when attempting to load these packages. To prevent this, we can utilize the following option:

1# Create conversion options instance.
2...
3# Set to true to make the engine skip missing packages (when your file references one) without errors.
4options.ignore_missing_packages = True

How to avoid building ligatures

By default, the TeX engine constructs ligatures for specific character pairs if the font contains the necessary data. However, we can instruct the engine to bypass ligature construction using the following code:

1# Create conversion options instance.
2...
3# Set to true to make the engine not construct ligatures where normally it would.
4options.no_ligatures = True

Repeating the job

As mentioned in LaTeX input file paragraph, labels and references, there are situations where we may need to run the same job twice. Here is a method to accomplish that:

1# Create conversion options instance.
2...
3# Ask the engine to repeat the job.
4options.repeat = True

Turning math formulas into raster images

If there is a need to convert math formulas into raster images instead of rendering them with fonts, the following option can be used for this purpose:

1# Create conversion options instance.
2...
3# Create and assign saving options instance if needed.
4...
5# Set to true if you want math formulas to be converted to raster images.
6so.rasterize_formulas = True

Turning graphics into raster images

The ObjectTeX engine provides the capability to include graphic files in raster formats such as PNG and JPG, as well as PS (EPS) and XPS (OXPS) formats. The latter two formats typically contain vector elements and text. If we want to rasterize and include them as solid images, we can utilize the following option:

1# Create conversion options instance.
2...
3# Create and assign saving options instance if needed.
4...
5# Set to true if you want included graphics (if it contains vector elements) to be converted to raster images.
6so.rasterize_included_graphics = True

Subsetting fonts

If we desire to decrease the size of the output file, we can employ font subsetting, which entails that the fonts in the resulting document will not include data for those glyphs that are not present in the document. Here is a solution to achieve this:

1# Create conversion options instance.
2...
3# Create and assign saving options instance if needed.
4...
5# Set to true to make the device subset fonts used in the document.
6so.subset_fonts = True
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.