Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d48fca9

Browse files
authored
Merge pull request #22048 from anntzer/catcode
DOC: Document how to prevent TeX from treating `&`, `#` as special.
2 parents 49142c9 + 877e75d commit d48fca9

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tutorials/text/pgf.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
r"""
2-
*********************************
3-
Typesetting with XeLaTeX/LuaLaTeX
4-
*********************************
5-
6-
How to typeset text with the ``pgf`` backend in Matplotlib.
2+
*********************************************************
3+
Typesetting with XeLaTeX/LuaLaTeX via the ``pgf`` backend
4+
*********************************************************
75
86
Using the ``pgf`` backend, Matplotlib can export figures as pgf drawing
97
commands that can be processed with pdflatex, xelatex or lualatex. XeLaTeX and
@@ -53,7 +51,13 @@
5351
5452
Generally, these characters must be escaped correctly. For convenience,
5553
some characters (_, ^, %) are automatically escaped outside of math
56-
environments.
54+
environments. Other characters are not escaped as they are commonly needed
55+
in actual TeX expressions. However, one can configure TeX to treat them as
56+
"normal" characters (known as "catcode 12" to TeX) via a custom preamble,
57+
such as::
58+
59+
plt.rcParams["pgf.preamble"] = (
60+
r"\AtBeginDocument{\catcode`\&=12\catcode`\#=12}")
5761
5862
.. _pgf-rcfonts:
5963

0 commit comments

Comments
 (0)