latex label using string variable

Hi,

My little problem is simple. I want to use a variable to define labels on a
graph. If I want to create a fraction, I have to use function \frac but when
I do that :
ylab="$RRR [\frac{R(300K)}{R(10K)}]$"
The value stored in ylab is :
'$RRR [\x0crac{R(300K)}{R(10K)}]$'

So how to put "\f" in a variable in python?

Hi,

I'd advise to use 'raw strings' like:
ylab = r'RRR \[\\frac\{R\(300K\)\}\{R\(10K\)\}\]'
If you then type 'ylab' in interative mode, you'll see:
'RRR \[\\\\frac\{R\(300K\)\}\{R\(10K\)\}\]'
Voila: Backslashes get escaped automatically.

Cheers
Christian

···

On Tuesday 04 April 2006 17:24, manouchk wrote:

Hi,

My little problem is simple. I want to use a variable to define labels on a
graph. If I want to create a fraction, I have to use function \frac but
when I do that :
ylab="RRR \[\\frac\{R\(300K\)\}\{R\(10K\)\}\]"
The value stored in ylab is :
'RRR \[\\x0crac\{R\(300K\)\}\{R\(10K\)\}\]'

So how to put "\f" in a variable in python?

Hi,

So how to put "\f" in a variable in python?

You either have to escape the \ :
     ylab="RRR \[\\\\frac\{R\(300K\)\}\{R\(10K\)\}\]"

or use raw strings:
     ylab=r"RRR \[\\frac\{R\(300K\)\}\{R\(10K\)\}\]"

Marin

···

--
Laboratory of Neurophysics and Physiology
UMR 8119 CNRS-Université René Descartes
45, rue des Saints-Pères
75270 Paris Cedex 06
France

Ok thank you, I didn't have already integrated the concept of raw string! But
now it is.

Emmanuel

···

Le Mardi 04 Avril 2006 12:27, Marin Manuel a écrit :

Hi,

>So how to put "\f" in a variable in python?

You either have to escape the \ :
     ylab="RRR \[\\\\frac\{R\(300K\)\}\{R\(10K\)\}\]"

or use raw strings:
     ylab=r"RRR \[\\frac\{R\(300K\)\}\{R\(10K\)\}\]"

Marin