[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Font locking is supposed to improve readability of the source code by highlighting certain keywords with different colors or fonts. It thereby lets you recognize the function of markup code to a certain extent without having to read the markup command. For general information on controlling font locking with Emacs' font lock mode, see section `Font Lock Mode' in GNU Emacs Manual.
TeX-install-font-lock
.
Besides font-latex AUCTeX ships with a scheme which is derived
from Emacs' default LaTeX mode and activated by choosing
tex-font-setup
. Be aware that this scheme is not coupled with
AUCTeX's style system and not the focus of development. Therefore
and due to font-latex being much more feature-rich the following
explanations will only cover font-latex.
In case you want to hook in your own fontification scheme, you can
choose other
and insert the name of the function which sets up
your font locking patterns. If you want to disable fontification in
AUCTeX completely, choose ignore
.
font-latex provides many options for customization which are accessible with M-x customize-group RET font-latex RET. For this description the various options are explained in conceptional groups.
Highlighting of macros can be customized by adapting keyword lists which
can be found in the customization group font-latex-keywords
. The
lists contain names of macros without the leading backslash.
Three types of macros can be handled differently with respect to fontification:
font-lock-keyword-face
will be used and for the optional
arguments the face font-lock-variable-name-face
. The face
applied to the mandatory argument depends on the macro class represented
by the respective built-in variables.
font-lock-keyword-face
and the text will get
the face configured for the respective macro class. If no TeX group
is present, the latter face will be applied to the macro itself.
font-latex provides keyword lists for different macro classes which are described in the following table:
font-latex-match-function-keywords
font-lock-function-name-face
font-latex-match-reference-keywords
font-lock-reference-face
font-latex-match-textual-keywords
font-lock-type-face
font-latex-match-variable-keywords
font-lock-variable-name-face
font-latex-match-warning-keywords
font-latex-warning-face
Sectioning commands are macros like `\chapter' or `\section'.
For these commands there are two fontification schemes which may be
selected by customizing the variable font-latex-title-fontify
.
font-lock-type-face
will be used to fontify the argument of
the command.
font-latex-match-title-1-keywords
font-latex-title-1-face
font-latex-match-title-2-keywords
font-latex-title-2-face
font-latex-match-title-3-keywords
font-latex-title-3-face
font-latex-match-title-4-keywords
font-latex-title-4-face
LaTeX provides various macros for changing fonts or font attributes. For example, you can select an italic font with `\textit{...}' or bold with `\textbf{...}'. An alternative way to specify these fonts is to use special macros in TeX groups, like `{\itshape ...}' for italics and `{\bfseries ...}' for bold. As mentioned above, we call the former variants commands and the latter declarations.
Besides the macros for changing fonts provided by LaTeX there is an infinite number of other macros--either defined by yourself for logical markup or defined by macro packages--which affect the font in the typeset text. While LaTeX's built-in macros and macros of packages known by AUCTeX are already handled by font-latex, different keyword lists per type style and macro type are provided for entering your own macros which are listed in the table below.
font-latex-match-bold-command-keywords
font-latex-bold-face
font-latex-match-italic-command-keywords
font-latex-italic-face
font-latex-match-math-command-keywords
font-latex-math-face
font-latex-match-type-command-keywords
font-lock-type-face
font-latex-match-bold-declaration-keywords
font-latex-bold-face
font-latex-match-italic-declaration-keywords
font-latex-italic-face
font-latex-match-type-declaration-keywords
font-latex-type-face
In case the customization options explained above do not suffice for
your needs, you can specify your own keyword classes by customizing the
variable font-latex-user-keyword-classes
.
When adding new entries, you have to use unique values for the class names, i.e. they must not clash with names of the built-in keyword classes or other names given by you. Additionally the names must not contain spaces.
The keywords are names of commands you want to match omitting the leading backslash.
The face argument can either be an existing face or font specifications made by you. (The latter option is not available on XEmacs.)
There are three alternatives for the type of keywords---"Command with arguments", "Declaration inside TeX group" and "Command without arguments"---which correspond with the macro types explained above.
Text in quotation marks is displayed with the face
font-latex-string-face
. Besides the various forms of opening and
closing double and single quotation marks so-called guillemets (<<, >>)
can be used for quoting. Because there are two styles of using
them--French style: << text >>; German style: >>text<<---you can
customize the variable font-latex-quotes
to tell font-latex
which type you are using.
In order to make math constructs more readable, font-latex displays
subscript and superscript parts in a smaller font and raised or lowered
respectively. This fontification feature can be controlled with the
variables font-latex-fontify-script
and
font-latex-script-display
.
Note that this feature is not available on XEmacs, for whicht it is disabled per default. In GNU Emacs raising and lowering is not enabled for versions 21.3 and before due to it working not properly.
Usually it is not desirable to have content to be typeset verbatim
highlighted according to LaTeX syntax. Therefore this content will
be fontified uniformly with the face font-latex-verbatim-face
.
font-latex differentiates three different types of verbatim constructs for fontification and consequently provides three keyword lists for customization.
font-latex-verb-like-commands
the macro's argument is enclosed in
a TeX group and not two arbitrary characters.
Font locking in LaTeX source code often involves constructs spanning
more than one line of text. For these constructs to be handled
correctly GNU Emacs as well as font-latex provide mechanisms for
multi-line fontification which can be controlled by the variable
font-latex-do-multi-line
.
Setting the variable to t will enable font-latex's mechanism, setting it to nil will disable it. Setting it to `try-font-lock' (the default) will use font-lock's mechanism if available and font-latex's method if not.
Setting this variable will only have effect after resetting buffers controlled by font-latex or restarting Emacs.
In case you want to change the colors and fonts used by font-latex please refer to the faces mentioned in the explanations above and use M-x customize-face RET <face> RET. All faces defined by font-latex are accessible through a customization group by typing M-x customize-group RET font-latex-highlighting-faces RET.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |