(click anywhere to close)

[LaTeX] Math Environments I

category: Writing | course: LaTeX Math | difficulty:

When it comes to math environments, there are 4 core environments, and lots of sub environments. The core ones start math mode, and define some crucial overall functionality and layout, while the sub environments are usually used to align everything properly and gain more control over the look.

This chapter is only about the core ones; every math formula you’ll ever use needs to start with one of these. Next chapter is about the others, which need to be placed inside a certain core environment – remember that, as I won’t keep mentioning it! If you forget it, LaTeX will often throw an undecipherable error and stop compiling.

The core math environments are: math, displaymath, equation and array.


The math environment starts inline math mode, which means it’s placed in line with the regular text within the paragraph. It can be started with one of the following three (equivalent) syntaxes:

\( … \) $ … $ \begin{math} … \end{math}

Juan fetched some $H_{2}O$, and did $a^2 + b^2 = c^2$, and created a unicorn!


The displaymath environment starts math mode on a new line, and centres the equation. It can be started with one of the following two (equivalent) syntaxes:

\[ … \] \begin{displaymath} … \end{displaymath}

Einstein's famous formula, 
\[ E = mc^2 \]
has become an important cornerstone of modern physics


The equation environment does the same as the previous environment, but also adds the equation number in the right margin. All equations are automatically numbered by LaTeX, starting from 1. The syntax is:

\begin{equation} … \end{equation}

    E = mc^2
Formula 1 was one of Einstein's most important formulas.

The star variation, equation*, is exactly the same as the displaymath environment.

The reason it numbers equations, is that it allows you to use labels and references, just as with tables and figures. For this, use the \label{label} and \eqref{label} commands.

    E = mc^2\label{eq:Relativity}
Formula \eqref{eq:Relativity} was one of Einstein's most important formulas.

Multiple equations can be put within the same math environment, which means you can have multiple labels within the environment – each corresponding with the equation on the current line.


The array environment creates a table, but, unlike the regular tabular environment, all cells are automatically put into math mode. Of course, you could recreate the effect by starting math mode in every cell individually, but using this environment is much, much simpler. The syntax is:

\[ \begin{array}{columns} item1 & item2 & item3 \\ … \end{array} \]

Because cells are all in math mode, the types of columns you can use are restricted to l (left), c (center), r (right) and | (vertical line).

		2 &+& 2 & = 4 \\
		2 &+& 2 & = 0
Do you like my tutorials?
To keep this site running, donate some motivational food!
Chocolate Milk