How to Transfer a Jupyter Notebook into an Immediate Slideshow

Running your code directly while playing your slideshow during your presentation

A Jupyter notebook can be either transferred into Reveal.js slides or turned into an immediate slide presentation. There are three common methods to create a presentation slideshows from a notebook, i.e.

  • Saving Notebook as Reveal.js Slides
  • Converting Notebook into Slides
  • Turning Notebook into an Immediate and Live Presentation

In this post, I will illustrate you how to create a presentation slideshows from a notebook and make it into an immediate and live presentation using RISE.

1. RISE

(1) What is RISE

RISE is a Jupyter notebook extension, which enables you to instantly turn your Jupyter Notebook into a live reveal.js-based presentation. In this section, we will view how to install the extension, and how we use RISE to turn our simple_slidedeck into the live and immediate slide deck.

(2) RISE Installation

Based on the official document, there are two options to install RISE. You can install it directly in the Jupyter notebook.

(1) Use conda

If you are an Anaconda user, just install RISE through the following command:
 conda install -c conda-forge rise

(2) Use pip

Normally, you can install it through pip with the command as follows:
 pip install RISE

The installation process in the Jupyter notebook looks as the follows:

Collecting RISE
Using cached rise-5.7.1-py2.py3-none-any.whl (4.3 MB)
Requirement already satisfied: notebook>=6.0 in c:\users\sigmund\anaconda3\lib\site-packages (from RISE) (6.4.8)
Requirement already satisfied: argon2-cffi in c:\users\sigmund\anaconda3\lib\site-packages (from notebook>=6.0->RISE) (21.3.0)
Requirement already satisfied: nbformat in c:\users\sigmund\anaconda3\lib\site-packages (from notebook>=6.0->RISE) (5.3.0)
Requirement already satisfied: Send2Trash>=1.8.0 in c:\users\sigmund\anaconda3\lib\site-packages (from notebook>=6.0->RISE) (1.8.0)
Requirement already satisfied: pyzmq>=17 in c:\users\sigmund\anaconda3\lib\site-packages (from notebook>=6.0->RISE) (22.3.0)
Requirement already satisfied: terminado>=0.8.3 in c:\users\sigmund\anaconda3\lib\site-packages (from notebook>=6.0-\site-packages (from stack-data->ipython>=7.23.1->ipykernel-
.
.
.
>notebook>=6.0->RISE) (0.2.2)
Installing collected packages: RISE
Successfully installed RISE-5.7.1
Note: you may need to restart the kernel to use updated packages.

The last few lines indicate that the RISE was successfully installed and that it need restart the kernel. Thus, let’s go to the Kernel and restart it.

Next, you also should refresh your browser. Then you should find there is a new icon like a bar graph on the toolbar of the Jupyter Notebook. When you move your mouse besides this icon, it shows Enter/Exit RISE Slideshow. It looks like the following screenshot:

2. Create Slides

Now let’s create some slides, and I illustrate you the general process using the following steps.

Step 1: Create a new notebook

Let’s create the notebook and change its name to whatever you like, say “simple_slidedeck” for example.

Step 2: Create a Title Page

Above all, let’s create a title page, or cover page as follows:

In the title page, for example, we add a logo on right-upper corner, two images – Python logo and Jupyter logo in the middle, and then a title of the presentation and author name and email. The code snippet is as follows:

<img src="./images/deepsim-academy-logo.png"
style="float: right"
width=150
style="padding-bottom:30px;"/>
<br>
<br>
<table>
<tr>
<td>
<img src='./images/python-logo.png'width=350>
</td>
<td>
<img src='./images/jupyter_logo.png'width=350>
</td>
</tr>
</table>
<h1 style='text-align: center;'>Awesome Immediate Slideshow in Jupyter Notebook</h1>
<h2 style='text-align: center;'>Sigmund S. Wei, Ph.D. Professor</h2>
<h3 style='text-align: center;'>Email: shouke.wei@gmail.com</h3>

The first <img> tag is used to embed a logo and align it to the right, the second one and third one are used to embed Python logo and Jupyter logo, respectively, and we use an HTML table to align the two logos on one row. Two spaces have added between the first logo and the following two. Then there comes the centred title at header level 1, followed by the centred presenter name and contact information.

If you are not familiar with how to size and align an embedded image, and how to align text in the Jupyter notebook, you can read my previous posts as follows:

How to Embed an Image, Size and Align it in the Jupyter Notebook

How to Easily Generate a Table and Align it in Jupyter Notebook

How to Align Text in the Jupyter Notebook

Step 3: Create a table of contents

For example, we create a TOC in the second Markdown cell, and type something as follows:

## Outline of the Presentation
- <h3>1. A Python Function</h3>
- <h3>2. A Simple Line Plot</h3>

Step 4: Create a slide header and Python function slide

Before starting to create our function slide, it is better for us to create a header to this slide. Just type the following header at level two in the fourth Markdown cell.

## 1. A Python Function

Then, in the next code cell, let’s create a simple adder function, which is able to sum three numbers. Type the following code in the cell.

# define an adder function to sum three numbers
def adder(x,y,z):
print("sum:",x+y+z)

adder(8,22,38)

Step 5: Create a header and a line plot

Similarly, first, let’s create a header at level 2 in the next Markdown cell as follows:

## 2. A Simple Line Plot

Then, we just type the following code to display how to plot a simple line plot in the following code cell.

x = [0,1,2,3,4,5,6,7,8,9,10]
y = [0,2,4,3,5,7,6,9,8,10,11]

plt.plot(x,y)

Step 6: Create end slide

In this end slide, let’s just type “Thank you for your attention!” for instance in a new Markdown cell. We will use HTML <h1> tag in the example because we want to align the text to the center of the side.

<h1 style="text-align: center">Thank you for your attention!</h1>

The end notebook looks like as the follows:

The slides created in notebooks look like the normal notebook, and the next task for us is to select which cells will be as slides and which types of slide the cell will be.

Step 7: Enter slide type set mode

Go to the menu bar, click View > Cell Toolbar > Slideshow, to bring up the slide type set mode.

Step 8: Set slide types

In the slide type set mode, we set all the other cells to “slide” except that the two cells of “Python function code” and “plot code”, which are selected as “-”.

The interesting thing is that selecting “-” will bring up this cell and previous cell in one slide, by which the header cell and code cell will come together in one slide. At the end of this step, it looks as the follows:

3. Turning Notebook into an Immediate and Live Slideshow

The more important aspect is that we will create a living slide deck where we can edit and run the code directly, and you can also freely switch between the slide mode and notebook mode.

(1) Run the Slideshow

Go to Enter/Exit RISE Slideshow icon > click it, and then it will render your notebook as a deck of slides in your browser. You can click the X to close it. Besides, RISE slides are live where you can click the cell and edit the text or code.

The end slideshow looks as follows:

You can edit the code or text directly. But the finish the editing, just use Shift+Enter shortcut to run the cell. Besides, you can use the Ctrl key and + or - combos to increase or decrease the page magnification. If you are using a mouse, you just hold down the keyboard Ctrl key and use the mouse wheel to zoom in or out.

4. Video Tutorial

If you are interested in a video version, you can watch the video tutorial on my YouTube channel. If this video is helpful, please subscribe to my channel to support me.

5. Online Course

If you are interested in learning Jupyter notebook in details, you are welcome to enroll one of my course Practical Jupyter Notebook from Beginner to Expert.

Bookmark
Please login to bookmarkClose
0 - 0

Thank You For Your Vote!

Sorry You have Already Voted!

Please follow and like me:

Leave a Reply

Your email address will not be published. Required fields are marked *