This is the reason LaTeX exists: flawless mathematics. The golden rule: maths are written in a math mode. Inline within a sentence with $…$, or as a centred equation with \[…\].
Compile Compile. Spot the inline formula (between
$…$) and the centred equation (between \[…\]), with a fraction and an exponent.The essential building blocks
\$ … \$: inline maths, within the text.\[ … \]: an equation centred on its own line.^: exponent (x^2)._: subscript (a_1).\frac{numerator}{denominator}: a fraction.
Modify Your turn: change the formula to write x cubed (
x^3) and the fraction 3/4. Compile.Show the solution
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[ x^3 + \frac{3}{4} \]
\end{document}The classic mistake: forgetting the $
A mathematical symbol written in plain text triggers the error "Missing $ inserted". The solution is always the same: surround the expression with $…$.
Fix This document triggers "Missing $ inserted":
x^2 is outside math mode. Surround the expressions with $…$, then compile. Learn more about this error →Show the solution
\documentclass{article}
\begin{document}
The derivative of $x^2$ is $2x$.
\end{document} Key point: as soon as there is a
^, a _ or a maths command, you are in math mode → surround it with $…$ (or \[…\] to centre it).Well done, you have completed Level 1! You now know how to create, format and write maths. Ready to work on a real document?
Open the full editor