Writing mathematics in your posts (LaTeX)

Writing mathematics on the forum

This forum typesets mathematics with MathJax, so you can write LaTeX directly in a post and it renders in Computer Modern — the standard LaTeX font. This topic shows the syntax with a few economics examples.

First, one rule: write math in Markdown mode

The composer has two modes, switched by the icons at the top left: A (rich text) and M↓ (Markdown). Always write math in M↓ (Markdown) mode.

Inline math

Wrap math in single dollar signs $ … $ (or \( … \)) to place it inside a line of text.

The Cobb–Douglas utility function $u(x,y) = x^{\alpha} y^{1-\alpha}$ is homothetic.

renders as:

The Cobb–Douglas utility function u(x,y) = x^{\alpha} y^{1-\alpha} is homothetic.

Display math

Use double dollar signs $$ … $$ (or \[ … \]) for an equation centred on its own line.

The budget constraint is
$$ p_x\, x + p_y\, y = M. $$

renders as:

The budget constraint is

p_x\, x + p_y\, y = M.

Multi-line derivations

For working that runs over several lines, put an aligned environment inside display delimiters. Use & to set the alignment column (usually at the =) and \\ to end each line.

Maximising Cobb–Douglas utility subject to the budget line gives the first-order conditions
$$
\begin{aligned}
\alpha\, x^{\alpha-1} y^{1-\alpha} &= \lambda\, p_x \\
(1-\alpha)\, x^{\alpha} y^{-\alpha} &= \lambda\, p_y
\end{aligned}
$$
Dividing the first by the second gives the tangency condition
$$ \frac{\alpha}{1-\alpha}\cdot\frac{y}{x} = \frac{p_x}{p_y}. $$

renders as:

Maximising Cobb–Douglas utility subject to the budget line gives the first-order conditions

\begin{aligned} \alpha\, x^{\alpha-1} y^{1-\alpha} &= \lambda\, p_x \\ (1-\alpha)\, x^{\alpha} y^{-\alpha} &= \lambda\, p_y \end{aligned}

Dividing the first by the second gives the tangency condition

\frac{\alpha}{1-\alpha}\cdot\frac{y}{x} = \frac{p_x}{p_y}.

A short symbol reference

You want You type It renders
Fraction \frac{a}{b} \frac{a}{b}
Superscript / subscript x^{2}, x_{i} x^{2}, x_{i}
Greek letters \alpha, \beta, \lambda \alpha,\ \beta,\ \lambda
Expectation \mathbb{E}[X] \mathbb{E}[X]
Sum / integral \sum_{i=1}^{n}, \int_0^1 \sum_{i=1}^{n},\ \int_0^1
Partial derivative \frac{\partial u}{\partial x} \frac{\partial u}{\partial x}
Maximise over \max_{x,y} \max_{x,y}
Inequalities \le, \ge, \neq \le,\ \ge,\ \neq
Sized brackets \left( \frac{a}{b} \right) \left( \frac{a}{b} \right)

Showing LaTeX source without rendering it

If you ever want to display the raw code itself (as this topic does), wrap it in backticks for inline code, or in a fenced code block (three backticks on their own line, before and after). Anything inside code is left untouched by MathJax.

2 Likes