avatarKhelifi Ahmed Aziz

Summary

The provided web content is a comprehensive guide on how to write Markdown and LaTeX in the Jupyter Notebook environment, emphasizing their utility in creating interactive documents with code, visualizations, and formatted text.

Abstract

The article "Learn How to Write Markdown & LaTeX in The Jupyter Notebook" serves as an extensive tutorial for users looking to enhance their interactive notebook experience. It introduces Markdown as a simple language for formatting text in Jupyter Notebooks and Google Colab, detailing how to create headings, paragraphs, lists, and other text elements. The guide also covers LaTeX integration within these notebooks, facilitated by MathJax, to render complex mathematical equations and symbols, which is particularly useful for teaching and documenting scientific research. The author provides examples and HTML equivalents for various Markdown and LaTeX notations, demonstrating how to insert links, images, tables, code blocks with syntax highlighting, and special symbols. Additionally, the article offers resources for further learning and encourages readers to explore the capabilities of Jupyter Notebooks and LaTeX for their documentation and data analysis needs.

Opinions

  • The author recommends Jupyter Notebook and Google Colab for their powerful and shareable interactive document capabilities.
  • Markdown is presented as a user-friendly markup language that simplifies HTML coding for web developers and other users.
  • LaTeX is highlighted as an essential tool for writing complex math and physics equations, with the Jupyter Notebook's use of MathJax praised for its rendering capabilities.
  • The article suggests that interactive notebooks are a great teaching environment and are gaining popularity due to their ability to combine live code, visualizations, and narrative text.
  • The author provides a subjective endorsement for a cost-effective AI service, ZAI.chat, as an alternative to ChatGPT Plus (GPT-4), indicating a belief in its value for users interested in such technologies.
  • The use of tablesgenerator.com is recommended for easily generating Markdown tables, showcasing the author's preference for this tool.
  • The inclusion of numerous examples and screenshots throughout the article demonstrates the author's commitment to providing a clear and practical learning resource for readers.

Learn How to Write Markdown & LaTeX in The Jupyter Notebook

Not only Jupyter. Google Colab, R Markdown, and much more.

Background by JESHOOTS.COM on Unsplash

Interactive notebooks are experiencing a rise in popularity. Why? Simply because it’s a great teaching environment, powerful, shareable, and provides the ability to perform data visualization in the same environment. Which interactive notebooks should I use? I recommend:

  • The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations, and narrative text.
  • Colaboratory is a free Jupyter notebook environment that requires no setup and runs entirely in the cloud.

Both of them support

  1. Markdown which is a markup language that is a superset of HTML.
  2. Latex to render mathematical and scientific writing.

Markdown

It’s a very simple language that allows you to write HTML in a shortened way. It can be used on some websites like Stack Overflow or to write documentations (essentially on GitHub).

Markdown file extension is .md

When you write in Markdown, you use shortened notations which are replaced by the corresponding HTML tags. Each time, I will tell you the HTML equivalent of the Markdown notation to show you how Markdown made our life easier than ever.

Even web developers, now, use Markdown then convert it to HTML using some websites.

• Headings

You make titles using hashtags #. A single hashtag gives you a title (h1), two hashtags give you a subtitle (h2) and so on as shown below:

# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6

HTML equivalent:

• Paragraphs

Paragraphs are represented by the <p> tag in HTML. In Markdown, they’re separated by one or more blank lines. Like HTML, whitespace is ignored. So if you add 10 blank lines, you’re still only going to have one paragraph.

This is a paragraph of text.
This is another paragraph of text.

HTML equivalent:

• Line breaks

Just end a line with two or more spaces , then type return. Or leave an empty line.

This is a text.     <!-- spaces -->
This is another text.

HTML equivalent:

• Mark emphasis

You can add emphasis by making text bold or italic.

Emphasis, aka italics, with *asterisks* or _underscores_.
Strong emphasis, aka bold, with **asterisks** or __underscores__.
Combined emphasis with **asterisks and _underscores_**.
Strikethrough uses two tildes ~ . ~~Scratch this.~~

HTML equivalent:

• Lists

Creating lists in Markdown is a real pleasure, you will see that there is nothing simpler!

1. Item 1
2. Item 2 ( we can type 1. and the markdown will automatically numerate them) 
* First Item
  * Nested item 1
  * Nested item 2
    1. Keep going
    1. Yes
  
* Second Item
- First Item
- Second Item

HTML equivalent:

• Links and Images

To create a link, you must place the text of the link in square brackets followed by the URL in parentheses. Images are almost inserted in the same way as links, add an exclamation mark (!), followed by alt text in brackets, and the path or URL to the image asset in parentheses.

<!-- [Text](link) -->
[Link Text](https://medium.com/@ahmedazizkhelifi "Optional Title")
<!-- ![Alt Text](image path "title") -->
![Alt Text](https://miro.readmedium.com/max/80/0*PRNVc7bjff0Jj1pm.png "Optional Title")
<!-- Linking Image -->
<!-- [![Alt Text](image path "title")](link) -->[![Alt Text](https://miro.readmedium.com/max/80/0*PRNVc7bjff0Jj1pm.png "Optional Title")](https://medium.com/@ahmedazizkhelifi)

HTML equivalent:

• Horizontal Rule

To create a horizontal rule, use three or more asterisks (***), dashes (---), or underscores (___) on a line by themselves.

Reading articles on Medium is awesome.
---
Sure !!

HTML equivalent:

• Table

It’s so freaking easy. And you can use this website to generate them. Use \ before the dollar signs $, on your Notebook, otherwise, you’ll enter the math display mode (check it out on the LaTeX side).

| Id | Label    | Price |
|--- |----------| ------|
| 01 | Markdown |\$1600 |
| 02 | is       |  \$12 |
| 03 | AWESOME  | \$999 |

HTML Equivalent:

• Code and Syntax Highlighting

```python
def staySafe(Coronavirus)
  if not home:
    return home
```

HTML Equivalent:

• Blockquotes

Blockquotes work like replies to e-mails: you must precede the quoted lines with a >.

> This is a blockquote.
>  
> This is part of the same blockquote.
Quote break
> This is a new blockquote.

HTML Equivalent:

LaTeX

Have you ever asked yourself, how they write complex maths and physics equations using computer? Well, it’s all about LaTeX.

The Jupyter Notebook uses MathJax to render LaTeX inside HTML / Markdown. Just put your LaTeX math inside $ $. Or enter in display math mode by writing between$$ $$.

Output Result: Colab Notebook

Important Notes:

  1. To add little spacing in math mode use \,
  2. To add a new line when in math mode use \\
  3. To display fraction use \frac{arg 1}{arg 2}
  4. For power (superscripts text) use ^{}
  5. For indices (subscripts) use _{}
  6. For roots use \sqrt[n]{arg} The [n]is optional.
Output Example: Colab Notebook

LaTeX file extension is .tex

• Greek Letters

To write greek letters, type \ and the letter name:

Output Result: Colab Notebook

Important Note: To write Capital Greek Letter, type the first case after the backslash \as an uppercase, for example:

\delta >>> δ 
\Delta >>> Δ
\omega >>> ω
\Omega >>> Ω
Output Example: Colab Notebook

As shown in this figure:

Full Greek Letter List. Source

• Roman Names:

Output Result: Colab Notebook
Source

• Other Symbols

Output Result: Colab Notebook
Sets and Logic: Source
Arrows: Source
Other Symbols: Source

• Vertical curly braces:

To define a left vertical curly brace we use the attribute

\left\{

to close it we use

\right\}
Output Result: Colab Notebook

• Horizontal curly braces

For horizontal curly braces, we use :

\underbrace{...}
\overbrace{...}
Output Result: Colab Notebook

• Derivative

Output Result: Colab Notebook

• Limit

Output Result: Colab Notebook

• Sum

Output Result: Colab Notebook

• Product

Output Result: Colab Notebook

• Integral

Output Result: Colab Notebook

• Matrix

Output Result: Colab Notebook

Resources:

Thanks For Reading! 😄

Check out my other articles and follow me on Medium

Khelifi Ahmed Aziz

Data Science
Jupyter Notebook
Markdown
Latex
Math
Recommended from ReadMedium