# TeX in xlabel ? (Chris Barker)

Date: Mon, 25 Oct 2004 20:40:02 -0400
From: Gary <pajer@...97...>
To: Chris Barker <Chris.Barker@...259...>
CC: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] TeX in xlabel ?

Chris Barker wrote:

> Gary wrote:
>
>> AFAICT, It is not possible to mix text and TeX symbols in a string
>> and have it come out right. For example, in
>>
>> xlabel(r'$\rm{Normalized Temperature} (kT/\epsilon)$'
>> The text comes out in TeX math mode ... not so pretty. Please tell
>> me what I've overlooked.
>
>
> well, I'm not sure how this is supported in matplotlib, but in
> LaTex,you would do:
>
> Normalized Temperature $(kT/\epsilon)$
>
> or:
>
> $\text{Normalized Temperature} (kT/\epsilon)$
>
> the "$" means put it in math mode, if you don't want "Normalized > Temperature" in math mode, don't put it inside the $$. The second puts > it all in math mode, but the text{} means set this in text mode. > > -Chris > Matplotlib doesn't support \text, and it requires that the first and last characters of a TeX string be . I guess it only processes mathmode. Well, it can't do *everything*. It would be nice to figure out a workaround... Gary's example xlabel(r'\rm{Normalized Temperature} (kT/\epsilon)' USED to work, in earlier versions of Matplotlib. It no longer does. I have posted a similar issue a little while ago: http://sourceforge.net/mailarchive/message.php?msg_id=9681306 Unfortunately, I haven't really had the time to dig into the code to see what has changed, but when I do, I'll let you know what I find. The solution xlabel(r'\rm{Normalized \ Temperature} (kT/\epsilon)' somehow isn't entirely satisfactory. As far as I can see, \rm{} in Matplotlib should act just the way \mbox{} does in LaTeX, when you are already in math mode. And certainly, in LaTeX,$$ xy = 0 \mbox{ but however } x \neq y$\$
produces the expected output in the expected fonts and with the expected
spacing.

Dominique