3.1.3 Fontification of mathematical constructs
In LaTeX mathematics can be indicated by a variety of different methods: toggles (like dollar signs), macros and environments. Math constructs known by font-latex are displayed with the face font-latex-math-face
. Support for dollar signs and shorthands like ‘\(...\)
’ or ‘\[...\]
’ is built-in and not customizable. Support for other math macros and environments can be adapted by customizing the variables font-latex-match-math-command-keywords
and texmathp-tex-commands
respectively. It is no longer recommended to customize font-latex-math-environments
.
To convert your customization in font-latex-math-environments
into texmathp-tex-commands
, please register your own math environments, together with starred variants if any, as entries of env-on
type in texmathp-tex-commands
, then clear out font-latex-math-environments
. You have to restart Emacs for this new customization to take effect for fontification.
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
.
user option
font-latex-fontify-script
If non-nil, fontify subscript and superscript strings. Concretely, this means that the scripts are raised or lowered.
Another possiblity is setting this variable to the symbol multi-level
. In this case, in a formula x^{y^z}, y is raised above and smaller than x, and z is raised above and smaller than y. With many script levels, the text might become too small to be readable. (See font-latex-fontify-script-max-level
below.)
Lastly, you can set this variable to invisible
whose behavior is like multi-level
, and in addition the super-/subscript characters ^ and _ are not displayed.
user option
font-latex-fontify-script-max-level
Maximum scriptification level for which script faces are applied.
The faces font-latex-superscript-face
and font-latex-subscript-face
define custom :height
values ﹤ 1.0. Therefore, scripts are displayed with a slightly smaller font than normal math text. If font-latex-fontify-script
is multi-level
or invisible
, the font size becomes too small to be readable after a few levels. This option allows to specify the maximum level after which the size of the script text won’t be shrunken anymore.
For example, in the expression x^{y^{z^a_b}}, x has scriptification level 0, y has level 1, z has level 2, and both a and b have scriptification level 3.
If font-latex-fontify-script-max-level
was 2, then z, a, and b would have the same font size. If it was 3 or more, then a and b were smaller than z just in the same way as z is smaller than y and y is smaller than x.
The script characters ‘^
’ and ‘_
’ themselves are also fontified with an own face named font-latex-script-char-face
.
user option
font-latex-script-display
Display specification for subscript and superscript content. The car is used for subscript, the cdr is used for superscript. The feature is implemented using so-called display properties. For information on what exactly to specify for the values, see (elisp)Other Display Specs section ‘Other Display Specifications’ in GNU Emacs Lisp Reference Manual.