33Writing mathematical expressions
44================================
55
6- You can use TeX markup in any matplotlib text string. Note that you
7- do not need to have TeX installed, since matplotlib ships its own TeX
8- expression parser, layout engine and fonts. The layout engine is a
9- fairly direct adaptation of the layout algorithms in Donald Knuth's
10- TeX, so the quality is quite good (matplotlib also provides a
11- ``usetex `` option for those who do want to call out to TeX to generate
12- their text (see :ref: `usetex-tutorial `).
13-
14- Any text element can use math text. You need to use raw strings
15- (preceed the quotes with an ``'r' ``), and surround the string text
16- with dollar signs, as in TeX. Regular text and mathtext can be
6+ You can use a subset TeX markup in any matplotlib text string by
7+ placing it inside a pair of dollar signs ($).
8+
9+ Note that you do not need to have TeX installed, since matplotlib
10+ ships its own TeX expression parser, layout engine and fonts. The
11+ layout engine is a fairly direct adaptation of the layout algorithms
12+ in Donald Knuth's TeX, so the quality is quite good (matplotlib also
13+ provides a ``usetex `` option for those who do want to call out to TeX
14+ to generate their text (see :ref: `usetex-tutorial `).
15+
16+ Any text element can use math text. You should use raw strings
17+ (preceed the quotes with an ``'r' ``), and surround the math text with
18+ dollar signs ($), as in TeX. Regular text and mathtext can be
1719interleaved within the same string. Mathtext can use the Computer
1820Modern fonts (from (La)TeX), `STIX <http://www.aip.org/stixfonts/ >`_
1921fonts (with are designed to blend well with Times) or a Unicode font
@@ -35,6 +37,26 @@ Whereas this::
3537
3638produces ":math: `\alpha > \beta `".
3739
40+ .. note ::
41+ Mathtext should be placed between a pair of dollar signs ($). To
42+ make it easy to display monetary values, e.g. "$100.00", if a
43+ single dollar sign is present in the entire string, it will be
44+ displayed verbatim as a dollar sign. This is a small change from
45+ regular TeX, where the dollar sign in non-math text would have to
46+ be escaped ('\$ ').
47+
48+ .. note ::
49+ While the syntax inside the pair of dollar signs ($) aims to be
50+ TeX-like, the text outside does not. In particular, characters
51+ such as::
52+
53+ # $ % & ~ _ ^ \ { } \( \) \[ \]
54+
55+ have special meaning outside of math mode in TeX. Therefore, these
56+ characters will behave differently depending on the rcParam
57+ ``text.usetex `` flag. See the :ref: `usetex tutorial
58+ <usetex-tutorial>` for more information.
59+
3860Subscripts and superscripts
3961---------------------------
4062
0 commit comments