2

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!

  • 6
    \frac{numerator}{denominator} A quick glance in math-mode will show you more possibilities. – Johannes_B Dec 3 '14 at 15:30
  • 1
    $\frac{x}{\cos(x)+x}$ (testing) - like this? – Kurtbusch Dec 3 '14 at 15:35
  • 1
    @Kurtbusch yes. – David Carlisle Dec 3 '14 at 15:39
  • 1
    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
  • 3
    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
4

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

kurtbuschFractions1

\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.

kurtbuschRecipe

\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}

kurtbuschFractions2

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.