Fraction in LaTeX (\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.
\documentclass{article}
\begin{document}
Fraction: $\frac{a}{b}$
\[ \frac{d}{dx}\left(\frac{1}{x}\right) = -\frac{1}{x^2} \]
\end{document}Related symbols
- Square Root
\sqrt{x} - Division
\div - N-th Root
\sqrt[n]{x} - Multiplication
\times - Summation
\sum_{i=1}^{n} - Subtraction
-
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.
Best AI LaTeX Editor, Overleaf Alternative
Octree helps researchers from 15+ universities write research papers faster using AI
- Generate beautiful TikZ diagrams using AI
- Upload image and convert it to LaTeX seamlessly
- Get instant assistance with writing and formatting research papers