Throughout this tutorial, we will dive into how to implement fractions using LaTeX.
How to Write Simple Fractions in LaTeX
To create fractions, you need to import the amsmathpackage in the preamble.
Once you have the package imported, you can use the \frac and insert the numerator and denominator.
\usepackage[utf8]{inputenc}
\begin{document}
\[
\frac{3}{4}
\]
\end{document}
The above code results in the following.
You can display a fraction inline a block of text by using brackets, as shown in the example code below:
\usepackage[utf8]{inputenc}
\begin{document}
Peter spends \(\frac{1}{2} \), of her salary on house renovations and \(\frac{1}{4} \) on food and shopping. What fraction of her salary was left?
\end{document}
Once you run the markup above, you will see the equations displayed inline with the text as:
The following is an example of a fraction with superscripts and polynomial values.
\usepackage[utf8]{inputenc}
\begin{document}
More Fractions
\[
(a + b)^n = \sum^\alpha_{k=0}\binom{n}{k}a^{n-k}b^k
\]
\end{document}
The output value for this is below:
How to Create Continued Fractions In LaTeX
LaTex also allows you to create nested fractions. To do this, pass another fraction as the denominator.
Here is an example:
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\begin{document}
\[
\frac{\frac {1}{x} - \frac{i}{y} }{\frac{1}{xy}}
\]
\end{document}
The output for this is:
Conclusion
In this guide, we discussed how to create simple fractions and nested fractions in LaTex documents.
Refer to the documentation to learn more.