2.2. Text Cells#

Text Cells are cells that contain Markdown. Markdown is a markup language that is used to format text. In this section, we are going to look at different formatting options to make our text more structured and user-friendly.

To add a Text cell:

  1. Choose the +Text button in the top toolbar colab-text

  2. This will add the text cell in your Jupyter Notebook. Double-click on the cell and start typing your Markdown. There is a display panel on the right-hand-side that shows the output of your Markdown which is very helpful.

  3. To stop editing the Text cell, click on the Close markdown editor button colab-close-text-editor that is present on the top tight-hand-side of the cell menu.

Let’s start looking at how to use Markdown below.

2.2.1. Headings#

Below is the Markdown code you need to use to specify headings at different levels and the rendered output respectively below the code:

# Heading 1

Heading 1

## Heading 2

Heading 2

### Heading 3

Heading 3

#### Heading 4

Heading 4

2.2.2. Inline text formatting#

To make text bold use **double asterisks** or __double underscores__.
To make text italic use *asterisks* or _underscores_.
To make text ^superscript^ use ^caret^.
To make text ~subscript~ use ~tilde~.
To mark text as inline code use `backticks`.
To ~~strikethrough~~ text use ~~double tilde~~.

2.2.3. Line breaks#

To create a line break, put more than 2 spaces at the end of a sentence.

Exercise 2.1 (Markdown in Jupyter Notebook)

Level:

Replicate the output of the text below in a new Jupyter Notebook notebook2. notebook_exercise1 The text comes from a paper by Monya Baker that was published in 2016 in the Nature journal that triggered the discussion about Reproducibility Crisis.

2.2.5. Footnotes#

To indicate a footnote use[^2]. Indicate additional footnotes using other numbers as follows [^3], then specify the wordings of the footnotes as:

[^2]: This is the first footnote.
[^3]: This is the second footnote.

You do not need to put footnotes at the end of the document for them to be rendered there. This example is rendered as follows:

To indicate a footnote use[2]. Indicate additional footnotes using other numbers as follows[3], then specify the wordings of the footnotes as:

2.2.6. Lists#

Ordered lists#

To create an ordered list use the following syntax:

1. Item 1
2. Item 2
3. Item 3

This is rendered as:

  1. Item 1

  2. Item 2

  3. Item 3

Use 4 spaces to indent an item if you would like to have sub-lists:

1. Item 1
2. Item 2
3. Item 3  
    a. Item 3a  
    b. Item 3b  
    c. Item 3c  
4. Item 4
  1. Item 1

  2. Item 2

  3. Item 3
    a. Item 3a
    b. Item 3b
    c. Item 3c

  4. Item 4

Unordered lists#

In an unordered bulletted list, each item begins with *, + or -. Example:

* Item 1
* Item 2
* Item 3
    * Item 3a
        * Item 3ai
        * Item 3aii
    * Item 3b
    * Item 3c
* Item 4

Will be rendered as:

  • Item 1

  • Item 2

  • Item 3

    • Item 3a

      • Item 3ai

      • Item 3aii

    • Item 3b

    • Item 3c

  • Item 4

2.2.7. Inserting images#

To insert an image use the following syntax: ![alternative text](path_to_image). Example:

![Jupyter Logo](images/jupyter.png)

Will be rendered as:

Jupyter Logo

Exercise 2.2 (More Markdown)

Level:

Continue working on notebook2.ipynb from Exercise 2.1. Extend the output of notebook2.ipynb to look like this.

You can find the image used in this exercise at this location: https://www.nature.com/news/polopoly_fs/7.36716.1469695923!/image/reproducibility-graphic-online1.jpeg_gen/derivatives/landscape_630/reproducibility-graphic-online1.jpeg

More information about Markdown is provided here. Let us now look at code cells.