Opening a LaTeX environment

There are three ways to open a LaTeX environment within Moodle:

  1. Using two $$ at either end of your equation will open a LaTeX environment.
    1. For example: $$ x\ =\ \frac{\sqrt{144}}{2}\ \times\ (y\ +\ 12) $$
  2. Using a pair of \[ \] will allow you to open a LaTeX environment which will display on its own line allowing you to separate equations from text.
    1. For example: \[ x\ =\ \frac{\sqrt{144}}{2}\ \times\ (y\ +\ 12)\]
  3. Finally, using a pair of \( \) will allow you to create an inline equation environment allowing for the environment to be naturally placed within a sentence or line. These are added automatically by Moodle's equation editor and so do not need to be added.
    1. For example: \( x\ =\ \frac{\sqrt{144}}{2}\ \times\ (y\ +\ 12)\)

Henceforth it will be assumed that all examples are written within a LaTeX environment.

Special Characters:

“@”, “#”, “$”, “%”, “^”, “&”, “*”, “.”, “(“ and “)” will not appear as text when placed within a LaTeX environment. In order for these symbols to be shown they must be preceded by a forward slash e.g. “\&”.


Functions can be nested within other functions through the use of curly braces “{}”. It is important to ensure that the number of open curly braces is equal to the number of close curly braces.

Superscripts, Subscripts, and Roots

In order to insert a single superscript character a caret is used “^”. This will cause the very next symbol typed to become a superscript. If you want more than one symbol to be superscript you can enclose them in {}.

For example: x^6,  x^\delta, or x^{67}.

For subscripts the same applies except using an underscore in place of a caret “_”.

For example: x_6x_\delta, or x_{67}.

For a square root is represented by “\sqrt” followed by the text you wish to appear within the square root being placed within curly braces {}.

For example: \sqrt{x^6}\sqrt{x_{67}}


Fractions in LaTeX are processed by starting with the command string “\frac” followed by two sets of curly braces “{}{}”. The first set of curly braces are used to express the numerator, while the second set specifies the denominator.

For example: \frac{2xy^{2z}}{7xz}

Fractions within Brackets:

When you try to place your fraction within brackets you will likely notice that the brackets are too small. This can be fixed by changing the nomenclature used. By adding “\left” and “\right” before the bracket it will resize to fully encompass the fraction.

For example: \left(\frac{12}{7x}\right)Conversely: (\frac{12}{7x})

Log and Trigonometric Functions

Functions such as sin, cos, and tan can be expressed in LaTeX by placing a forward slash before them. Similarly, log and ln can be used in much the same way. This allows for such functions to appear normally within a LaTeX mathematics environment.

For Example: \ln\arcsin, or \coth

Derivatives and Integrals

An integration symbol is expressed in LaTeX by writing “\int” followed by the integrand. For integrating twice and thrice an extra i can be added, “\iint” and “\iiint” respectively. And for a circular integral “\oint” is used. Finally for integrals limits can be set using the sub and superscript above.

For derivatives the “frac” command (see above) can be used as no special symbols are necessary.

For example: \int^{2\pi}_0 x^2+6x \,\, dx\iint 2x+9y \,\, dx \,\, dy, or  \frac{dy}{dx} = x^2+9

NB: A forward slash followed by a comma “\,” can be used to generate a space between characters. In the above example it was used to split the differential (dx) from the integrand (x^2+6x).


Unlike other functions listed above matrices require the opening of their own environments. To start a matrix first type “\begin{pmatrix}” this will open the matrix environment. Follow this by what you want to be in the matrix breaking columns with “&” and rows with “\\”. Finally close the matrix environment by typing “\end{pmatrix}”.

For example: \begin{pmatrix} 1z&2&3x\\4&5x&6\\7&8&9 \end{pmatrix}

As you can see there are three lines with each line being separated by the “\\”, each item not separated by a “\\” is instead separated by a “&”.

Different Matrix Types:

Finally you may change the brackets enclosing the matrix by changing the first letter in the curly brackets. For a matrix with square brackets you would write “\begin{bmatrix}” … “\end{bmatrix}”.

  • Round Brackets: pmatrix
  • Curly Brackets: bmatrix
  • Square Brackets: Bmatrix
  • Vertical Lines: vmatrix
  • Double Vertical Lines: Vmatrix
  • No Brackets: matrix

For example: \begin{Vmatrix} w&x&y&z\\4&5&6&7 \end{Vmatrix}