Serlo Logo The Open Learning Platform

Creating formulas with LaTeX

To create the content on Serlo, we use the text typesetting programme LATEX, especially in the areas of mathematics and physics when presenting formulae, equations and calculations.

This help page is intended to give you technical support in using LATEX.

Important: On serlo.org LATEX is only used for writing formulas, normal text should not be written in LATEX.

Contents

The LATEX environment in the Serlo editor

Before we talk about the correct representation of mathematical expressions, you will first see how to open the LATEX environment.

Step 1:

Click on the formula symbol, which is marked with a red arrow in the picture.

Image

Step 2:

The window shown in the illustration opens. Now select the option latex from the drop-down menu.

Image

All other environments, functions and symbols listed below must be written in this environment to be displayed correctly.

Basic mathematical notation

Decimal numbers

Comma numbers: in LATEX, the input 2,14 becomes this: 2,14. If you want to avoid the space after the comma, write 2{,}14 and get 2,14.

Indices and exponents

Indices are created within the LATEXenvironment with the command _. For exponents, ^ is used. If the index or exponent contains more than one character, the two commands mentioned above must be extended by { }. Thus _{ } and ^{ } respectively.

Output

LaTeX-Code

Explanation

x2

x^2

Exponents with circumflex: ^

x2a

x^{2a}

Exponents with two or more characters in curly brackets

x1

x_1

Indices with underscore: _

x1,2

x_{1,2}

Indices with two or more characters in curly brackets

Trigonometric functions

For the correct notation of trigonometric functions, note that instead of simply sin(x), one uses the command \sin(x).

This rule also applies to all other trigonometric functions. Here you can expand a table in which you can find the corresponding commands.

Root expressions

The representation of root expressions succeeds within the \LaTeX environment with the command \sqrt{ }. This command outputs the square root by default.

If you need the nth root more generally, use the command \sqrt[ ]{ }.

Output

LaTeX-Code

Explanation

|

\surd

Root symbol without radicant

x

\sqrt{x}

Square root

xa

\sqrt[a]{x}

Higher roots

Fractions

For fractions, the command \dfrac{ }{ } is used. The content inside the first { } represents the numerator of the fraction, while the content in the second { } represents the denominator of the fraction.

Output

LaTeX-Code

Explanation

3+x2x

\dfrac{3+x}{2x}

For fractions, put numerator and denominator in curly brackets.

Greek alphabet

Text in the LaTeX environment

Occasionally, text is needed in addition to formulas and equations within a LATEXenvironment. The command \text{ } is used for this. The command plays a role above all in physics, since units, for example, are correctly represented by this command.

Example: The input

a = 3 \ \dfrac{\text{m}}{\text{s}^2}

delivers

a=3 ms2

Colours

You can also colour parts of your formula, for example to mark an important step in a calculation. This works with the command \textcolor{}{}.

In the first curly bracket, enter the hex code of the colour you want to use. For example,

  • this text has the colour with the hex code009999 and

  • this text the colour with the hex code𝐜𝐜𝟎𝟎𝟎𝟎.

The hex codes for the recommended colours on Serlo can be found in the help page for images and graphics.

In the second curly bracket, enter the LaTeX code that you want to highlight.

An example: The LaTeX code

f(X)=\textcolor{ff6600}{1013}\cdot \textcolor{009999}{1,42}^x=\ \textcolor{ff6600}{b}\ \cdot \textcolor{009999}{a}^x

f(X)=10131,42x= b ax

Note: Be careful not to use red and green in combination to distinguish elements from each other - people with a red-green deficiency may have problems here.

Brackets and semicolons

rackets are always written with \left and \right so that they can adapt to the size of the formula in between. A list of the most important bracket notation can be found below.

Amount strokes can also be set by \left and \right. The input

f(x)=\left| x \right|

becomes

f(x)=|x|

Vectors, matrices and determinants

For vectors and matrices, another environment is needed within the LATEXenvironment:

Vectors and matrices

Environment

Application

pmatrix

With the "pmatrix" environment you can create vectors and matrices. Rows are terminated with . Individual columns of a matrix are separated with &.

With the code

\vec{a} = \begin{pmatrix} 1 \\ 2 \\ 3 \end{pmatrix}

you get the vector

a=(123)

By entering

A = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{pmatrix}

The following matrix is generated:

A=(123456789)

Determinants

The following environment is used for the representation of determinants:

Environment

Application

vmatrix

The "vmatrix" environment is useful for notating determinants. Individual columns are separated with & and with \ \ rows are terminated.

For example, by entering

\det A = \begin{vmatrix} 2 & 2 & 5 \\ 1 & 3 & 9 \\ 2 & 3 & 4 \end{vmatrix}

which produces the following determinates:

detA=|225139234|

Integrals

To represent integrals, the command \int is used. If the integral is not to be indefinite but definite, the lower and upper limits can be supplemented by the addition \int_{ }^{ }. Here, the content of the pair of brackets after _ determines the lower limit, while the content of the pair of brackets after ^ determines the content of the upper limit.

Output

LaTeX-Code

Explanation

ππsin(x)dx

\int_{-\pi}^{\pi} \sin(x) \mathrm{d}x

Integral limits with _ and ^, and the operator "d" in normal font with \mathrm{}

When representing the integration variables, note that one does not write dx but instead \mathrm{d}x.

Arrows

This section is about the display of arrows.

List of mathematical expressions

Functions

Mathematical special characters

You can find a list of the most important mathematical special characters here:

Notations and function modifications

Special characters, vector arrows, derivatives or curly brackets under terms can be found here:

Still want more?

You can find more content on this topic here:

Articles


This content is licensed under
CC BY-SA 4.0 What does that mean? serlo.org