Sarmate.net Sarmate.net
Home Features Pricing Documentation Contact
Log in Sign up

Writing fractions in LaTeX

The \frac command is the main tool for writing fractions in LaTeX. This guide covers simple fractions, display variants, and nested fractions.

Simple fraction with \frac

The basic syntax is \frac{numerator}{denominator}. The fraction automatically adapts to the context (inline or display mode).

LaTeX
La probabilité est $\frac{1}{6}$ pour chaque face.

En mode display :
\[
    \frac{a}{b} + \frac{c}{d} = \frac{ad + bc}{bd}
\]

Controlling size: \dfrac and \tfrac

By default, \frac reduces size in inline mode. Use \dfrac to force display size, or \tfrac to force the smaller inline size even in display mode.

LaTeX
% Comparaison en ligne :
Avec frac : $\frac{1}{2}$ \quad
Avec dfrac : $\dfrac{1}{2}$ \quad
Avec tfrac : $\tfrac{1}{2}$

% En mode display, tfrac est compact :
\[
    \tfrac{1}{2} + \tfrac{1}{3} = \tfrac{5}{6}
\]
Tip Use \dfrac in inline formulas when readability is more important than text spacing, for example in a math exercise.

Nested and continued fractions

You can nest \frac as needed. For continued fractions, use \cfrac which maintains a readable size at each level.

LaTeX
% Fraction imbriquée
\[
    \frac{1}{1 + \frac{1}{2}} = \frac{2}{3}
\]

% Fraction continue avec cfrac
\[
    \sqrt{2} = 1 + \cfrac{1}{2 + \cfrac{1}{2 + \cfrac{1}{2 + \cdots}}}
\]

Reference table

CommandResultUsage
\frac{a}{b}Fraction standardAdaptatif au contexte
\dfrac{a}{b}Fraction grandeForcer la taille display
\tfrac{a}{b}Fraction compacteForcer la taille inline
\cfrac{a}{b}Fraction continueFractions en cascade

Try it in Sarmate

Edit, compile and download your LaTeX documents directly in your browser.

Open the editor