wander95
wander95

Reputation: 1366

Writing Latex in Ipython output

Consider the following lines in a IPython notebook:

 B=1.0e5   # in Gauss
 fce = 1.80e6 * B
 print "Electron gyrofrequency $f_{ce}$= %0.5e " %(fce)

I cannot get $f_{ce}$ to print in its latex form. I also tried:

     from IPython.display import display, Math, Latex 
     display ("Electron gyrofrequency" + Math(r'f_{ce}') + "= %0.5e " %(fce))

I got an error:

 TypeError: cannot concatenate 'str' and 'Math' objects

Upvotes: 1

Views: 3292

Answers (1)

cel
cel

Reputation: 31349

You can render the full latex string by passing it to the Latex constructor:

from IPython.display import Latex

B=1.0e5   # in Gauss
fce = 1.80e6 * B 

Latex("Electron gyrofrequency $f_{ce}$= %0.5e " % fce)

Upvotes: 1

Related Questions