FormaTeX

\frac{num}

LaTeX Fractions

Everything you need to write fractions in LaTeX — from basic \frac{num}{den} to size-controlling variants \dfrac and \tfrac, nested fractions, and continued fractions with \cfrac.

\frac{numerator}

Basic \frac usage

The \frac{numerator}{denominator} command is the standard way to write fractions in LaTeX. It is available in all math modes without any extra packages. The size adapts automatically: smaller in inline math, full-size in display math.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

% Basic \frac{numerator}{denominator}
The slope is $\frac{\Delta y}{\Delta x}$.

% Display-style fraction with \[...\]
\[
  \frac{d}{dx}\left[\frac{f(x)}{g(x)}\right]
  = \frac{f'(x)\,g(x) - f(x)\,g'(x)}{[g(x)]^2}
\]

% \dfrac: always display size (good for inline headings)
The exact value is $\dfrac{\sqrt{3}}{2}$.

% \tfrac: always text size (good in display for side notes)
\[
  \text{Mixing sizes: } \tfrac{1}{2} + \frac{1}{3} = \frac{5}{6}
\]

\end{document}

\dfrac{vs \\tfrac}

\dfrac vs \tfrac

Both commands are provided by amsmath and override the automatic size selection of \frac. Use them when the default size is wrong for the context.

f

\frac

Auto-sizing

Chooses text or display style based on the current math context. The sensible default for most situations.

Best for: Most equations

d

\dfrac

Display size

Always renders at full display size. Use inside inline math or matrix entries when you need a large, readable fraction.

Best for: Inline headings, matrix cells

t

\tfrac

Text size

Always renders at compact text size. Use inside display equations when a full-size fraction would be too prominent.

Best for: Summation indices, side annotations

\cfrac{continued}

Nested fractions & continued fractions

You can nest \frac inside itself, but each level shrinks the font. For deeply nested structures — especially continued fractions — use \cfrac from amsmath, which keeps every level at display size.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

% Nested fractions
\[
  \frac{1}{\dfrac{1}{a} + \dfrac{1}{b}} = \frac{ab}{a + b}
\]

% Continued fraction with \cfrac (no size reduction)
\[
  \sqrt{2} = 1 + \cfrac{1}{2 + \cfrac{1}{2 + \cfrac{1}{2 + \cdots}}}
\]

% Binomial coefficient
\[
  \binom{n}{k} = \frac{n!}{k!\,(n-k)!}
\]

\end{document}

\section{Common patterns}

Fraction patterns you'll use every day

Copy-ready commands for the fraction forms that appear most often in mathematics, physics, and engineering documents.

\frac{1}{2}

Simple half — the most common fraction

\frac{a+b}{c-d}

Expressions in numerator and denominator

\frac{df}{dx}

Derivative notation (Leibniz)

\frac{\partial f}{\partial x}

Partial derivative

\frac{n!}{k!(n-k)!}

Binomial coefficient expanded form

\binom{n}{k}

Binomial coefficient compact form

\cfrac{1}{1+\cfrac{1}{x}}

Continued fraction (no shrinking)

\sfrac{1}{2}

Slanted fraction (requires xfrac package)

\section{Common mistakes}

Avoid these pitfalls

Missing braces around multi-character arguments

\frac ab+c is not the same as \frac{a}{b+c}. Without braces, LaTeX treats only the first token as each argument — so \frac ab+c renders as (a/b)+c.

Using \frac in exponents without braces

e^{\frac{x}{2}} is correct; e^\frac{x}{2} is ambiguous and will compile incorrectly. Always wrap \frac in braces when it appears in a superscript or subscript.

Overusing \dfrac in running text

\dfrac forces a large fraction that increases line-height in inline math, causing uneven paragraph spacing. Prefer \frac in inline math, or rewrite the expression to avoid inline fractions in body paragraphs.

\section{FAQ}

Frequently asked questions

What is the difference between \frac and \dfrac in LaTeX?

\frac automatically adjusts its size to context: in inline math it renders in text style (smaller), in display math it renders in display style (larger). \dfrac always forces display style regardless of context — use it when you need a full-size fraction inside inline math or inside a subscript.

When should I use \tfrac?

\tfrac forces text (inline) style even inside a display equation. It is useful when you want a compact fraction as part of a larger display expression — for example, inside a matrix entry or a summation index where a full-size fraction would look too large.

How do I write a continued fraction in LaTeX?

Use \cfrac from amsmath. Unlike \frac, \cfrac keeps the numerator and denominator at full size when nested — it does not progressively shrink. Write \cfrac{a}{b + \cfrac{c}{d + \cdots}} to build up the continued fraction level by level.

How do I write a fraction without amsmath?

Plain LaTeX provides \frac in math mode without needing any package. amsmath is only required for \dfrac, \tfrac, and \cfrac. For the vast majority of documents, including \usepackage{amsmath} is a good habit regardless.

How do I make fractions bigger in inline math?

Use \dfrac instead of \frac. Alternatively, switch to display math with \[...\] or the equation environment. If you only need a single fraction to be larger without switching the full equation to display mode, \dfrac is the cleanest solution.

FormaTeX Playground

Try these fraction examples live

Compile LaTeX in the browser — pdfLaTeX, XeLaTeX, LuaLaTeX. Free tier, no credit card.

One quick thing

We track anonymous usage — page views, feature usage, compilation events — to understand what works and what doesn't. No ads, no personal data, no third-party sharing.

Cookie policy