Engineering.SE supports $\LaTeX$ style equation editing via MathJax. However, most of the guides for typesetting equations with $\LaTeX$ are either too limited or too expansive for new users who just want to ask their question. This post will aim to give a simple introduction to the most commonly used features of equation typesetting. Below are also some links to other guides.
1 Answer
The Basics
Inline equations are surrounded by dollar signs;
$\sin(x)$
gives $\sin(x)$.Equations on their own line are surrounded by double dollar signs;
$$\tan(\theta)=o/a$$
gives $$\tan(\theta)=o/a$$Subscripts and superscripts are denoted by the
_
and^
operators;E_i^2
gives $E_i^2$Brackets can be used to extend the influence of operators over multiple characters;
E_{1,2}^{op}
gives $E_{1,2}^{op}$Fractions can be made with the
\frac{}{}
command;\frac{\partial E}{\partial z}
gives $\frac{\partial E}{\partial z}$. If your inline fraction is compressed into too small a space, try using\dfrac
to force the fraction to display as if it were on its own line;\dfrac{\partial E}{\partial z}
gives $\dfrac{\partial E}{\partial z}$.Spaces and carriage returns have no meaning;
\alpha\beta \gamma
gives $\alpha\beta \gamma$
Common Symbols
Common symbols such as Greek letters are generally rendered by a slash followed by the name. For symbols with both an uppercase and lowercase form the case of the first letter determines the case of the symbol.
Greek letters (lower):
\alpha \beta \gamma \delta \epsilon \zeta \eta \theta \iota \kappa \lambda \mu \nu \xi \omicron \pi \rho \sigma \tau \upsilon \phi \chi \psi \omega
gives $\alpha\beta\gamma\delta\epsilon\zeta\eta\theta\iota\kappa\lambda\mu\nu\xi\omicron\pi\rho\sigma\tau\upsilon\phi\chi\psi\omega$Greek letters (upper):
\Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega
gives $\Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega$. Other uppercase Greek letters can be made by simply typing the corresponding letter in the Latin alphabet, e.g. A for upper case alpha.Basic Integrals: use
\int
where limits are added with the superscript and subscript operators;\int_a^b xdx
gives $\int_a^b xdx$.Multiple Integrals: use
\iint
and\iiint
for double and triple integrals when you don't need to specify separate limits;\iint_A f(x, y) dxdy
gives $\iint_A f(x, y) dxdy$Pretty Integrals: optionally, use
\limits
to position the limits of an integral directly above and below the integral symbol and\,
to separate terms like $dx$ and $dy$ from the function and each other;\int\limits_a^b\int\limits_c^d f(x,y)\,dx\,dy
gives $\int\limits_a^b\int\limits_c^d f(x,y)\,dx\,dy$Radicals: use
\sqrt{}
which will expand to the size of its argument;\sqrt{a}
gives $\sqrt{a}$,\sqrt{\frac{a}{b}}
gives $\sqrt{\frac{a}{b}}$, etc.Relations:
\lt \gt \leq \geq \neq
gives $\lt\gt\leq\geq\neq$Operators:
\times \div \pm \mp \cdot
gives $\times\div\pm\mp\cdot$Approximately:
\approx \sim \simeq \propto
gives $\approx \sim \simeq \propto$Special:
\infty \nabla \partial \Im \Re
gives $\infty \nabla \partial \Im \Re$Special Functions:
\sin \cos \exp \ln \log
gives $\sin \cos \exp \ln \log$
Parentheses
Ordinary parentheses, brackets, and curly braces are added with the symbols
( ) [ ] | | \{ \}
(which gives $( ) [ ] | | \{ \}$). Note that the curly braces needs the\
since it is otherwise a special LaTeX symbol.Expanding parentheses can be added with the
\left
and\right
commands;\exp [ \sin ( \frac{a}{b} ) ]
gives $$\exp [ \sin ( \frac{a}{b} ) ]$$ while\exp \left[ \sin \left( \frac{a}{b} \right) \right]
gives $$\exp \left[ \sin \left( \frac{a}{b} \right) \right]$$
Formatting Tips
Newlines are ignored unless escaped with
\\
. For example:
$$1 2 3$$$$1 2 3$$
Versus:
$$1\\ 2\\ 3$$$$1\\ 2\\ 3$$
Be careful when using the Blockquote button (or CTRL + Q) in the editor window to format MathJax markup; the default behavior is to wrap the quote in a way that can result in undesired angle brackets in the rendered output. Take this formula as an example:
$$\dfrac {\partial \mathbf u} {\partial t} + \mathbf u \cdot \nabla \mathbf u - \nu \nabla ^2 \mathbf u = - \nabla w + \mathbf g$$
Highlighting the exact same marked-up formula in the editor window and pressing the Blockquote button produces this output:
$$\dfrac {\partial \mathbf u} {\partial t} + \mathbf u \cdot \nabla > \mathbf u - \nu \nabla ^2 \mathbf u = - \nabla w + \mathbf g$$
Notice the extra $>$ that now appears in the second term. To avoid this, make sure to use only a single Blockquote delimiter (
>
) at the start of the MathJax block ($
or$$
).Sometimes it's more effective to consolidate several formulas or equations into a single block of MathJax-formatted text than to scatter them throughout the body of a post. In these cases, you can use
\tag{}
to number or label a block of MathJax markup for later reference:$\tag{1} C = 2 \pi r$ $\tag{2} A = \pi r^2$ $\tag{3} V = {4 \over 3} \pi r^3$
A more detailed explanation, including labeled hyperlink references, is available here on Math.SE.