Fraction in LaTeX (\frac{a}{b})

ab\frac{a}{b}
LaTeX command
\frac{a}{b}
Package
No package needed: built into LaTeX
Mode
Math mode only

Where it is used

Typesets a built-up fraction with numerator a over denominator b, separated by a horizontal rule.

\frac takes two arguments, the numerator and the denominator, so \frac{a}{b} is just a placeholder for any ratio such as \frac{dy}{dx} or \frac{n(n+1)}{2}. In inline math it shrinks to text size, which can be cramped; \dfrac forces display size and \tfrac forces text size. For simple inline ratios a slash, a/b, often reads better than a stacked fraction. Binomial coefficients use \binom{n}{k}, not \frac with no rule. Continued fractions look cleaner with \cfrac, which keeps every level at full size. When a fraction sits inside parentheses, use \left( and \right) so the brackets grow to match its height.

Minimal compilable example

Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.

ddx(1x)=−1x2\frac{d}{dx}\left(\frac{1}{x}\right) = -\frac{1}{x^2}
\documentclass{article}
\begin{document}
Fraction: $\frac{a}{b}$

\[ \frac{d}{dx}\left(\frac{1}{x}\right) = -\frac{1}{x^2} \]
\end{document}

Related symbols

All الرموز الرياضية →

Frequently asked questions

How do I write Fraction in LaTeX?
Type \frac{a}{b} in math mode, for example $\frac{d}{dx}\left(\frac{1}{x}\right) = -\frac{1}{x^2}$. It works in plain LaTeX without loading any package.
Which package do I need for \frac{a}{b}?
None. \frac{a}{b} is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
Can I use \frac{a}{b} in text mode, or only in math mode?
Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $\frac{a}{b}$ in running text.
Math poweredاكتب LaTeX باستخدام الذكاء الاصطناعي

أفضل محرر LaTeX بالذكاء الاصطناعي، بديل Overleaf

يساعد Octree الباحثين من أكثر من 15 جامعة على كتابة أوراق البحث بشكل أسرع باستخدام الذكاء الاصطناعي

  • أنشئ رسوم TikZ جميلة باستخدام الذكاء الاصطناعي
  • ارفع صورة وحولها إلى LaTeX بسلاسة
  • احصل على مساعدة فورية في كتابة وتنسيق أوراق البحث