Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the font size and color of markdown cell in Ipython (py 2.7) notebook

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

###Python Paper
       ####Python Oaoer

I also tried: .text_cell_render { font-family: Times New Roman, serif; } However it shows invalid syntax error.

Another method I tried was to locate the ipython in my laptop. That went south too. Could anybody elaborate a little.

I am fairly new to Python, forgive my ignorance and request for spoon-feeding. Thanks in advance

like image 840
Bowen Liu Avatar asked Dec 16 '15 03:12

Bowen Liu


People also ask

How do I change the font in Markdown in Jupyter notebook?

If you want to change the text cell font and font size you can type the following in a cell and hit shift+enter.

How do you edit a Jupyter notebook Markdown cell?

Just double click on the markdown cell. Edit what you want to and Run. It will reflect the changes. Save your notebook.

How do I increase font size in Markdown?

To change the font size, you don't need to know a lot of html for this. Open the html output with notepad ++. Control F search for "font-size". You should see a section with font sizes for the headers (h1, h2, h3,...).

How do you make a Markdown cell bold in Jupyter notebook?

For example, to make a word bold, surround it with the HTML code for bold ( <b>text</b> instead of the Markdown code. You can attach image files directly to a notebook in Markdown cells by dragging and dropping it into the cell.


1 Answers

If you want to change the appearance of your notebook, please refer to this document: iPython style sheets

CSS in a cell is not recommended but is possible like so:

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>
""")
like image 181
aquagremlin Avatar answered Sep 21 '22 09:09

aquagremlin