# How to do fractions

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!

• \frac{numerator}{denominator} A quick glance in math-mode will show you more possibilities. – Johannes_B Dec 3 '14 at 15:30
• $\frac{x}{\cos(x)+x}$ (testing) - like this? – Kurtbusch Dec 3 '14 at 15:35
• @Kurtbusch yes. – David Carlisle Dec 3 '14 at 15:39
• Welcome to TeX.SX! Your question is basically about mathjax usage in websites (such as Math.SE), but fortunately, \frac or \dfrac command (for 'better' fractions) work with mathjax – user31729 Dec 3 '14 at 15:40
• N.B. On the actual TeX Stackexchange site, rendering of (La)TeX is disabled, which is why your test in the comment above didn't work. – Niel de Beaudrap Dec 3 '14 at 15:41

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.