# mathtext \left and \right delimiters not working #715

Merged
merged 2 commits into from Feb 27, 2012

### 2 participants

Mathtext doesn't seem to understand all delimiters when using \left and \right. For example, I can do

import matplotlib.pyplot as plt
plt.plot([0,1,4,9])
plt.ylabel(r'$\left\{ \frac{a}{b} \right\}$')
plt.show()


The result is a big ugly traceback ending in

matplotlib.pyparsing.ParseFatalException: Expected a delimiter
$\left\{ \frac{a}{b} \right\}$ (at char 0), (line:1, col:1)


Using \left{ does work (but that's incorrect TeX), while \left[ doesn't work either. When I set

matplotlib.rcParams['text.usetex'] = True


Everything works as expected. But I'd prefer to be able to use mathtext.

I am using matplotlib version 1.1.0 with python 2.7.2 on Mac OS X 10.6.8. I tried this on a new user account with no matplotlibrc or pythonrc. My default backend is MacOSX, but I get the same thing with Agg.

 mdboom Fix a couple of problems with auto-sized delimiters:  \left{ should be \left\{ etc. If the delimiters have no content, they were getting shrinked down to nothing. 5add058
Matplotlib Developers member

Does the attached pull request resolve the issue for you?

Almost. It gets the curly braces working, but square brackets should not have a backslash in front of them. (With the backslashes, that's actually an old-fashioned TeX command that has no place in labels.) So if I take those backslashes out of your lines 2125 and 2127, it works. Thanks!

[Sorry if I should be doing something fancier here -- like adding my own diff. I'm not new to git, but I am new to github.]

Matplotlib Developers member

Oh, yes... just an oversight. Will fix and then merge.

 mdboom Fix auto-sized square brackets 49be6b5
merged commit bf81821 into matplotlib:master Feb 27, 2012
deleted the mdboom:mathtext-delimiters branch Mar 3, 2015
referenced this pull request Mar 30, 2015
Closed