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 Mga Simbolo ng Math →

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 poweredSumulat ng LaTeX gamit ang AI

Pinakamahusay na AI LaTeX Editor, Alternatibo sa Overleaf

Tinutulungan ng Octree ang mga researcher mula sa 15+ na unibersidad na sumulat ng research papers nang mas mabilis gamit ang AI

  • Gumawa ng magagandang TikZ diagrams gamit ang AI
  • Mag-upload ng larawan at i-convert ito sa LaTeX nang walang problema
  • Makakuha ng instant na tulong sa pagsulat at pag-format ng research papers