FRACTIONS & GROUPING

How to write fractions in LaTeX

Examples checked with MathTexLab’s base and AMS math renderer · Display style

Write a fraction as \frac{numerator}{denominator}. The first brace group goes above the bar and the second goes below it. Start with this structure, then choose the fraction style and any surrounding parentheses.

Start with two brace groups

The expression below means three divided by four. The command is followed by two arguments; the braces make those arguments clear even when they contain more than one character.

A basic fraction
\frac{3}{4}
Open example in editor

Use the Fraction button in Essentials to insert a template. Replace a and b with your values. Leave the braces in place.

Group the whole numerator and denominator

Braces do not print as visible brackets. They tell the renderer which terms belong together. Here, x+1 is entirely above the bar and x^2+1 is entirely below it.

Grouping longer expressions
\frac{x+1}{x^2+1}
Open example in editor

That differs from \frac{x}{x^2}+1, where the final +1 is outside the fraction. It also differs from plain x+1/x^2+1, whose grouping is not made clear by a horizontal fraction bar. Check the preview against the expression you intend.

When to use frac, dfrac and tfrac

\frac{a}{b}
Follows the surrounding math style. It is a useful default for most equations.
\dfrac{a}{b}
Forces display-style sizing for that fraction, even in an otherwise compact context.
\tfrac{a}{b}
Forces text-style sizing for that fraction, useful when a smaller fraction is intentional.
Automatic, display and text-style fractions
\frac{1}{2}\quad\dfrac{1}{2}\quad\tfrac{1}{2}
Open example in editor

The preview above uses Display style, so the first two fractions look alike and the third is smaller. Open the example, change Math style to Inline, and compare them again. The font-size slider changes the overall equation size; \dfrac and \tfrac change the mathematical style of individual fractions.

There is no universally better choice. Display fractions may improve readability but take more vertical room. Use the form that fits the equation and its destination.

Fractions inside fractions

A fraction argument can contain another fraction. Match each opening brace with its closing brace, and read from the outside inward: the outer numerator is 1; its denominator is 1+\frac{1}{x}.

A fraction inside a fraction
\frac{1}{1+\frac{1}{x}}
Open example in editor

Nested fractions naturally become more compact at inner levels. Forcing every level into display style can make an expression tall. If the result is hard to read, reconsider the notation rather than increasing the font size alone.

Use growing parentheses around a tall expression

\left( and \right) create a matched pair that sizes around its contents. The outer exponent below applies to the whole parenthesized fraction.

Parentheses that grow with a fraction
\left(\frac{a+b}{c}\right)^2
Open example in editor

Both delimiter commands must be present in the same mathematical group. Ordinary ( and ) are fine for short expressions when automatic sizing is unnecessary.

Fix the most common fraction errors

  • A missing argument: \frac{a} is incomplete. Supply the denominator group too.
  • A missing brace: match the braces before adding more commands. Work outward from the innermost fraction.
  • A valid expression with the wrong meaning: compare terms inside and outside the bar. Rendering success is not a mathematical proof.
  • Full-document syntax in the editor: enter only the expression. MathTexLab already supplies its supported math packages.

Use the symbol guide for operators and relations. When the fraction looks right, the image-export guide explains how to keep it readable in a slide or document.

Syntax references

See Overleaf’s fraction reference for general LaTeX context and the MathJax command index for command and extension information. All runnable examples here use MathTexLab’s base and AMS configuration.