# [Tex/LaTex] How to do fractions

math-mode

On the math stack exchange, I've figured out I can do \sin and \int and \theta. I've also figured out that you can use \frac for fractions, but I'm having trouble using it. Can someone explain how \frac works?

I'm new with this so make sure a noob can understand!

Fractions in LaTeX can be done by using the standard control sequence \frac{numerator}{denominator}. There are different modes for inline and displayed formulas:

\documentclass{article}
\usepackage{blindtext}
\usepackage{xcolor}
\usepackage{mathtools}
\begin{document}
Fractions in LaTeX? \blindtext
{\color{red}$\frac{12}{45}$} \blindtext
$\frac{67}{90}$
\blindtext% $\dfrac{91}{42}$ \blindtext%for the ugly output
\end{document}


You can use the displaystyle inline, if you really want to. But it stretches the lines making the output looking ugly.

Package nicefrac makes the fractions looking nice which can be good when typing recipes.

\documentclass{article}
\usepackage{blindtext}
\usepackage{xcolor}
\usepackage{nicefrac}
\begin{document}
\blindtext {\color{blue}Use 3 cups of all purpose flour and
\nicefrac{3}{2} cups of semolina. Mix in ehte yeast and add
water. Make a nice dough and leave it overnight at a rather cool
place.} \blindtext
\end{document}


Of course, you can use fractions inside other fractions as well.

\documentclass{article}
\usepackage{blindtext}
\usepackage{mathtools}
\begin{document}
\blindtext
$\frac{\frac{1}{x}}{\sin{x}\cdot x^2}$
\blindtext
\end{document}


It has to be said tough, that not all those commands may work with Mathjax.