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 poweredAIでLaTeXを書く

最高のAI LaTeXエディタ、Overleaf代替

Octreeは15以上の大学の研究者がAIを使って論文をより速く書くのを支援

  • AIで美しいTikZダイアグラムを生成
  • 画像をアップロードしてシームレスにLaTeXに変換
  • 論文の執筆とフォーマットに即座にサポートを取得