本文介绍了在Jupyter Notebook中用于编辑代码和Markdown单元的不同字体设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Jupyter笔记本中,我想在编辑 markdown单元格和UbuntuMono用于代码单元格时使用常规的Ubuntu字体.我可以通过编辑.jupyter/custom/custom.css来同时更改这两种单元格类型的字体,如下所示:

In the Jupyter notebook, I would like to use the regular Ubuntu font when editing markdown cells and UbuntuMono for code cells. I can change the fonts of both these cell types simultaneously by editing .jupyter/custom/custom.css like so:

.CodeMirror pre {
    font-family: "Ubuntu Mono", monospace;
    font-size: 14pt;
}

我还可以更改降价代码单元中标头的格式:

I can also change the formatting of the headers in the markdown code cells:

.cm-header {
    font-size: 110%;
    font-family: "Ubuntu";
}

以及渲染后文本的外观(执行markdown单元后):

As well as how the text looks when rendered (after executing a markdown cell):

div.text_cell_render {
    font-family: "Ubuntu";
    font-size: 12pt;
}

但是,我不明白在编辑模式下我可以使用哪个CSS类来区分代码单元和markdown单元中的paragragh/body文本.我在Firefox中尝试了对象检查器,但是两种单元格类型的输入文本都使用相同的span标签和css类显示.我已经尝试了许多列出的组合在这里,但是似乎我找不到合适的主意,有什么主意吗?

However, I don't understand which css classes I could use to discriminate between code cells and paragragh/body text in markdown cells in edit mode. I tried the object inspector in Firefox, but the input text for both cell types show up with the same span tags and css classes. I have tried many of the combinations listed here, but it seems like I just can't find the right one, any ideas?

推荐答案

我收到了Jupyter Notebook问题的回复,该问题链接在此处对我的问题的评论中.可以结合使用CSS选择器,因此以下解决了我的问题:

I received a reply from the Jupyter Notebook issue linked in the comments of my questions here. It is possible to combine CSS selector, so the following solves my problem:

.text_cell .CodeMirror pre {
    font-family: "Ubuntu";
    font-size: 12pt;
}

这篇关于在Jupyter Notebook中用于编辑代码和Markdown单元的不同字体设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 17:28