Next: , Previous: Help with LaTeX Command Syntax, Up: LaTeX Support


6.2.1.4 LaTeX Packages

Many LaTeX commands and features only become available when the appropriate package is included in the document using the ‘\usepackage’ command. Predictive LaTeX mode supports this by automatically trying to load package dictionaries and configuration functions when a ‘\usepackage’ command is typed, and unloading them again if it is modified or deleted.

When a ‘\usepackage{package}’ command is typed, predictive LaTeX mode looks for four dictionaries based on the package name: dict-latex-package, dict-latex-math-package, dict-latex-preamblepackage, and dict-latex-env-package. These correspond to the four categories of LaTeX dictionary (see LaTeX Support). If any of these dictionaries are found, they are added to the list of dictionaries for the corresponding category, and will be active in the appropriate regions of the document. If the text of the ‘\usepackage{package}’ command is modified or deleted, the dictionaries are removed again.

In addition, when a ‘\usepackage’ command is typed, modified or deleted, predictive LaTeX mode will try to load an Elisp file called predictive-latex-package.el[c]’, and run package-specific load or unload functions, as appropriate. The variable predictive-latex-usepackage-functions is used to determine which function (if any) to call when loading or unloading a LaTeX package (see below). This allows arbitrary configuration changes to be made when packages are included in or removed from the document. (A common use of this is to add or remove auto-overlay regexps, see LaTeX Automatic Overlays.)

predictive-latex-usepackage-functions
Alist associating LaTeX package names (strings) with a list containing two functions: a function to be called when loading the package with that name (i.e. when ‘\usepackage{package}’ is typed), and a function to be called when unloading the package (i.e. when the ‘\usepackage{package}’ is modified or deleted). Entries should be added to this variable by the corresponding Elisp file, predictive-latex-package.el[c]’.

The predictive completion package already comes with support for some LaTeX packages, though by no means all or even the most important1.


Footnotes

[1] Dictionaries and Elisp code welcome!