因为用到大量的数学公式编辑,就搭建一个IPython Notebook环境,并编辑复杂的数学公式。
其实也可以采用MathML,在网页中编辑,但MathML缺少简洁性。但网页中有非常好的展示性。
IPython官方参考文档:http://ipython.org/ipython-doc/dev/notebook/
1、安装
安装脚本,文件:ipython_install.sh
pip install IPython -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install jupyter -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
脚本下载地址:https://github.com/QiangAI/PythonSkill/tree/master/AdvPython
2、启动IPython Notebook服务器
在控制台输入命令行:
> IPython notebook
执行该指令后会自动启动浏览器,并打开编辑环境。
这是IPython booknote启动的过程

IPython booknote编辑UI如下:

3、创建一个Notebook文档
(1)一般建议创建一个工作目录,并切换到工作目录

(2)新建文档
新建文档操作

点击【New】,在出现的下拉菜单点击【Python3】(也可能是Python2,这取决于安装的Python版本)
下面是创建后的编辑UI。

(3)保存新建文档
在UI的【File】菜单中可以选择【Save as】,因为默认文件名是Untitled。

输入需要保存的文件名,然后就可以产生一个扩展名为:ipynb的文档文件。
4、编辑内容类型
在IPython notebook中能够编辑的内容类型分成4种:Code,Markdown,Raw NBConvert,Heading。

Code:源代码
Markdown:正文文本(这是Github提出的一种文本编辑格式)
Raw NBConvert:这是一个命令行工具,可将你的笔记本转换为另一种格式
Heading:用来设置Markdown内容为标题,可以指定标题级别。
实际内容选择仅仅是前面两个。后面两个严格意义讲是内容工具。
5、第一个LaTeX公式
(1)选择文档单元类型(Cell Type)为Markdown。

(2)编辑公式内容
在Cell中输入包含公式的文本内容。

(3)显示公式
编辑好文本内容后,点击Run快捷工具按钮,就可以现实最后效果的内容。并同时开启一个新的内容单元格(Cell)。

例子下载:https://github.com/QiangAI/AICode/blob/master/notebook/LatTeX_Test.ipynb
网友评论