Jupyter Markdown Latex

Posted on  by admin

Jupyter Notebook is a great tool for data analysis. And one of its greatest features is that you can easily combine runnable code with rich-text annotations. Markdown cells that contain such annotations support both HTML and Markdown syntax.

  1. Learn how to install, run and use R with Jupyter Notebook and RStudio's R Notebook, including tips and alternatives.
  2. Collaborative Calculation and Data Science.
  3. This extension for Jupyter notebook enables the use of some LaTeX commands and environments markdown cells. LaTeX commands and environments support for some LaTeX commands within markdown cells, e.g. Textit, textbf, underline. Support for theorems-like environments, support for labels and cross references.
Jupyter notebook markdown

Personally I prefer # Header (markdown syntax) to <h1>Header</h1> (HTML syntax) in my notebook’s cells as the former looks more human. So I use markdown syntax more often and a concise cheat sheet for Jupyter Notebook markdown is what I was missing for a long time. Yes, I’m aware of such comprehensive cheat sheets like this and this, they are great but too verbal and it’s hard to print them on one page to have it easily accessible.

Eventually, I decided to gather all crucial points of the markdown syntax that are actual for Jupyter notebook and combine them in a concise cheat sheet that I present to you. It doesn’t explain much but should be useful if you simply forgot something. Click the picture to download the PDF version.

I didn’t get into the details of LaTeX syntax (see the penultimate cell in the cheat sheet with the square root of k) since it’s well described here (get ready, it’s a very long document) and you can even download a pretty good cheat sheet here.

An online LaTeX editor that's easy to use. No installation, real-time collaboration, version control, hundreds of LaTeX templates, and more.

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)$$

Examples

Derivative

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

Jupyter Markdown Latex

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

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

The MacLaurin series for $e^x$ is

Latex Markdown Jupyter Notebook

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

Jacobian Matrix

Jupiter Markdown Latex Mattress

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

Jupiter Markdown Latex Free

  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.