ParseFatalException on basic LaTeX expressions #659

eviatarbach opened this Issue Jan 6, 2012 · 6 comments


None yet

3 participants



matplotlib is returning ParseFatalException on basic LaTeX expressions. For example,

from pylab import *
import numpy as np

t = arange(-180.0, 180.0, 0.1)
s = t / 360.0 * np.pi

plot(t, s, '-', lw=2)



ParseFatalException: Expected end of math '$'

Matplotlib Developers member

What version are you using?
Your example fails for me also, but with a different exception, because mathtext doesn't know about "\floor".
I don't know that vanilla LaTeX does either, for that matter. I do find "\lfloor", and "\rfloor" in LaTeX, both of which work with mpl github master.
So it is not at all clear to me that what you are reporting is a bug.


Ah, sorry, that command doesn't actually exist in LaTeX. However, the same error occurs with \mbox, for example.

I'm using version 1.0.1-3.

Matplotlib Developers member

Right. I suspect the problem is that mathtext is not intended as a full implementation of LaTeX, but as a way of getting a large fraction of LaTeX formatting without requiring an actual LaTeX installation. @mdboom may want to comment further. If you have LaTeX installed, you can use rcParams['text.usetex']=True to use genuine LaTeX in place of mathtext. Then \mbox will work, presumably along with any other valid base LaTeX.


Oh, okay. But should't the error message be changed? It's misleading.

Matplotlib Developers member

Exactly--and evidently it was changed some time between 1.0.1 and the present git master. Running the latter, I get

Unknown symbol: \floor (at char 0), (line:1, col:1)
@efiring efiring closed this Jan 6, 2012
Matplotlib Developers member

The error messages were improved in 7f1d181. As you can see from that, it required a pretty major overhaul of how the parser works. This is not in 1.1.x, but will make it into the next major release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment