Reputation: 1366
Consider the following input in a IPython notebook:
mu = 39.95
Z=1
Latex(r"Atomic Mass: $\quad \mu$= %0.5e Hz" %(mu))
Latex(r"Charge state: $\quad z$= %0.5e" %(Z))
My question has two parts.
(A) Missing output
From above source, Surprisingly I got the following result:
Charge state: z = 1.00000e+00
What happened to the first line (i.e the value of $mu$ was not printed)?
(B) Missing newline
I was however able to get the result using the following:
Latex(r"Atomic Mass: $\quad \mu$= %0.5e Hz " %(mu) + r"Charge state: $\quad z$= %0.5e" %(Z))
But now, I need a newline in the above. How does one do it?
Upvotes: 1
Views: 3332
Reputation: 31339
By default the notebook only renders the last value obtained in a cell. Use IPython.display.display
as an augmented print
function to display several things:
from IPython.display import Latex, display
mu = 39.95
Z=1
display(Latex(r"Atomic Mass: $\quad \mu$= %0.5e Hz" % mu))
display(Latex(r"Charge state: $\quad z$= %0.5e" % Z))
Upvotes: 1