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

8

我正在尝试在Ipython笔记本中写论文,因此我想稍微装饰一下。通常我使用"#"来改变大小。然而,我注意到当缩进超过4个时,"#"停止工作。

###Python Paper
       ####Python Oaoer

我还尝试了以下代码:

.text_cell_render {
    font-family: Times New Roman, serif;
}

但是它显示无效的语法错误。

我尝试过另一种方法,就是找到我的笔记本电脑中的ipython。但那也没有成功。请问有人可以详细解释一下吗?

我对Python还比较新,请求大家不吝指教。非常感谢!

1个回答

20

如果您想改变笔记本的外观,请参考此文档:iPython样式表

不推荐在单元格中使用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>
""")

非常感谢,你帮了我很多。这非常详细和有用,谢谢。 - Bowen Liu

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接