[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.1 A Simple Style File

Here is a simple example of a style file.

;;; book.el - Special code for book style.

 (lambda () 
   (LaTeX-largest-level-set "part"))

The example is from the AUCTeX sources and is loaded for any LaTeX document using the book document class (or style before LaTeX2e). (Note that the above code is much simplified for explanatory purpose.) The file specifies that the largest kind of section in such a document is ‘part’. The interesting thing to notice is that the style file defines an (anonymous) function, and adds it to the list of loaded style hooks by calling TeX-add-style-hook.

The first time the user indirectly tries to access some style-specific information, such as the largest sectioning command available, the style hooks for all files directly or indirectly read by the current document are executed. The actual files will only be evaluated once, but the hooks will be called for each buffer using the style file.

Note that the basename of the style file and the name of the style hook should usually be identical.

Function: TeX-add-style-hook style hook &optional dialect-expr

Add hook to the list of functions to run when we use the TeX file style and the current dialect is one in the set derived from dialect-expr. When dialect-expr is omitted, then hook is allowed to be run whatever the current dialect is.

dialect-expr may be one of:

In case of adding a style hook for LaTeX, when calling function TeX-add-style-hook it is thought more futureproof for argument dialect-expr to pass constant TeX-dialect currently defined to :latex, rather than passing :latex directly.

Constant: TeX-dialect

Default dialect for use with function TeX-add-style-hook for argument dialect-expr when the hook is to be run only on LaTeX file, or any mode derived thereof.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on January 17, 2024 using texi2html 1.82.