4.3 Packages

Packages in plasTeX are loaded in one of three ways: standard LaTeX package, Python package, and INI file. LaTeX packages are loaded in much the same way that LaTeX itself loads packages. The kpsewhich program is used to locate the requested file which can be either in the search path of your LaTeX distribution or in one of the directories specified in the TEXINPUTS environment variable. plasTeX read the file and expand the macros therein just as LaTeX would do.

Python packages are located using Python’s search path. This includes all directories listed in sys.path as well as those listed in the PYTHONPATH environment variable. After a package is loaded, it is checked to see if there is a function called ProcessOptions in its namespace. If there is, that function is called with two arguments: 1) the dictionary of options that were specified when loading the package, and 2) the document object that is currently being processed. This function allows you to make adjustments to the loaded macros based on the options specified, and define new commands in the document’s context (see section 4.2.3 for more information). Of course, you can also define Python based macros (section 4.2.1) in the Python package as well.

The last type of packages is based on the INI file format. This format is discussed in more detail in section 4.2.2. INI formatted packages are loaded in conjunction with a LaTeX or Python package. When a package is loaded, an INI file with the same basename is searched for in the same director as the package. If it exists, it is loaded as well. For example, if you had a package called ‘python.sty’ and a file called ‘python.ini’ in the same package directory, ‘python.sty’ would be loaded first, then ‘python.ini’ would be loaded. The same operation applies for Python based packages.