How to format text cells in Jupyter?
Solution 1
After creating those blocks you have to run them to give you that white background.
Press Ctrl + Enter inside the block.
For eg.
Click on a cell. Press Esc and then press 1
Now type this: "THIS IS A HEADING"
And then press Ctrl + Enter.
You will get this as an output with a white background (The image below is a bit dull):
Solution 2
In addition, by using the %%html
magic command, you can type HTML in cells and get them rendered the way you want
Sembei Norimaki
Engineer who loves challenges and is always working in new professional and personal projects.
Updated on June 05, 2022Comments
-
Sembei Norimaki almost 2 years
I would like to create a Jupyter notebook to make a tutorial.
When I go to the jupyter website and I try jupyter in the browser, there is already a nice python tutorial, with some cells used as text explanations and others as code:
Now I create a new notebook and I am able to create different cells and format them in 4 types:
- Code
- Markdown
- Raw NBConvert
- Heading
However none of them allow me to create the text explanations with white background as in the image above. I tried formatting one cell as markdown and it's just keeping with the grey background.
Am I missing something? Thanks.
-
Sembei Norimaki over 7 yearsWow, it's simpler than I though. Thanks
-
Roman Orac over 5 yearsI would also suggest you use a python code formatter for Jupyter notebooks: github.com/kenkoooo/jupyter-autopep8.