1

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
2
  • have you tried Latex("Electron gyrofrequency $f_{ce}$= %0.5e " %fce) Commented Dec 28, 2016 at 16:06
  • That worked. Please make it an answer so I can accept it Commented Dec 28, 2016 at 16:09

1 Answer 1

1

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)
Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.