Introduction
This is just an example of a Pressbooks book using Jupyter Notebook to add interactivity to the many great functionalities already available at Pressbooks platform, such as reader annotations (Hypothesis) and interactive content (H5P).
The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more.
It is very easy to include Jupyter notebooks in your open textbooks using a plugin by Andrew Challis.
Note January 2023: unfortunately nbviewer now adds extra lines that prevent this plugin from working properly. For that you need to clean up the output file from https://nbviewer.jupyter.org/url/<ipynb githubfilename> in this case https://nbviewer.org/github/Jero2760/nbconvert/blob/master/Python%20for%20DS/lecture1.ipynb
In this example book, lectures and assignments are provided as interactive Jupyter notebooks. Readers can then study through a lecture notebook and then read the assignment notebook and access it through GitHub to open and run the Jupyter notebook.
Installation
- Install WP Pusher as a plugin in your Pressbooks site by downloading and installing the package from a zip file: go to your Pressbooks dashboard, Network Administrator, and select Plugins -> Add Plugins -> Upload Plugin. Upload your WP Pusher zip file, install it and activate it
- Install the nbconvert plugin in your Pressbooks site: from the WP Pusher settings, add the nbconvert plugin by typing this uri into the git plugin installer: ghandic/nbconvert. Go to Network Administrator -> Plugins -> WP Pusher -> Install plugin -> [Repository host: select GitHub] -> [Plugin repository: type ghandic/nbconvert] -> Install plugin
- Activate the nbconvert plugin for your network
- Customize your book css as needed, since nbconvert.css from the plugin can require some adaptation (in your book go to Appearance -> Custom Styles -> Your Web Styles). My custom styles file is available here.
How it works
Simply add a shortcode and a url to the notebook file into your page editor on Pressbooks, between square brackets:
nbconvert url=”https://github.com/Jero2760/nbconvert/blob/master/example1.ipynb”