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 对cells使用markdown格式. 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:

对cells使用markdown格式

The cell changes its view:

对cells使用markdown格式

Click 对cells使用markdown格式 on the toolbar, and see how the cell looks now:

对cells使用markdown格式

Now you can just select the desired style from the drop-down list, and the view of the cell changes approriately:

对cells使用markdown格式

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 对cells使用markdown格式. The result is stunning:

对cells使用markdown格式

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 对cells使用markdown格式, and enjoy:

对cells使用markdown格式

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">

计算该单元格之后,会出现这样的结果:

对cells使用markdown格式

另外,markdown 单元格还支持 LaTex 语法。例如:

$$\int_0^{+\infty} x^2 dx$$

计算上述单元格,将获得下面的 LaTex 方程式:

对cells使用markdown格式

相关文章:

  • 2022-01-20
  • 2021-12-04
  • 2022-02-01
  • 2022-12-23
  • 2021-10-17
  • 2021-05-19
猜你喜欢
  • 2021-07-09
  • 2022-02-27
  • 2022-12-23
  • 2021-05-09
  • 2021-11-13
  • 2021-06-15
  • 2021-11-01
相关资源
相似解决方案