Mathematics in Markdown
Use ordinary Markdown for explanation and LaTeX for notation. This reference explains what each delimiter, backslash, brace, operator, and row marker does so a first-time writer can build formulas safely.
The two delimiters
Markdown itself does not define mathematics; a math-enabled renderer passes the text between delimiters to a LaTeX math renderer. Most use dollar signs. The delimiters are not part of the equation: they tell the renderer where math begins and ends.
| Characters | What they mean | Write | Use it when |
|---|---|---|---|
$ expression $ | The first dollar opens inline math; the second closes it. Keep them touching the formula, not separated by spaces. | $a^2 + b^2 = c^2$ | A symbol or short relation inside a grammatical sentence. |
$$ line $$ | Two dollars open and close display math. Put each delimiter on its own line. | $$ ... $$ | An equation, derivation, or definition that needs its own visual line. |
\( expression \) | Some tools use a backslash plus parentheses for inline math. This is not universally enabled. | \(x^2\) | Only when the destination explicitly documents this form. |
\[ line \] | Some tools use a backslash plus square brackets for display math. | \[E=mc^2\] | Only when the destination explicitly documents this form. |
A common beginner mistake is writing currency beside a formula. In normal prose, escape a literal dollar as \$5. Do not put spaces just inside a delimiter pair such as $ x $; some renderers accept it, others do not. If a formula is long, use a display block rather than forcing it into a sentence.
Inline example
The quadratic formula gives $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$.
Preparing rendered result…
Keep inline math short. A reader should be able to continue the sentence after it without losing the grammar. The \frac command begins with a backslash, then takes two brace groups: the first is the numerator and the second is the denominator.
Display example
$$
E = mc^2
$$
Preparing rendered result…
Leave a blank line before and after a display equation. This is clearer in raw Markdown and avoids edge cases in renderers that require the delimiters to be on their own lines. Read E = mc^2 character by character: = means equals, plain letters are variables, and ^ attaches the next item as a superscript.
Common LaTeX building blocks
LaTeX is built from ordinary characters, commands, and groups. A backslash \ starts a named command; braces { } keep several characters together as one argument; a caret ^ makes a superscript; an underscore _ makes a subscript.
| Character or command | Exact rule | Write | Meaning |
|---|---|---|---|
^ | Attaches exactly the next token above the baseline. Use braces for more than one character. | x^2, x^{n+1} | Power or upper limit. |
_ | Attaches exactly the next token below the baseline. Use braces for more than one character. | a_n, a_{n+1} | Index or lower limit. |
{ } | Groups characters without printing the braces. | x^{10} | “x to the tenth,” not x¹ followed by 0. |
\frac{a}{b} | \frac takes exactly two brace groups: top, then bottom. | \frac{a+b}{c+d} | A fraction. |
\sqrt{ } | One brace group is the radicand; optional index goes in brackets. | \sqrt{x}, \sqrt[3]{x} | Square or cube root. |
\alpha | The backslash starts a named symbol; command names use letters and end before punctuation or a space. | \alpha + \beta | Greek letters α and β. |
\sin, \log | Use named commands for standard functions, not italic letters typed one by one. | \sin(x) | Correctly spaced function name. |
\le, \neq, \to | Named relation and arrow commands begin with a backslash. | x \le y | ≤, ≠, → and other relations. |
\sum, \int, \lim | Operators accept _ and ^ limits. | \sum_{i=1}^{n} i | Sum, integral, or limit. |
|x| | Plain vertical bars work for simple absolute values; use a command for scalable delimiters. | |x| | Absolute value. |
\text{ } | Put ordinary words in a brace group, not as naked math letters. | x \text{ is positive} | Readable explanatory text. |
For a geometric series with ratio $r$, where $|r| < 1$:
$$
\sum_{n=0}^{\infty} ar^n = \frac{a}{1-r}
$$
Preparing rendered result…
Use braces whenever a superscript or subscript contains more than one character. x^10 means “x to the first power, then 0”; x^{10} means “x to the tenth power.” For a function, write \sin, \cos, \log, or \exp, rather than sin, so the renderer knows it is one operator rather than three multiplied variables.
Complex equations: alignment, cases, and matrices
For multi-line derivations, use an aligned environment inside a display block. \begin{aligned} opens the environment and \end{aligned} closes it. The ampersand & marks the vertical alignment point; the double backslash \\ ends one row and begins the next. Because every marker matters, edit these structures like code.
$$
\begin{aligned}
f(x) &= x^2 + 2x + 1 \\
+ &= (x + 1)^2
\end{aligned}
$$
Preparing rendered result…
Piecewise definition
$$
f(x) =
\begin{cases}
x^2, & x \ge 0 \\
+-x, & x < 0
\end{cases}
$$
Preparing rendered result…
In cases, each row has two columns separated by &: the value first, then its condition. A row ends with \\. Commands such as \ge and \lt express ≥ and <; never rely on visual spacing to communicate a condition.
Matrix and vector
$$
A = \begin{bmatrix}
1 & 2 \\
+3 & 4
\end{bmatrix}
\qquad
\vec{v} = \begin{bmatrix} x \\ y \end{bmatrix}
$$
Preparing rendered result…
In a matrix, & separates columns and \\ separates rows. bmatrix adds square brackets; pmatrix adds round brackets; vmatrix adds vertical bars. \qquad is wide visual spacing and should be used sparingly; it is not a substitute for mathematical structure. These environments are easy to damage when editing visually, so write in source mode, render, then make one small correction at a time.
Compatibility and best practices
Confirm the renderer before choosing syntax
Dollar delimiters are common, but not universal. GitHub Markdown, static-site generators, note apps, and chat tools each enable mathematics differently. Some require an extension; some use \( ... \) and \[ ... \] instead. Preview in the destination, not only in the authoring tool. KaTeX deliberately supports a practical subset of full LaTeX, so a command that works in a desktop TeX compiler may still be unavailable on the web.
Keep prose outside the formula
Explain what every displayed equation is for immediately before or after it. A formula without variables, units, assumptions, or a conclusion is difficult for collaborators and AI systems to interpret correctly.
Use semantic LaTeX, not visual spacing tricks
Prefer \frac, \sum, \text{where}, and environments such as aligned to manually aligned spaces. Semantic structure is more robust across screen sizes and easier to revise. Do not use ^, _, &, or \\ as decoration: each has a specific grammar role.
Escape Markdown only when necessary
Keep formulas out of link labels and emphasis markers. If literal dollar signs appear in normal text, escape them as \$. Put an equation in its own display block rather than trying to nest it in a complicated list, table, or quote. If a preview fails, first check matching delimiters, matching braces, command spelling after \, then row markers in that order.
Make equations accessible
Use descriptive sentences, define symbols nearby, and do not encode the only explanation in an image. If you export a document, inspect the output: a formula that looks correct in a browser may not be selectable or readable in another format.
Write the explanation, then the equation
Open a local Markdown file in MarkIOY, switch to source for the LaTeX, and keep a readable visual document alongside it.
Open MarkIOY Web →