简体   繁体   English

更改 iPython 笔记本 markdown 单元格中的字体

[英]Changing the font in iPython notebook markdown cells

I just wanted to change the default font in Ipython (1.0.0) notebook markdown cells to something else, and tried doing this using style tags in a markdown cell instead of going through the path of creating a custom.css.我只是想将 Ipython (1.0.0) 笔记本 markdown 单元格中的默认字体更改为其他字体,并尝试使用 markdown 单元格中的样式标签来执行此操作,而不是通过创建 custom.ZC7A628CBA22E28EB17B5F5C6AE2A26 的路径。 I do not know CSS, and my needs are very minimal.我不知道 CSS,我的需求很少。 After some research, I found the following code snippet:经过一番研究,我发现了以下代码片段:

<style>
div.text_cell_render {
font-family: "Times New Roman", serif;
...
}
</style>

I applied the above CSS code to a markdown cell, however the font in the other markdown text cells did not change.我将上述 CSS 代码应用于 markdown 单元格,但是其他 markdown 文本单元格中的字体没有改变。 Do I have to turn something on first?我必须先打开一些东西吗? Below is how it looks like:下面是它的样子:

截图

On Ubuntu this works: 在Ubuntu上,这有效:

<style>
.text_cell_render {
font-family: Times New Roman, serif;
}
</style>

The ... in your example indicate other possible options like listed eg in http://www.w3schools.com/css/css_text.asp 您示例中的...表示其他可能的选项,例如http://www.w3schools.com/css/css_text.asp中列出的选项

However, this CSS applies to all rendered cell text, ie. 但是,此CSS适用于所有呈现的单元格文本,即。 markdown and heading. 降价和标题。 If you want to format just the markdown text use .text_cell_render p { . 如果只想格式化降价文字,请使用.text_cell_render p { The individual headings can be addressed with h1 , h2 , etc instead of p . 可以使用h1h2等代替p来处理各个标题。

To change the CSS style in a Jupyter notebook, simply create a cell at the top with the styles:要在 Jupyter 笔记本中更改 CSS 样式,只需在顶部使用 styles 创建一个单元格:

%%html
<style>
.rendered_html p {
    font-size: 17px;
    font-family: Ubuntu Mono;
    text-align:justify}
</style>

More information in here更多信息在这里

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

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