简体   繁体   English

如何在Ipython(py 2.7)笔记本中更改markdown单元格的字体大小和颜色

[英]How to change the font size and color of markdown cell in Ipython (py 2.7) notebook

I am trying to write a paper in Ipython notebook, therefore I want to decorate it a little bit. 我想在Ipython笔记本上写一篇论文,所以我想稍微装饰一下。 Usually I do it with the "#" to change the size. 通常我用“#”来改变大小。 However, I noticed that the # stops working when the indent is more than 4 但是,我注意到当缩进超过4时#停止工作

###Python Paper
       ####Python Oaoer

I also tried: .text_cell_render { font-family: Times New Roman, serif; 我也尝试过:.text_cell_render {font-family:Times New Roman,serif; } However it shows invalid syntax error. 但是它显示无效的语法错误。

Another method I tried was to locate the ipython in my laptop. 我尝试的另一种方法是在我的笔记本电脑中找到ipython。 That went south too. 那也是南方。 Could anybody elaborate a little. 任何人都可以详细说明一下。

I am fairly new to Python, forgive my ignorance and request for spoon-feeding. 我是Python的新手,请原谅我的无知和请求喂勺。 Thanks in advance 提前致谢

If you want to change the appearance of your notebook, please refer to this document: iPython style sheets 如果您想更改笔记本的外观,请参阅此文档: iPython样式表

CSS in a cell is not recommended but is possible like so: 建议不要在单元格中使用CSS,但可以这样:

from IPython.core.display import HTML
HTML("""
<style>

div.cell { /* Tunes the space between cells */
margin-top:1em;
margin-bottom:1em;
}

div.text_cell_render h1 { /* Main titles bigger, centered */
font-size: 2.2em;
line-height:1.4em;
text-align:center;
}

div.text_cell_render h2 { /*  Parts names nearer from text */
margin-bottom: -0.4em;
}


div.text_cell_render { /* Customize text cells */
font-family: 'Times New Roman';
font-size:1.5em;
line-height:1.4em;
padding-left:3em;
padding-right:3em;
}
</style>
""")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM