Appendix A — Adding Jupyter Notebooks Chapters

Quarto can include Jupyter notebooks (.ipynb) directly as book chapters. This is particularly useful when teaching materials combine narrative text, executable code, and visualisations created in Jupyter Notebook and you want to share it with students.

Note

This chapter is actually compiled from a .ipynb file rather than a .qmd file.

A.1 Adding a Notebook to the Quarto Book

List the notebook in the chapters section of _quarto.yml just as you would a .qmd file (see Section 12.5).

Quarto will automatically render the notebook as a chapter in the book and include it in the table of contents and navigation.

A.2 Controlling Code Display

Notebook cells can be shown, hidden, or folded using cell metadata.

For example, to hide a code cell while displaying its output:

{
  "tags": ["hide-input"]
}

Common tags include:

  • hide-input – hide code, show output
  • hide-output – show code, hide output
  • hide-cell – hide both code and output

A.3 Using Notebooks with Quarto Features

Jupyter notebooks support many Quarto features, including:

  • Citations
  • Equations
  • Figure captions
  • Callouts
  • Cross-references

A.4 An example of some executable code

The code below is a code block in a .ipynb notebook

for i in range(5):
    print("hello world")
hello world
hello world
hello world
hello world
hello world