Jupyter Notebooks

Markdown

Documentation: https://daringfireball.net/projects/markdown/basics

Cheatsheet: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet

Magic keywords

Examples

For more magic keywords - https://ipython.readthedocs.io/en/stable/interactive/magics.html

Converting notebooks

nbconvert - ex:

jupyter nbconvert --to html notebook.ipynb

Read more at: https://nbconvert.readthedocs.io/en/latest/usage.html

Slideshows

To create the slideshow from the notebook file, you'll need to use nbconvert:

    jupyter nbconvert notebook.ipynb --to slides

This just converts the notebook to the necessary files for the slideshow, but you need to serve it with an HTTP server to actually see the presentation.

To convert it and immediately see it, use

jupyter nbconvert notebook.ipynb --to slides --post serve

This will open up the slideshow in your browser so you can present it.

jupyter nbconvert presentation.ipynb --to slides --template output_toggle.tpl
--post serve

If you're at home with HTML, css, and web engine templating, then you have a lot of potential room for customizing your slide deck work. Otherwise, you can just use an expression like the following to get a basic slide deck up and running.

Additionally, running the base expression will not automatically open up the slide deck for viewing. In order to serve the slides, you would need to install a local copy of reveal.js (Installation documentation), make sure that your HTML slides point to the library correctly (using the --reveal-prefix option), and then start a local http server (e.g., via python -m http.server). Alternatively, you can add the --post serve option to your expression to make use of a public, online version of reveal.js, start up a server, and immediately open a tab in your web browser with the slide deck ready to navigate.

By default, code cell inputs and outputs are both rendered in the slides. More likely than not, you'll want to hide the code in your presentation so that all attention can be put on the visualizations and text. To do this, you can specify a template file using the --template option. On this page, you can find template code (output_toggle.tpl) that will hide code cells from nbconvert. The template file is also available at this link and in the Resources at the bottom of this page.

However, it's likely that you'll want to add additional options to the nbconvert call to make the slides look cleaner and to make serving them easier.

jupyter nbconvert presentation.ipynb --to slides

Once your notebook has been prepared, save it and shut down your notebook server. On the command line, you can render the notebook as slides using the following expression as a base.

In addition to setting slide types, make sure that all of your code cells have been run and produce the output that you want to show. nbconvert will only export elements of the notebook as-is, and won't run the notebook cells as is. It is recommended that you use the Kernel > Restart & Run All menu option to do a clean run-through of all of your cells as a final preparatory action.

Last updated