MarkdownPaper Open reader

Guide

Math in Markdown

Write math between dollar signs, using LaTeX. One $ on each side puts a formula inside a sentence. Two $$ on their own lines set an equation on a line of its own, centered.

You write

The area of a circle is $\pi r^2$.

$
\int_0^1 x^2 \, dx = \frac{1}{3}
$

You see

The area of a circle is .

Math is not part of standard Markdown, but GitHub, MarkdownPaper, Obsidian, VS Code and most note apps support it in this form.

On this page

Inline math

Keep the dollar signs tight against the formula: $x^2$, not $ x^2 $. That rule is also what keeps prices as prices.

When a line has a price and a formula, put a backslash before the price's dollar sign, or the two dollar signs can pair up and neither shows as intended.

You write

Each ticket costs \$5 and the total is $n \times 5$.

You see

Each ticket costs $5 and the total is .

On GitHub, a formula with * or _ in it can be read as Markdown first and come out in italics. GitHub's fix is to write it as $`...`$. MarkdownPaper reads the math first, so plain dollar signs are enough there.

You write

The sum is $a_1 * b_1$.

You see

The sum is .

Display math

Put $$ on the line before and the line after. On a single line, some apps (MarkdownPaper among them) set it inside the sentence instead.

You write

$
E = mc^2
$

You see

A fence marked math does the same thing and is easier to spot in the file.

You write

```math
a^2 + b^2 = c^2
```

You see

The symbols you will use most

WriteShows
x^2
x_1
\frac{a}{b}
\sqrt{2}
\sum_{i=1}^{n} i
\alpha \beta \pi
\le \ge \ne
\times \div \pm
\infty
\to

For more than one character in a power or an index, use braces: x^{10}, not x^10.

Line up several equations

Use aligned and put & before the sign to line up on. End each line with \\.

You write

$
\begin{aligned}
y &= 2x + 3 \\
  &= 2(4) + 3 \\
  &= 11
\end{aligned}
$

You see

Matrices and cases

You write

$
\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}
$

$
|x| = \begin{cases} x & x \ge 0 \\ -x & x < 0 \end{cases}
$

You see

Use pmatrix for round brackets and vmatrix for straight bars.

Where math works

AppMath
GitHub$, $$ and the math fence, drawn with MathJax
MarkdownPaper$, $$ and the math fence, drawn with KaTeX
Obsidian$ and $$
VS Code preview$ and $$

KaTeX and MathJax cover the same everyday LaTeX. A rare command may work in one and not the other.

Common problems

  • A price turned into math. Two prices in one line, like $5 and $10, can be read as a formula in some apps. Write \$5 to be safe.
  • The formula shows in red. The LaTeX has a mistake, often a missing brace. The red text is the part that failed.
  • Underscores turned into italics. On GitHub, use $`...`$ or the math fence.

Questions

How do I write an equation in Markdown?

Put it between $$ lines for an equation on its own line, or between single $ for one inside a sentence. The equation itself is written in LaTeX.

Does GitHub support math in Markdown?

Yes, in README files, issues and comments. It uses MathJax and accepts $, $$ and a fence marked math.

How do I write a dollar sign that is not math?

Put a backslash before it: \$5.

Next