auctex: Simple Style
5.6.1 A Simple Style File
-------------------------
Here is a simple example of a style file.
;;; book.el - Special code for book style.
(TeX-add-style-hook
"book"
(lambda ()
(LaTeX-largest-level-set "chapter"))
LaTeX-dialect)
The example is from the AUCTeX sources and is loaded for any LaTeX
document using the book document class (or style before LaTeX2e). The
file specifies that the largest kind of section in such a document is
chapter. 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:
* A symbol indicating a singleton containing one basic TeX
dialect, this symbol shall be selected among:
':latex'
For all files in LaTeX mode, or any mode derived thereof
':bibtex'
For all files in BibTeX mode, or any mode derived thereof
':texinfo'
For all files in Texinfo mode.
* A logical expression like:
'(or DIALECT-EXPRESSION1 ... DIALECT-EXPRESSION_N)'
For union of the sets of dialects corresponding to
DIALECT-EXPRESSION1 through DIALECT-EXPRESSION_N
'(and DIALECT-EXPRESSION1 ... DIALECT-EXPRESSION_N)'
For intersection of the sets of dialects corresponding to
DIALECT-EXPRESSION1 through DIALECT-EXPRESSION_N
'(nor DIALECT-EXPRESSION1 ... DIALECT-EXPRESSION_N)'
For complement of the union sets of dialects
corresponding to DIALECT-EXPRESSION1 through
DIALECT-EXPRESSION_N relatively to the set of all
supported dialects
'(not DIALECT-EXPR)'
For complement set of dialect corresponding to
DIALECT-EXPR relatively to the set of all supported
dialects
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 'LaTeX-dialect' currently defined to
':latex', rather than passing ':latex' directly.
-- Constant: LaTeX-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.