Creating formulas with LaTeX
To create the content on Serlo, we use the text typesetting programme , 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 .
Important: On serlo.org is only used for writing formulas, normal text should not be written in .
Contents
The environment in the Serlo editor
Before we talk about the correct representation of mathematical expressions, you will first see how to open the environment.
Step 1:
Click on the formula symbol, which is marked with a red arrow in the picture.

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

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 , the input 2,14 becomes this: . If you want to avoid the space after the comma, write 2{,}14 and get .
Indices and exponents
Indices are created within the 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 |
---|---|---|
x^2 | Exponents with circumflex: ^ | |
x^{2a} | Exponents with two or more characters in curly brackets | |
x_1 | Indices with underscore: _ | |
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 | |
\sqrt{x} | Square root | |
\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 |
---|---|---|
\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 . 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
delivers
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,
and
.
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
Note: Be careful not to use and 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
becomes
Vectors, matrices and determinants
For vectors and matrices, another environment is needed within the :
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
you get the vector
By entering
The following matrix is generated:
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
which produces the following determinates:
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 |
---|---|---|
\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: