How to change font in ipython notebook

后端 未结 7 981
粉色の甜心
粉色の甜心 2020-12-04 13:35

I am fairly new to python and have no html experience. The question has been asked and either not answered at all or not answered in enough detail for me to set the default

相关标签:
7条回答
  • 2020-12-04 13:43

    There is a much easier way to do without adding the CSS files and all the other methods suggested. But you have to do it every time you start the Jupiter notebook.

    Go to inspect in your browser and click on the element selection icon and then click on the box. And at the bottom of the page, you will be seeing the styling option for CSS where you can easily change the font-size.

    0 讨论(0)
  • 2020-12-04 13:59

    I would also suggest that you explore the options offered by the jupyter themer. For more modest interface changes you may be satisfied with running the syntax:

    jupyter-themer [-c COLOR, --color COLOR]
                          [-l LAYOUT, --layout LAYOUT]
                          [-t TYPOGRAPHY, --typography TYPOGRAPHY]
    

    where the options offered by themer would provide you with a less onerous way of making some changes in to the look of Jupyter Notebook. Naturally, you may still to prefer edit the .css files if the changes you want to apply are elaborate.

    0 讨论(0)
  • 2020-12-04 14:01

    Using Jupyterthemes, one can easily change look of notebook.

    pip install jupyterthemes
    
    jt -fs 15 
    

    By default code font size is set to 11 . Trying above will change font size. It can be reset using.

    jt -r 
    

    This will reset all jupyter theme changes to default.

    0 讨论(0)
  • 2020-12-04 14:02

    You can hover to .ipython folder (i.e. you can type $ ipython locate in your terminal/bash OR CMD.exe Prompt from your Anaconda Navigator to see where is your ipython is located)

    Then, in .ipython, you will see profile_default directory which is the default one. This directory will have static/custom/custom.css file located.

    You can now apply change to this custom.css file. There are a lot of styles in the custom.css file that you can use or search for. For example, you can see this link (which is my own customize custom.css file)

    Basically, this custom.css file apply changes to your browser. You can use inspect elements in your ipython notebook to see which elements you want to change. Then, you can changes to the custom.css file. For example, you can add these chunk to change font in .CodeMirror pre to type Monaco

    .CodeMirror pre {font-family: Monaco; font-size: 9pt;}
    

    Note that now for Jupyter notebook version >= 4.1, the custom css file is moved to ~/.jupyter/custom/custom.css instead.

    0 讨论(0)
  • 2020-12-04 14:02

    The new location of the theme file is: ~/.jupyter/custom/custom.css

    0 讨论(0)
  • 2020-12-04 14:03

    In JupyterNotebook cell, Simply you can use:

    %%html
    <style type='text/css'>
    .CodeMirror{
    font-size: 17px;
    </style>
    
    0 讨论(0)
提交回复
热议问题