Jupyter Notebook supports a type of writing language called Markdown. It is a simple way of creating nice looking documents with a small number of commands to remember. This language is particularly good for typesetting mathematical equations, which is our main reason for using it.
When you first open a new Jupyter notebook you will be greeted with a code box that looks like this:
If you want to use the notebook for code- that's great! Start typing commands. If however, you are using the notebook for writing then you need a different box- a text box. Click on the code box, and click on the 'Cell' menu at the top of the screen. From there select 'Cell type' and click 'Markdown'.
You will notice that the square bracket to the left of the cell has disappeared, meaning we now have a text box to write in:
(note that you can shortcut this process by typing "m" for "Markdown" when the box is highlighted)
Now, click in the cell, (its border will turn green) a cursor will appear and you can type anything you like:
Now, you will notice that the text looks a little different from the font I am using here. That's because you're editing the source code, and it has not yet been rendered. In order to see what the finished product will look like, click the 'play' button, click 'Cell > Run Cell' or type 'Ctrl-Enter', and hopefully you will see:
To edit the text in the cell, simply double click it again. You can make changes, and then click the 'play' button, click 'Cell > Run Cell' or type 'Ctrl-Enter' again to see your changes.
To make text bold enclose it between two asterisks:
** bold **
Or to italicise, use one asterisk
* italics *
(This also works in whatsapp by the way)
You can make bulleted lists using asterisks:
to mark each point
* bullet 1
* bullet 2
You make titles using hashtags. A single hashtag gives you a title, two hastags gives you a subtitle and so on as shown below:
# Title
## Subtitle
### SubSubtitle
You can include links to external pages and you can embed images
and a whole load of other things. There is a handy cheat sheet available here to help you remember the key commands.
The way that Markdown handles mathematics is via another 'language' called 'Latex' (Pronounced 'lay-tek', and more commonly written $\LaTeX$). $\LaTeX$ is a whole other world of writing and is used every day by thousands of academics and publishers as it provides a very flexible and customisable way of rendering documents. If you google 'Fun things to do with Latex' (actually, don't do that...) you'll probably find a whole host of rather intimidating looking pages. However, we only need a very few basic features at this stage.
In order to enter mathematical formulae using latex you need to enclose them in dollar (\$) signs, like this:
$ 1+1=2 $
$1+1=2$
If you want to place an important equation centered on its own line use two dollar signs:
$$ 2+2=4 $$
You can see that the font is different and the spacing is all taken care of properly, but $\LaTeX$ can do so much more...
$\LaTeX$ has a load of commands for rendering mathematical symbols and formulae, that all start with a backslash "\", and then take arguments in curly braces "{}". For instance if I want to write the fraction "one-half", I can write
$ \frac{1}{2} $
$\quad \Longrightarrow \quad \frac{1}{2}$
where the command \frac
is the command for a fraction, the number in the first curly brace {1}
is the numerator and the second {2}
is the denominator. And I can make more complicated fractions by putting whatever I want in the braces:
$ \frac{x^2+3y-z}{\sin (4 \omega _0 x)} $
$\quad \Longrightarrow \quad \frac{x^2+3y-z}{\sin (4 \omega _0 x)}$
where you can see I've used the commands \sin
and \omega
and also the ^
and _
characters to make superscripts and subscripts.
I can make sums and integrals :
$ \sum \limits _{i=1} ^{10} \int \limits _0 ^{\infty} e^{\nu _i x } dx $
$\quad \Longrightarrow \quad \sum \limits _{i=1} ^{10} \int \limits _0 ^{\infty} e^{\nu _i x } dx$
and even matrices and vectors (although these are a bit more fiddly- google Latex arrays for an explanation of how this works)
$$ \left( \begin{array}{cc} 1 & 2 \\ 3 & 4 \end{array}\right)
\left( \begin{array}{c} 5 \\ 6 \end{array} \right) =
\mathbf{\underline{V}}$$
In general, you can do any greek letter:
\alpha, \beta, \gamma, \pi, \theta, \Theta
$\quad \Longrightarrow \quad \alpha, \beta, \gamma, \pi, \theta, \Theta$
mathematical function
\sqrt{x+y}, \log, \ln, \sin, \cos, \tan, \sec, \sinh
$\quad \Longrightarrow \quad \sqrt{x+y}, \log, \ln, \sin, \cos, \tan, \sec, \sinh$
relation
\leq, \geq, \approx, \equiv, \neq, <, >
$\quad \Longrightarrow \quad \leq, \geq, \approx, \equiv, \neq, <, >$
you can do accents like dots and bold face:
\dot{x}, \mathbf{M}, \underline{v}
$\quad \Longrightarrow \quad \dot{x}, \mathbf{M}, \underline{v}$
the sky is the limit. Of course, you don't need to memorize all of the commands- just keep this reference handy and as long as you know how to put the commands together, you have all that you need to make beautiful looking mathematics in all of your reports.