Books with Jupyter¶ Jupyter Book is an open source project for building beautiful, publication-quality books and documents from computational material. Here are some of the features of Jupyter Book: Write publication-quality content in Markdown. You can write in either Jupyter Markdown, or an extended flavor of Markdown with publishing features. This video will explain Markdown in Jupyter Notebook. How do Headings, Bold, Italic, Bullets, Numbered lists, Mathematical symbols, Indented quoting, Line br. Markdown Mode in Jupyter Very very quickly, this is how you can switch to markdown mode in Jupyter. Select a cell in command mode. If you see a cursor in the cell and can write, then it’s in edit. Markdown in Jupyter Notebook In this tutorial, you'll learn how to use and write with different markup tags using Jupyter Notebook. Markdown is a lightweight and popular Markup language which is a writing standard for data scientists and analysts. Markdown (or R Markdown) Makefiles; This is a lot, though, and hopefully those without the full suite of knowledge above can still gain some appreciation of the system I’m going to describe. For many years now, the Python community has had really nice integration with R through rpy2 and the cell magic of%%R in Jupyter/IPython.
Markdown is a simple text-to-HTML markup language written in plain text. Jupyter notebook recognizes markdown and renders markdown code as HTML. In this section, we present the basic features of markdown.
See Markdown (by John Gruber) and GitHub Markdown Help for more information.
Text
Output | Syntax |
---|---|
emphasis | *emphasis* |
strong | **strong** |
code | `code` |
Headings
Output | Syntax |
---|---|
# Heading 1 | |
Heading 2 | ## Heading 2 |
Heading 3 | ### Heading 3 |
Heading 4 | #### Heading 4 |
Heading 5 | ##### Heading 5 |
Heading 6 | ###### Heading 6 |
Lists
Create an ordered list using numbers:
- Number theory
- Algebra
- Partial differential equations
- Probability
Jupyter Markdown Html
Create an unordered list using an asterisk * for each item:
- Number theory
- Algebra
- Partial differential equations
- Probability
Use indentation to create nested lists:
- Mathematics
- Calculus
- Linear Algebra
- Probability
- Physics
- Classical Mechanics
- Relativity
- Thermodynamics
- Biology
- Diffusion and Osmosis
- Homeostasis
- Immunology
Links
Create a link with the syntax [description](url)
. For example:
creates the link UBC Math.
Images
Include an image using the syntax ![description](url)
. For example:
displays the image
Tables
Create a table by separating entries by pipe characters |:
Python Operator | Description |
---|---|
+ | addition |
- | subtraction |
* | multiplication |
/ | division |
** | power |
The syntax :---:
specifies the alignment (centered in this case) of the columns. See more about GitHub flavoured markdown.
Exercises
- Create a numbered list of the top 5 websites you visit most often and include a link for each site.
- Write a short biography of your favourite mathematician, provide a link to their Wikipedia page and include an image (with a link and description of the source).
- Create a table of all the courses that you have taken in university. Include the columns: course number, course title, year (that you took the class), and instructor name.
Learning Objectives
Jupyter Markdown Table
After completing this page, you will be able to:
- Create new Code and
Markdown
cells withinJupyter Notebook
. - Run Code and
Markdown
cells withinJupyter Notebook
to executePython
code and renderMarkdown
text. - List useful shortcuts for common tasks in
Jupyter Notebook
.
Work With Python Code and Markdown Cells in Jupyter Notebook
Recall that a Jupyter Notebook
file consists of a set of cells that can store text or code.
- Text Cells: Text cells allow you to write and render
Markdown
syntax. This is where you can describe and document your workflow. - Code Cells: Code cells allow you to write and run programming code (e.g.
Python
).
Create New Cells
You can use either the Menu tools or Keyboard Shortcuts to create new cells.
Function | Keyboard Shortcut | Menu Tools |
---|---|---|
Create new cell | Esc + a (above), Esc + b (below) | Insert→ Insert Cell Above OR Insert → Insert Cell Below |
Copy Cell | c | Copy Key |
Paste Cell | v | Paste Key |
While the default cell type for new cells is Code, you can change the cell type of any existing cell by clicking in the cell and selecting a new cell type (e.g. Markdown
) in the cell type menu in the toolbar.
Cell type options include Code, Markdown, Raw NBConvert (for text to remain unmodified by nbconvert), and Heading.
To use the Keyboard Shortcuts, hit the esc
key. After that, you can change a cell to Markdown by hitting the m
key, or you can change a cell to Code by hitting the y
key.
Run Cells
Python Code Cells
You can run any cell in Jupyter Notebook
(regardless of whether it contains Code or Markdown
) using the Menu tools or Keyboard Shortcuts.
Function | Keyboard Shortcut | Menu Tools |
---|---|---|
Run Cell | Ctrl + enter | Cell → Run Cell |
For example, you can add a new Code cell and then run the following Python
code (e.g. 3 + 4
). Your result, or output, will be displayed below the Code cell that you run.
Markdown Cells
You can run Markdown
cells in the same way that you can run code cells. However, when you run a Markdown
cell, the text formatted using Markdown
syntax will be rendered as stylized text.
This means that headings are larger and bold, bulleted lists have bullets next to them instead of *
, and regular text looks normal. No outputs will appear below the Markdown cell.
For example, the Markdown
syntax below represents 3 headers. You can double-click in any Markdown
cell to see the raw Markdown
syntax, which for the cell below would appear like this raw Markdown
syntax:
To see the Markdown
as stylized text, run the cell. It should look like the text printed below:
This is a subtitle in Markdown
This is a smaller subtitle
This is an even smaller subtitle
Rearrange Cells in a Jupyter Notebook
You can change the order of cells within Jupyter Notebook
using the up arrow
and down arrow
buttons on the menu bar. To do this, click inside the cell that you want to move and then press the desired arrow as many times as you need to move the Cell to the desired location.
Clear Results in Jupyter Notebook
Sometimes, you may want to clear any output results that have been produced. You can do this using the Menu:
Menu Tools |
---|
Cell -> Current Outputs -> Clear |
This will clear the current cell that you are working in, which you can activate by clicking in a cell.
You can also clear all of the output using the Menu Tools.
Jupyter Markdown Bold
Jupyter Markdown New Line
Menu Tools |
---|
Cell -> All Output -> Clear |