Choosing style
Look at the drop-down list to the right of the document toolbar. It allows you to choose presentation style of a cell. For example, the existing cells are presented as code.
Click the cell with the import statement again, and click . The new cell appears below. By default, its style selector shows Code. In this cell, type the following text:
Plot example |
Click the down arrow and select Markdown from the list:
The cell changes its view:
Click on the toolbar, and see how the cell looks now:
Now you can just select the desired style from the drop-down list, and the view of the cell changes approriately:
Writing formulae
Add a new cell. In this cell, choose Markdown from the style selector, and type the following text:
$$c = \sqrt{a^2 + b^2}$$
|
Click . The result is stunning:
As you see, PyCharm's IPython Notebook integration makes it possible to use LaTex notation and render formulae, labels and text.
Next, explore the more complicated case. The expected result - the formula - should appear as the result of calculation.
Add a cell and type the following code (taken from SymPy: Open Source Symbolic Mathematics):
from __future__ import division
from IPython.display import display
from sympy.interactive import printing
printing.init_printing(use_latex='mathjax')
import sympy as sym
from sympy import *
x, y, z = symbols("x y z")
k, m, n = symbols("k m n", integer=True)
f, g, h = map(Function, 'fgh')
|
Run this cell. It gives no output. Next, add another cell and type the following:
Rational(3,2)*pi + exp(I*x) / (x**2 + y)
|
Click , and enjoy:
Markdown 单元格高级用法
我们再来看看 Markdown 单元格。虽然它的类型是 markdown,但是这类单元格也接受 HTML 代码。这样,你就可以在单元格类实现更加丰富的样式,添加图片,等等。例如,如果想在 notebook 中添加 Jupyter 的 logo,将其大小设置为 100px x 100px,并且放置在单元格左侧,可以这样编写:
<img src="http://blog.jupyter.org/content/images/2015/02/jupyter-sq-text.png"
style="width:100px;height:100px;float:left">
计算该单元格之后,会出现这样的结果:
另外,markdown 单元格还支持 LaTex 语法。例如:
$$\int_0^{+\infty} x^2 dx$$
计算上述单元格,将获得下面的 LaTex 方程式: