Raw Cells¶
Any Jupyter Notebook consists of cells of three different types: Code cells, Markdown cells , and/or Raw cells. While most Jupyter Notebook users are very familiar with Code cells and Markdown cells in Jupyter Notebooks, Raw cells are less frequently used. For Jupyter Notebook, they are introduced here and for JupyterLab here. The Raw cells are also sometimes referred to as Raw NBConvert cells in the context of nbconvert. The Raw cell type can be used to render different code formats into HTML or LaTeX by Sphinx. This information is stored in the notebook metadata and converted appropriately.
Usage¶
Raw cells are created differently depending on the user interface.
Jupyter Notebook¶
To select a desired format from within Jupyter Notebook, select the cell containing your special code and choose options from the following dropdown menus:
Select “Raw NBConvert” in the Menu Toolbar (just below the two menus “Widgets” and “Help”).
Click on the “Raw NBConvert Format” dropdown menu within the cell and select “reST”.
JupyterLab¶
To select a desired format from within JupyterLab, first activate the right sidebar by clicking on View in the Menu Toolbar. Then you ensure that in front of Show Right Sidebar there is a tick. Once the Right Sidebar is shown, you are ready to go.
Now you select the cell containing your special code and choose options from the following dropdown menus:
Select “Raw” in the Notebook Toolbar (just next to the symbols that run cells or reload the kernel).
Click on “Raw NBConvert Format” in the Right Sidebar and select “reStructured Text”.
Available Raw Cell Formats¶
The following examples show how different Jupyter cell formats are rendered by Sphinx.
None¶
By default (if no cell format is selected), the cell content is included (without any conversion) in both the HTML and LaTeX output. This is typically not useful at all.
"I'm a raw cell with no format."reST¶
Raw cells in “reST” format are interpreted as reStructuredText and parsed by Sphinx. Thus, you can e.g. use its cross-referencing abilities for automatically creating/updating links to the definition of modules, classes, functions, and similar. The result is visible in both HTML and LaTeX output.
“I’m a raw cell in reST format.”
I can contain Sphinx roles such as a link to example_python_function()
.
Markdown¶
Raw cells in “Markdown” format are interpreted as Markdown, and the result is included in both HTML and LaTeX output. Since the Jupyter Notebook also supports normal Markdown cells, this might not be useful at all.
“I’m a raw cell in Markdown format.”
HTML¶
Raw cells in “HTML” format are only visible in HTML output. This option might not be very useful, since raw HTML code is also allowed within normal Markdown cells.
“I’m a raw cell in HTML format.”
LaTeX¶
Raw cells in “LaTeX” format are only visible in LaTeX output.
Python¶
Raw cells in “Python” format are not visible at all (nor executed in any way).