Mathtext questions, continued...

"John Hunter" <jdh2358@...149...> writes:

Hi all -- John H here under a different email.... I'm on vacation so
I'll probably be out of touch for a week but just dashed into a
cyber-cafe and couldn't resist jumping in.

[It seems that you only sent the email to me, but it looks like it is
meant for the list, so I re-sent it.]

For those of us on the beach in Michican w/o read access to a TeX
interpreter, perhaps you could describe what is different or broken.

This works and produces "xyz" in a Roman font:

    In [8]:rcParams['text.usetex'] = True

    In [9]:text(0,0,r'\\rm xyz')
    Out[9]:<matplotlib.text.Text instance at 0x1729be90>

This fails with an exception:

    In [10]:rcParams['text.usetex'] = False

    In [11]:text(0,0,r'\\rm xyz')


    exceptions.ValueError Traceback (most recent call last)

    /Users/jks/<ipython console>
    --> 613 raise ValueError('unrecognized symbol "%s"' % sym)
        615 #print sym, basename, num

    ValueError: unrecognized symbol "\rm"

In TeX \rm and friends set the font in the current scope. Mathtext
seems to only recognize \rm with an argument in braces, e.g. \rm{xyz}.

The only "fresh rewrite" I'd be happy to consider is one that
translated Knuth's algorithm for parsing mathematical expressions
more or less verbatim.

That's a pretty tall order (as I'm sure you know). Just for fun, go to and search for the word