Skip to content

mathtext \left and \right delimiters not working #715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 27, 2012

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Feb 24, 2012

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.

  \left{ should be \left\{ etc.

  If the delimiters have no content, they were getting shrinked down to nothing.
@mdboom
Copy link
Member

mdboom commented Feb 24, 2012

Does the attached pull request resolve the issue for you?

@moble
Copy link
Author

moble commented Feb 25, 2012

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.]

@mdboom
Copy link
Member

mdboom commented Feb 27, 2012

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

mdboom added a commit that referenced this pull request Feb 27, 2012
mathtext \left and \right delimiters not working
@mdboom mdboom merged commit bf81821 into matplotlib:master Feb 27, 2012
@mdboom mdboom deleted the mathtext-delimiters branch March 3, 2015 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants