Markdown Guide

What is Markdown?

Markdown is a lightweight, plain-text formatting language designed to create readable and easy-to-write documents that can be converted into HTML, PDF, EPUB and many other formats. It was created by John Gruber in 2004. By using simple syntax rules to format text, Markdown is accessible and easy to read. It is used to make writing for the web and other platforms more straightforward while ensuring the source text remains legible.

What is Markdown Used For?

  • Writing Documentation: For software projects, websites, or knowledge bases.
  • Note-Taking and Journaling: Platforms like Obsidian and Notion support Markdown.
  • Content Creation: Blogging, writing articles, or creating ebooks.
  • Version Control Collaboration: Used in README files and documentation on GitHub and GitLab.
  • Online Forums and Platforms: Many forums, such as Reddit, use Markdown for formatting comments and posts.

Basic Syntax

A Note about Whitespace and New Lines

The way Markdown handles whitespace can take some getting used to. If we simply hit return once, the rendered Markdown won’t create a new line (unless the line is a heading). To create a new line, we need to add two spaces and then hit return. If you want a new paragraph, then just hit return twice.

Headings

Markdown uses hashtags # to create headings. The number of hashtags corresponds to the heading level. These correspond to the HTML headings <h1>, <h2>, <h3>, ..., <h6>

For example,


# This is my top level heading

Here's an overview of this section. 

## This is a sub-heading

### This is a sub-sub-heading

Here’s what that looks like rendered:

–

This is my top level heading

Here’s an overview of this section.

This is a sub-heading

Some text about this sub-heading.

This is a sub-sub-heading

Some more text.

–

Bold and Italics

You can enclose text in a * or _ to make bold or italics text.

  • **bold** gives us bold
  • italics gives us italics

Lists

We can make unordered lists by starting a line with a - or a *. Tab or indent two spaces to create a nested list

- list item 1
	- list item 1.1
	- list item 1.2
- list item 2
- list item 3

This would give us

  • list item 1
    • list item 1.1
    • list item 1.2
  • list item 2
  • list item 3

For an ordered list, start a line with 1.

1. list item 1
2. list item 2
3. list item 3

This would give us

  1. list item 1
  2. list item 2
  3. list item 3

The syntax for links looks like this: [link text](URL). For example, [my math homepage](https://wealldomath.com) gives us my math homepage .

For images, we use the same syntax but with an exclamation point in front: ![image text](image link). The image link could be a url or a local file path.

Blockquotes

To generate a blockquote, just start a new line with >.

> To see a World in a Grain of Sand,  
> And a Heaven in a Wild Flower,  
> Hold Infinity in the palm of your hand,  
> And Eternity in an hour. - William Blake

This gives us

To see a World in a Grain of Sand,
And a Heaven in a Wild Flower,
Hold Infinity in the palm of your hand,
And Eternity in an hour. - William Blake

Notice that if I use a dash - in the middle of a line, it doesn’t start a list but is treated like a normal dash.

Code

To generate all of the inline code in this document, I enclosed the code in a backtick: ` (it’s to the left of your 1 key). So, `print("Hello World!")` gives us print("Hello World!"). For a code block, start a new line with three back ticks.

Tables

To generate a table, we use a combination of pipes and dashes. The first row of your table should have each entry separated by a pipe |. The next line should fill in the space between pipes with dashes -. Then, every subsequent row should have entries separated by pipes.

| First Name | Last Name    | Phone-Number |
|------------|--------------|--------------|
| Dimitri    | Papadopoulos | 555-5555     |
| John       | Smith        | 555-0000     |
First Name Last Name Phone-Number
Dimitri Papadopoulos 555-5555
John Smith 555-0000

Summary

Before we get to math, here’s a summary:

Feature Syntax Example Output Example
Headings # Heading 1
## Heading 2
### Heading 3
Heading 1
Heading 2
Heading 3
Italic *Italic* or _Italic_ Italic
Bold **Bold** or __Bold__ Bold
Bold + Italic ***Bold Italic*** or ___Bold Italic___ Bold Italic
Unordered List - Item 1
- Item 2
- Item 1
- Item 2
Ordered List 1. Item 1
2. Item 2
1. Item 1
2. Item 2
Link [Link Text](https://example.com) Link Text
Image ![Alt Text](image-url.jpg) Displays an image
Inline Code `print("Hello")` print("Hello")
Code Block <br> ```python<br>print("Hello")<br>```<br> python<br>print("Hello")
Blockquote > This is a blockquote. > This is a blockquote.
Table See this table’s syntax! Outputs this table

Incorporating LaTeX into Markdown

Markdown supports LaTeX for mathematical expressions and notations, making it popular among educators, scientists, and researchers. Many platforms like Jupyter Notebook, Obsidian, and GitHub Pages allow LaTeX integration using the following syntax:

  1. Inline Math: Use single dollar signs: $y = mx + b$.

Rendered: $y = mx + b$

  1. Block Math: Use double dollar signs:
$$
E = mc^2
$$

Rendered:

$$ E = mc^{2} $$

  1. Escaping Text: Use backslashes for LaTeX commands: $\frac{a}{b}$ for $\frac{a}{b}$.

Some useful commands/syntax to get started

Command/Syntax Output
$x^{12}$ $x^{12}$
$x_{12}$ $x_{12}$
$\frac{a}{b}$ $\frac{a}{b}$
$A \cap B$ $A \cap B$
$A \cup B$ $A \cup B$
$\{1,2,3\}$ ${1,2,3}$
$\leq$ $\leq$
$\geq$ $\geq$
$A \subset B$ $A \subset B$
$A \subseteq B$ $A \subseteq B$
$\int_{a}^{b} f(x) \, dx$ $\int_{a}^{b} f(x) , dx$

Note:

  • When using an escaped command, make sure to leave a space after it. If we write $A\subsetB$ LaTeX will assume the command we’re entering is \subsetB and won’t render (or will return an error).
  • To add space, you can use things like \. or \; as I did with the integral.

Organizing Our Work

If we have several lines of work that we want to have nicely aligned, we can use the aligned environment. We add a & in each line where we want the alignment to occurr:

$$
\begin{aligned}
x^2 + 3x &= -2 \cr
x^2 + 3x + 2 &= 0 \cr
(x + 1)(x + 2) &= 0 \cr
x &= -1, -2
\end{aligned}
$$

$$ \begin{aligned} x^2 + 3x &= -2 \cr x^2 + 3x + 2 &= 0 \cr (x + 1)(x + 2) &= 0 \cr x &= -1, -2 \end{aligned} $$

Rendering Our Markdown

We have a few options for rendering our markdown files.

Obsidian

The easiest option, I think, is to use Obsidian . Obsidian is nice because it will render the markdown as you go and it has a built in export to PDF feature. You can also get plugins that will allow you to export to HTML and other formats.

Pandoc

If you’re comfortable using the Terminal, you can look into the command line tool pandoc . This allows you to convert between all sorts of text formats. You’ll have to download that as well as the latex pdf engine to make it work. But, once you get the hang of it, it’s a very powerful tool!

An IDE

An IDE like Visual Studio Code will have extensions for markdown and latex. I use the “Markdown All In One” and “Latex” extensions.

Online Editors

There are also plenty of online editors that you can use to get started.