5.6.4 Adding or Examining Other Information

5.6.4.1 Adding bibliographies in style hooks

You can also specify bibliographical databases and labels in the style file. This is probably of little use, since this information will usually be automatically generated from the TeX file anyway.

Function: LaTeX-add-bibliographies bibliography

Add each bibliography to list of loaded bibliographies.

Function: LaTeX-add-labels label

Add each label to the list of known labels.

5.6.4.2 Examining Package/Class Options

In LaTeX documents, style hooks can find the package names and those options given as optional argument(s) of ‘\usepackage’ in LaTeX-provided-package-options.

Variable: LaTeX-provided-package-options

Buffer local variable holding alist of options provided to LaTeX packages. Each element is a cons cell (package . option-list). For example, its value will be

  (("babel" . ("german"))
   ("geometry" . ("a4paper" "top=2cm" "left=2.5cm" "right=2.5cm"))
   ...)

You can examine whether there is a specific package-option pair by LaTeX-provided-package-options-member.

Function: LaTeX-provided-package-options-member package option

Return non-nil if option has been given to package. The value is actually the tail of the list of options given to package.

There are similar facilities for class names and those options given in \documentclass declaration.

Variable: LaTeX-provided-class-options

Buffer local variable holding alist of options provided to LaTeX classes. Each element is a cons cell (class . option-list). For example, its value will be

  (("book" . ("a4paper" "11pt" "openany" "fleqn"))
   ...)
Function: LaTeX-provided-class-options-member class option

Return non-nil if option has been given to class. The value is actually the tail of the list of options given to class.

Function: LaTeX-match-class-option regexp

Check if a documentclass option matching regexp is active. Return first found class option matching regexp, or nil if not found.

These functions are also useful to implement customized predicate(s) in TeX-view-predicate-list. See Starting Viewers.

5.6.4.3 Adding Support for Option Completion

When the user inserts ‘\usepackage’ by C-c C-m, AUCTeX asks for the optional arguments after the package name is given. The style file of that package can provide completion support for the optional arguments.

Variable: LaTeX-packagename-package-options

List of optional arguments available for the package.

Here is an excerption from ‘acronym.el’:

(defvar LaTeX-acronym-package-options
  '("footnote" "nohyperlinks" "printonlyused" "withpage"
    "smaller" "dua" "nolist")
  "Package options for the acronym package.")

When the package accepts key-value style optional arguments, more sophisticated completion support is needed. The package style file can provide dynamic completion support by custom elisp function.

Function: LaTeX-packagename-package-options

This function should ask the user for optional arguments and return them as a string, instead of built-in option query facility. When this function is defined, AUCTeX calls it with no argument.

Here is an excerption from ‘acro.el’:

(defun LaTeX-acro-package-options ()
  "Prompt for package options for the acro package."
  (TeX-read-key-val t LaTeX-acro-package-options-list))

As you can see in the above example, a utility function TeX-read-key-val is available to read key-value pair(s) from users.

Note that defvar or defun of LaTeX-packagename-package-options should be at the top level of the style file and not inside the style hook, because the style hook is not yet called when the user inputs the optional arguments in response to C-c C-m.

There are similar facilities for class options. When the user inserts ‘\documentclass’ by C-c C-e, the respective class style file can provide completion support for the optional arguments.

Variable: LaTeX-classname-class-options

List of optional arguments available for the class.

Function: LaTeX-classname-class-options

Which see.