Inserting LaTex in a notebook

This notebook illustrates how to insert LaTex in the Markdown and Python code sections of your notebook.

If you need to include LaTex in your Markdown, you will need to surround the LaTex formatted code with either single dollar symbols $...$ or double dollar symbols $$...$$.

Single dollar symbols will display the LaTex inline like this: $c = \sqrt{a^2 + b^2}$ with text on both sides of the LaTex if needed.

Double dollar symbols will display the LaTex on a line of its own like this $$c = \sqrt{a^2 + b^2}$$ even if you include it within a line of text.

Obviously you also need to learn the LaTex format. There are many websites containing lists of LaTex symbols. For example, see LaTex Math Symbols.

Display LaTex from code cell

It is also possible to display LaTex from inside a code cell as shown below:

In [1]:
from IPython.display import display, Math, Latex
display(Math(r'c = \sqrt{a^2 + b^2}'))

import math

a = 3
b = 4
c = math.sqrt(a**2 + b**2)
print('a =',a)
print('b =',b)
print('c = ',c)
$$c = \sqrt{a^2 + b^2}$$
a = 3
b = 4
c =  5.0

More LaTex examples

A few more examples of embedding LaTex in Markdown are provided below.

Greek letters such as $\alpha$, $\beta$, and $\delta$ are often included in mathematical expressions.

Sometimes we need to compute the nth root of a value as in $\sqrt[n]{\beta^2 + \gamma^2}$.

The integration symbol $\int$ often appears in mathematical expressions for integral calculus.

When we do numeric integration with a computer, we often replace the integration symbol $\int$ with a summation symbol $\sum$.

Housekeeping material

Author: Prof. Richard G. Baldwin

Affiliation: Professor of Computer Information Technology at Austin Community College in Austin, TX.

File: Latex01.html

Revised: 09/04/18

Copyright 2018 Richard G. Baldwin