Jupyter Lab Markdown Cheat Sheet



List of Useful Magic Commands in Jupyter Notebook/Lab Updated On: Dec-12,2020 magic-commands, jupyter-notebook Jupyter Notebook/Lab is the go-to tool used by data scientists and developers worldwide to perform data analysis nowadays. Jupyter notebook recognizes LaTeX code written in markdown cells and renders the symbols in the browser using the MathJax JavaScript library. Mathematics Inline and Display. Enclose LaTeX code in dollar signs $. $ to display math inline. For example, the code $ inta^b f(x) = F(b) - F(a)$ renders inline as $ inta^b f(x) dx = F(b) - F(a) $. Jupyter notebook on github markdown; markdown cheat sheet jupyter; integral markdown jupyter; write exponential in jupyter notebook markdown; ipython notebook markdown title; ipython notebook markup; code markdown jupyter; Please make the first cell in your.ipynb file be a Markdown cell that says “CMSC / Math 207 Homework 1” and your name. Markdown cells are used to store text formatted using Markdown syntax. A cheat sheet for Markdown can be found here. Most often these are used to introduce and describe the code that is being used and to make titles.

  1. Jupiter Notebook Markdown Guide
  2. Jupiter Lab Markdown Cheat Sheet Pdf
  3. Jupyter Lab Markdown Preview
  4. Jupyter Notebook Markdown Cheat Sheet

It’s possible to control which content shows up in your book. For example,you may want to display a complex visualization to illustrate an idea, but don’twant the page to be cluttered with a large code cell that generated the visualization.In other cases, you may want to remove a code cell entirely.

In this case, you have two options:

  • Hiding content provides a button that lets readers reveal the content.

  • Removing content prevents it from making it into your book. Itwill be entirely gone (though still present in the source files)

There are two ways to hide content:

  • To hide Markdown, use the {toggle} directive.

  • To hide or remove code cells or their outputs, use notebook cell tags.

We’ll cover each alternative below.

Hide Markdown using MyST Markdown¶

There are two ways to hide Markdown content

  • you can use the {toggle} directive to hide arbitrary blocks of content

  • you can use the dropdown class with admonitions to turn them into dropdowns

Both allow you to wrap chunks of Markdown in a button that lets users showand hide the content.

The {toggle} directive¶

You can activate a toggleable behavior in Markdown with the {toggle}directive like so:

This results in:

Some hidden toggle content!

Note that if you’d like to show the toggle content by default, you canadd the :show: flag when you use {toggle}, like so:

Toggle admonition content with dropdowns¶

You can also add toggle buttons to admonition blocks, effectively making themdropdown blocks. Users will see the admonition title, but will need to clickin order to reveal the content. To do so, add the dropdown class to any admonition.For example, the code

results in:

Click the button to reveal!

Some hidden toggle content!

See Dropdown admonitions for more information on admonition dropdowns.

Hide code cell content¶

You can hide most cell elements of a page. The sections below describe howto hide each using cell tags in MyST Markdown.If you’re working with .ipynb files, see the cell tags guideon adding cell tags to notebooks in Jupyter Notebook or JupyterLab.

If an element is hidden, Jupyter Book will display a small button to the right of theold location for the hidden element. If a user clicks the button,the element will be displayed.

Hide cell inputs¶

If you add the tag hide-input to a cell, then Jupyter Book will hide the cell butdisplay the outputs.

Here’s an example of cell metadata that would trigger the “hide code” behavior:

For example, notice the cell below contains the hide-input tag:

Note how we only see the output by default. Now try clicking the buttonto the right of the empty spot above!

Hide cell outputs¶

You can also hide the outputs of a cell. For example, if you’d like to ask users tothink about what the output will look like first before viewing an answer. To do so,add the following tag to your cell:

Hide entire code cells¶

If you’d like to hide the whole code cell (both inputs and outputs) just add thistag to the cell metadata, like so:

Removing code cell content¶

In the above examples, we are only hiding parts of the cell, with the optionthat readers can reveal them if they wish. However, if you’d like to completely removethe respective parts, so that their contents do not make it into the book’s HTML, you mayuse the appropriate remove- tags, i.e. remove-input, remove-output and remove-cell.

Remove cell inputs¶

Jupiter Notebook Markdown Guide

The following cell has its inputs removed with remove-input. Note that inthis case, there is no button available to show the input contents,the entire input cell is gone!

Remove cell outputs¶

Similar to hiding inputs, it is also possible to hide the outputsof a cell with remove-output:

Remove an entire code cell¶

You can also remove both the inputs and outputs of a cell, in which case itwon’t show up in your book at all. These cells remain in the notebook file itself,so they’ll show up if readers click on a JupyterHub or Binder link from a page.

To remove both the inputs and outputs of a cell, add the tag remove-cell to the tagsof the cell. Here’s an example of cell metadata that would trigger the “remove cell” behavior:

These cells will be entirely removed from each book page - remember that if you’d like tooptionally display the inputs of a cell instead, you should use the hide-input tag.

For example, there’s a cell below this text that won’t make it into the final book,because it has been removed!

Remove empty cells¶

Jupiter Lab Markdown Cheat Sheet Pdf

You don’t need to do anything to remove empty cells from your pages.Jupyter Book will remove these automatically. Any cell with onlywhitespace will be removed.

For example, in the notebook for this page there are two cells above this text.Both only contain whitespace. Both are gone fromthe final output.

LaTeX is a typesetting language for producing scientific documents. We introduce a very small part of the language for writing mathematical notation. Jupyter notebook recognizes LaTeX code written in markdown cells and renders the symbols in the browser using the MathJax JavaScript library.

Mathematics Inline and Display

Enclose LaTeX code in dollar signs $ ... $ to display math inline. For example, the code $int_a^b f(x) = F(b) - F(a)$ renders inline as $ int_a^b f(x) dx = F(b) - F(a) $.

Enclose LaTeX code in double dollar signs $$ ... $$ to display expressions in a centered paragraph. For example:

renders as

$$f'(a) = lim_{x to a} frac{f(x) - f(a)}{x-a}$$

See the LaTeX WikiBook for more information (especially the section on mathematics).

Common Symbols

Below we give a partial list of commonly used mathematical symbols. Most other symbols can be inferred from these examples. See the LaTeX WikiBook (Mathematics) and the Detexify App to find any symbol you can think of!

SyntaxOutput
$x_n$$x_n$
$x^2$$x^2$
$infty$$infty$
$frac{a}{b}$$frac{a}{b}$
$partial$$partial$
$alpha$$alpha$
$beta$$beta$
$gamma$$gamma$
$Gamma$$Gamma$
$Delta$$Delta$
$sin$$sin$
$cos$$cos$
$tan$$tan$
$sum_{n=0}^{infty}$$sum_{n=0}^{infty}$
$prod_{n=0}^{infty}$$prod_{n=0}^{infty}$
$int_a^b$$int_a^b$
$lim_{x to a}$$lim_{x to a}$
$mathrm{Hom}$$mathrm{Hom}$
$mathbf{v}$$mathbf{v}$
$mathbb{Z}$$mathbb{Z}$
$mathscr{L}$$mathscr{L}$
$mathfrak{g}$$mathfrak{g}$
$dots$$dots$
$vdots$$vdots$
$ddots$$ddots$

Matrices and Brackets

Create a matrix without brackets:

$$begin{matrix} a & b c & d end{matrix}$$

Create a matrix with round brackets:

$$begin{pmatrix} a & b c & d end{pmatrix}$$

Create a matrix with square brackets:

$$begin{bmatrix}1 & 2 & 1 3 & 0 & 1 0 & 2 & 4end{bmatrix}$$

Use left and right to enclose an arbitrary expression in brackets:

$$left( frac{p}{q} right)$$

Jupiter

Jupyter Lab Markdown Preview

Examples

Derivative

The derivative $f'(a)$ of the function $f(x)$ at the point $x=a$ is the limit

$$f'(a) = lim_{x to a} frac{f(x) - f(a)}{x - a}$$

Jupyter Notebook Markdown Cheat Sheet

Continuity

A function $f(x)$ is continuous at a point $x=a$ if

$$lim_{x to a^-} f(x) = f(a) = lim_{x to a^+} f(x)$$

MacLaurin Series

Markdown

The MacLaurin series for $e^x$ is

$$e^x = sum_{k=0}^{infty} frac{x^k}{k!}$$

Jacobian Matrix

The Jacobian matrix of the function $mathbf{f}(x_1, dots, x_n)$ is

$$mathbf{J} = frac{d mathbf{f}}{d mathbf{x}} =left[ frac{partial mathbf{f}}{partial x_1}cdots frac{partial mathbf{f}}{partial x_n} right] =begin{bmatrix}frac{partial f_1}{partial x_1} & cdots & frac{partial f_1}{partial x_n} vdots & ddots & vdots frac{partial f_m}{partial x_1} & cdots & frac{partial f_m}{partial x_n}end{bmatrix}$$

Exercises

  1. Write LaTeX code to display the angle sum identity

    $$cos(alpha pm beta) = cos alpha cos beta mp sin alpha sin beta$$

  2. Write LaTeX code to display the indefinite integral

    $$int frac{1}{1 + x^2} , dx = arctan x + C$$

  3. Write LaTeX code to display the Navier-Stokes Equation for Incompressible Flow

    $$frac{partial mathbf{u}}{partial t} + (mathbf{u} cdot nabla) mathbf{u} - nu nabla^2 mathbf{u} = - nabla w + mathbf{g}$$

  4. Write LaTeX code to display Green's Theorem

    $$oint_C (L dx + M dy) = iint_D left( frac{partial M}{partial x} - frac{partial L}{partial y} right) dx , dy$$

  5. Write LaTeX code to display the Prime Number Theorem

    $$lim_{x to infty} frac{pi(x)}{ frac{x}{log(x)}} = 1$$

  6. Write LaTeX code to display the general formula for Taylor series

    $$sum_{n=0}^{infty} frac{f^{(n)}(a)}{n!} (x-a)^n$$

  7. Write LaTeX code to display Stokes' Theorem

    $$int_{partial Omega} omega = int_{Omega} d omega$$

  8. Write LaTeX code to display the adjoint property of the tensor product

    $$mathrm{Hom}(U otimes V,W) cong mathrm{Hom}(U, mathrm{Hom}(V,W))$$

  9. Write LaTeX code to display the definition of the Laplace transform

    $$mathscr{L} { f(t) } = F(s) = int_0^{infty} f(t) e^{-st} dt$$

  10. Write LaTeX code to display the inverse matrix formula

    $$begin{bmatrix} a & b c & d end{bmatrix}^{-1} = frac{1}{ad - bc} begin{bmatrix} d & -b -c & a end{bmatrix}$$

  11. Write LaTeX code to display the infinite product formula

    $$sin x = x prod_{n=1}^{infty} left( 1 - frac{x^2}{pi^2 n^2} right)$$

  12. Pick your favourite math course and write the notes from your last class in LaTeX.