如何在 Ipython (py 2.7) notebook 中更改 Markdown 单元格的字体大小和颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34303422/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change the font size and color of markdown cell in Ipython (py 2.7) notebook
提问by Bowen Liu
I am trying to write a paper in Ipython notebook, therefore I want to decorate it a little bit. Usually I do it with the "#" to change the size. However, I noticed that the # stops working when the indent is more than 4
我想在 Ipython notebook 上写一篇论文,因此我想稍微装饰一下。通常我用“#”来改变大小。但是,我注意到当缩进超过 4 时 # 停止工作
###Python Paper
####Python Oaoer
I also tried: .text_cell_render { font-family: Times New Roman, serif; } However it shows invalid syntax error.
我也试过: .text_cell_render { font-family: Times New Roman, serif; 但是它显示无效的语法错误。
Another method I tried was to locate the ipython in my laptop. That went south too. Could anybody elaborate a little.
我尝试的另一种方法是在我的笔记本电脑中找到 ipython。那也南下。谁能说得详细一点。
I am fairly new to Python, forgive my ignorance and request for spoon-feeding. Thanks in advance
我对 Python 相当陌生,请原谅我的无知并要求用勺子喂食。提前致谢
采纳答案by aquagremlin
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>
""")