© Copyright 2016 Dr Mike Croucher and Dr Marta Milo
Using the Jupyter Notebook as a Word Processor
In this notebook we will list a set of basic formatting commands that helps when using markdown cells as Word processor. It will be useful when adding text to your data analysis and also for sharing the notebook in collaborative projects.
Markdown
It is possible to use the notebook as a wordprocessor by making use of Markdown Cells.
Markdown is a very simple language that allows you to format your text in your notebook. It is used in many research projects around the world and it represents an ideal tool for data sharing. As well as the Jupyter notebook, another very important project that uses Markdown to format text is the github code-sharing site. SageMathCloud is also making use of github for the code-sharing and file management. Markdown, being a language, has its own syntax to implement the formatting of the text. In this brief document we list some commonly used syntax for basic text formatting.
Bold and italics
Unlike word processors such as Microsoft Word, you do not highlight text and click on something to change its format. Instead, you use the Markdown syntax to tell the computer how to format your text.
If you want some text to appear in bold, you surround it with two asterisks like this:
the result format will be:
This will be bold
If you want the text to be in italics, you surround it in just one asterisk
the result format will be: This will be in italics
Lists
We often create lists in our text, as bullet points or as numbered items.
If we want to create bullet point lists, we can do so in markdown by putting an asterisk and a space in front of each item like this:
the resulting format will be:
item1
item2
item3
To create nested lists add 4 spaces to the beginning of each line to indent it by one level. Add 8 spaces to indent by two levels like in the example below:
the resulting format will be:
item1
item1a - This has 4 spaces before the *
item1b
This has 8 spaces before the *
item2
Finally to create a numbered list, you need to number the first entry and use asterisks for the other entries.
First
Second
Third
Markdown does not support numbered nested lists. If you want to create nested indented lists, you can use the 4 spaces indentation and numbered list, like in the example below:
The result of the formatting is:
Dog
German Shepherd
Belgian Shepherd
Malinois
Groenendael
Tervuren
Cat
Siberian
Siamese
Mathematics
You can also use mathematical notation in markdown. Within a markdown cell, something surrounded in $
or $$
, is considered as an equation. You write equations using a language called (pronounced 'lay-tek' since the X is really a Greek letter chi).
Don't worry, you don't need to learn very much of this language - most people only need to learn a tiny number of commands. Here are some examples:
Superscript
Commonly used for powers. You use the ^
symbol
Subscript
One use for subscipts is in chemical forumlae:
Fractions
Fractions are a little more complicated. We use the form \frac{numerator}{denominator}
\frac
is a command and all such commands start with a \
Square root
We need another command \sqrt
. The argument to the square root function is put in curly brackets
Sums
To sum a quantity N times we can use
the result will be:
Products
To multiply a quantity n times we can use
the results will be:
Integrals
Integral notaton can be written using the following command:
the result will be:
or we can use integral notation, without upper or lower limits, with the following command:
the result will be:
Web links
Web links such as http://www.walkingrandomly.com/ become clickable when the Markdown code is evaluated so just type them in.
If you want to turn a piece of text into a weblink, you surround it in square brackets and put the web adress after it in round brackets. Like this:
Images
If the image is online, you use syntax that's very similar to a link but with a ! in front of it
Alternatively, you can put an image in the same folder as your notebook and link to it like this:
Tables
You can create tables in Markdown cells by doing something like this:
This produces the output
Column A | Column B |
---|---|
Row 1 | 1.0 |
Row 2 | 2.0 |
In practice, you'll rarely do this as you'll generate your tables using the R programming language.