Different font settings for editing code and markdown cells in the Jupyter Notebook

点点圈 提交于 2019-12-07 15:59:00

问题


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";
}

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

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

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?


回答1:


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;
}


来源:https://stackoverflow.com/questions/46504551/different-font-settings-for-editing-code-and-markdown-cells-in-the-jupyter-noteb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!