Getting Started with Markdown in JupyterLab

Overview of JupyterLab

JupyterLab is an IDE which is browser based.

File Explorer

Select the folder you want on the left left hand side menu. In this case Documents. Compatible files can be opened using this left hand side menu.

To the right hand side a Launcher is opened as a tab to the right hand side. From the launched we can create a new Text File, Markdown File or new Notebook.

File Types

Text File

From the launcher select Text File:

A new text file called untitled.txt will be opened. Note that this is automatically saved to the Documents folder which is the directory opened to the left hand side:

The file can be renamed by right clicking the tab or the file name within the File Explorer and selecting rename:

In this case I will rename it TestText.txt:

The file is renamed. A new tab can be created by opening another file or adding an additional launcher:

Markdown File

Let's have a look at a MarkDown File. This is essentially a Report File. It acts like a Text File but the Text can be formatted.

Select Markdown File:

Then right click an empty space in the file and select Show Markdown Preview:

The file name can be renamed by right clicking the tab and selecting rename:

Then inputting the desired name and then selecting Rename:

The file is now renamed:

NoteBook File

A NoteBook file consists of a series of cells that can be MarkDown, Code or Raw (Text). Open a new Launcher and select a new Python 3 Notebook:

The currently selected cell is highlighted in Blue to the left hand side. In this case I will set the cell to a MarkDown cell and create a Heading:

Then Run:

When I run this the cell displays as a heading (it can be edited again by double clicking it).

A new cell is created, this time I will leave it as Code. The Code can be ran:

When the code is ran a number displays denoting the order the cells were ran in. This is important when cells are dependent on earlier cells. For example if we create other cells:

The Code cells can be ran in any order i.e. it doesn't need to be ran from top to bottom however if the code of one cell requires the code to run in another cell before hand for example in the case of variable assignment errors will display:

If the assignment code cell is ran before the display code cell, the code works:

Code in the cells can be modified and ran again.

In this case we are asking to display a lot of data. We can right click the left hand side bar of the cell which is highlighted blue and we can enable or disabling scrolling for the output cell:

We can create x and y data and test plotting using the same code as we used in Spyder 4. JupyterLab (without plugins) plots figures inline i.e. making them images:

The cell that creates the inline figure can be reran to update the figure however:

Typing a [↹] gives auto-complete options:

Typing [⇧]+[ ↹ ] will give the docstring which gives more details about the input arguments of a function:

Mark Down Syntax

Headings

Text beginning with a hash # will be assigned to a heading. The number of hashes used will represent the level of heading.

# Heading 1
## Heading 2
### Heading 3
#### Heading 4

The heading level can be observed in the markdown preview. The table of contents can be opened to the left hand side and each Heading can be accessed as a link which will take the user to the relevant heading in both the markdown file and markdown preview.

Note it is recommended to leave a new line after each heading or paragraph. This does not display in the Markdown preview.

Separators

Three dash – keys can be used for a separator.

---

Bold, Italic, Bold Italic and Strike Through

Text can be formatted by use of the star * key. The number of stars used to enclose the text will set it to a different format:

*italic text*
**bold text**
***bold and italic text***

Text enclosed in two tilde ~ is strike through.

~~strike through text~~

Code

Text enclosed in three graves ` is code.

Code can either be inline:

Type in ```print("hello")``` to print hello.

Or display code can be made using a code block:

```

```

Note lines beginning with # within the code block are commented out code lines and not recognised as headings using the markdown syntax.

```
# Code Block
var = "hello"
print(var)
```

Lists

Starting text with a * can also be used to create a list. Note the item should only have one * before the text and not be enclosed in * which would make the text italic.

For Single Spacing and Bullet Points

* apples
* bananas
* grapes

For Double Spacing and Bullet Points

* apples

* bananas

* grapes

For Single Spacing and Numeric

1. apples
2. bananas
3. grapes

For Double Spacing and Numeric

1. apples

2. bananas

3. grapes

Equations

The $ is used to enclose LaTex equations. One $ is used to enclose an inline equation and two $$ are used to enclose a display equation.

It is out of the scope of this tutorial to give a LaTex overview. An equation will be copied to TeX using the Word Equation Editor.

The inline equation is $\left(1+x\right)^n=1+\frac{nx}{1!}+\frac{n\left(n-1\right)x^2}{2!}+\ldots$.
$$\left(1+x\right)^n=1+\frac{nx}{1!}+\frac{n\left(n-1\right)x^2}{2!}+\ldots$$

Tables

The pipe | is used to create columns in a table. The zeroth row is used for the column names and the first row is used to specify the formatting of each column.

The format specifier :-: can be used to center align the columns.

|Fruits|Vegetables|Grains|Drinks|
|:-:|:-:|:-:|:-:|
|Apple|Broccoli|Porridge|Water|
|Banana|Cabbage|Flower|Tea|
|Grape|Spinach|Rice|Coffee|

The format specifier :- can be used to left align the columns.

|Fruits|Vegetables|Grains|Drinks|
|:-|:-|:-|:-|
|Apple|Broccoli|Porridge|Water|
|Banana|Cabbage|Flower|Tea|
|Grape|Spinach|Rice|Coffee|

The format specifier :- can be used to right align the columns.

|Fruits|Vegetables|Grains|Drinks|
|-:|-:|-:|-:|
|Apple|Broccoli|Porridge|Water|
|Banana|Cabbage|Flower|Tea|
|Grape|Spinach|Rice|Coffee|

The format specifier — can be used to left align the columns with centred column titles.

|Fruits|Vegetables|Grains|Drinks|
|---|---|---|---|
|Apple|Broccoli|Porridge|Water|
|Banana|Cabbage|Flower|Tea|
|Grape|Spinach|Rice|Coffee|

A link or image can be inserted using a set of square brackets [ ] which will contain the name of the link, followed by a set of round brackets ( ) which contain the path.

 [Python Guides](https://dellwindowsreinstallationguide.com/python/)

An image can also be represented in the same manner and displayed as a link:

[Anaconda PowerShell Prompt](https://i1.wp.com/dellwindowsreinstallationguide.com/wp-content/uploads/2021/05/conda1.png?ssl=1)

If the image is to be displayed as part of the document. The square brackets should be prepended with an exclamation mark !

![Anaconda PowerShell Prompt](https://i1.wp.com/dellwindowsreinstallationguide.com/wp-content/uploads/2021/05/conda1.png?ssl=1)

Images can also be embedded that are in the same folder as the notebook. The file names should not include any spaces or special characters (except the underscore _). For example, if the file markdown_preview.png is stored in the same folder as the notebook it can be displayed using:

![Markdown Preview](markdown_preview.png)