LaTeX Fractions: \frac, \dfrac, \tfrac and \cfrac

The four fraction commands, when each one is the right choice, and why a fraction collapses inside inline maths.

A fraction in LaTeX is always two brace groups held together by a command: \frac{a}{b}. Choosing between \frac, \dfrac and \tfrac does not change the values — it changes how tall the fraction is typeset in the context around it, which is the single most common reason a fraction looks wrong. Two neighbouring decisions decide the rest: whether the whole expression sits on one line (Align) and whether a bracket has to grow with it (Brackets).

Which one to use

Situation Write this Because
Fraction inside a sentence
\frac{a}{b}
Shrinks to text style, so the paragraph keeps its rhythm.
Must stay full-size inline
\dfrac{a}{b}
Display size regardless of context — expect a taller line.
Must not stretch the line
\tfrac{a}{b}
Locks the compact form even inside displayed maths.
A fraction inside a fraction
\cfrac{1}{1+\cfrac{1}{x}}
Every level stays centred instead of shrinking to one side.
Two stacked entries, no rule
\binom{n}{k}
Parentheses sized around both entries; the bar is gone.
A plain ratio in prose
1/2
Fine until either side becomes an expression.

The commands

What Type this Renders as
General fraction Sizes itself to the context: full height in displayed maths, compressed inline.
\frac{a}{b}
\frac{a}{b}
Display style Forces the tall display form even inside a running sentence.
\dfrac{1}{\sqrt{2}}
\dfrac{1}{\sqrt{2}}
Text style Forces the compact inline form, so it cannot stretch the line height.
\tfrac{1}{2}x
\tfrac{1}{2}x
Continued fraction Keeps each level centred instead of shrinking it to the side.
\cfrac{1}{1+\cfrac{1}{1+\cfrac{1}{x}}}
\cfrac{1}{1+\cfrac{1}{1+\cfrac{1}{x}}}
Straight slash Plain text. Fine in prose, wrong when the numerator is an expression.
1/2
1/2
Binomial Parentheses sized around two stacked entries, with no rule between them.
\binom{n}{k}
\binom{n}{k}

Worked examples

The same fraction, three sizes

\frac{\pi}{2} \qquad \dfrac{\pi}{2} \qquad \tfrac{\pi}{2}
\frac{\pi}{2} \qquad \dfrac{\pi}{2} \qquad \tfrac{\pi}{2}

Rendered in display maths, where all three look identical; the difference only appears when the same code sits inside a paragraph.

Nested fraction

\frac{1+\frac{1}{2}}{1-\frac{1}{3}}
\frac{1+\frac{1}{2}}{1-\frac{1}{3}}

Each level drops to text style automatically, which is why deep nesting becomes unreadable and \cfrac exists.

Mixed number

2\frac{1}{3}
2\frac{1}{3}

A whole number followed by a fraction with no operator between them. Add a thin space with \, if it reads too tight.

Negative fraction

-\frac{b}{2a}
-\frac{b}{2a}

Put the minus outside the command. Writing \frac{-b}{2a} also works but reads worse and upsets alignment in some editors.

Common mistakes

  • Forgetting braces on multi-token arguments: \frac12 works, but \frac12+x parses as \frac{1}{2}+x, not what you meant.
  • Using \frac inline and then complaining the result is cramped — that is the intended behaviour. Reach for \dfrac when you want it tall.
  • Nesting \frac three deep. The inner levels shrink to near-illegibility; use \cfrac or split the expression across lines.
  • Writing a/b for something that is really a fraction of two expressions, e.g. a+b/c+d which is not (a+b)/(c+d).

Questions about this notation

What is the difference between \frac and \dfrac?
None in what they print — only in how they are sized. \frac follows the surrounding style, so it shrinks inside a sentence. \dfrac forces the full display size regardless. \tfrac does the opposite and forces the small inline size.
Why does my fraction look squashed?
Because it is inside inline maths, where LaTeX compresses fractions so they cannot push the line height apart. Either move it to a displayed equation or write \dfrac.
Do I need a package for \cfrac?
No. It comes from amsmath, which is loaded by default in most LaTeX setups and is supported by KaTeX and MathJax as well.
How do I write a complex fraction, where the numerator is itself a fraction?
Plain \frac drops each inner level to text style, so a fraction inside a fraction comes out small and off to one side. Use \cfrac, which keeps every level centred at full size, or split the expression over lines with \frac{1+\frac{1}{2}}{1-\frac{1}{3}} inside an aligned block. Two levels is the practical limit before it stops being readable.

Keep reading

Three ways into the same idea: the notation itself, the lesson that teaches it, and an article that applies it.