LaTeX Tutorials

Mastering Fractions in LaTeX: A Complete Guide

12 min read

Introduction

Fractions are fundamental mathematical expressions used throughout algebra, calculus, and advanced mathematics. In LaTeX, typesetting fractions correctly is essential for creating professional mathematical documents. This comprehensive guide covers everything you need to know about writing fractions in LaTeX, from basic fractions to complex nested and continued fractions.

Whether you're working on academic papers, research documents, or educational materials, mastering fraction notation in LaTeX will help you create clear, readable mathematical expressions. This complete guide provides step-by-step instructions for all types of fractions in LaTeX.

Basic Fractions

The most common way to create fractions in LaTeX is using the \frac command. The syntax is:

\frac{numerator}{denominator}

Here are some examples of basic fractions:

Simple fraction:

\frac{1}{2}

Fraction with variables:

\frac{x}{y}

Fraction with expressions:

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

Display Mode vs Inline Mode

LaTeX automatically adjusts fraction size based on the math mode. In display mode (centered, larger), fractions are more prominent, while in inline mode (within text), they are compressed to fit the line height.

Display Mode

Use display mode for standalone formulas:

\[ \frac{x^2 + 2x + 1}{x - 1} = x + 3 \]

Inline Mode

Use inline mode for fractions within text. The fraction below appears smaller to fit the line:

The value is \( \frac{1}{2} \) of the total.

Nested Fractions

You can nest fractions within fractions. For better readability, use \cfrac (continued fraction) or adjust sizes with \dfrac and \tfrac.

Nested fraction:

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

Using \cfrac for better readability:

\cfrac{a}{b + \cfrac{c}{d + \cfrac{e}{f}}}

Continued Fractions

Continued fractions are infinite expressions of the form:

The \cfrac command creates continued fractions with proper spacing and alignment.

\cfrac{1}{1 + \cfrac{1}{1 + \cfrac{1}{1 + \cdots}}}

Mixed Numbers

Mixed numbers combine whole numbers with fractions. In LaTeX, you can write them as:

Mixed number:

2\frac{1}{3}

With proper spacing:

2\,\frac{1}{3}

Controlling Fraction Size

LaTeX provides commands to force specific fraction sizes regardless of the math mode:

\dfrac - Display Size

Forces display-sized fraction even in inline mode:

\dfrac{a}{b}

\tfrac - Text Size

Forces text-sized fraction even in display mode:

\tfrac{a}{b}

Complex Examples

Example 1: Fraction with Powers

\frac{x^2 + 2x + 1}{(x - 1)^2}

Example 2: Fraction with Roots

\frac{\sqrt{a} + \sqrt{b}}{\sqrt{c}}

Example 3: Fraction in Limits

\lim_{x \to 0} \frac{\sin(x)}{x} = 1

Example 4: Fraction in Integrals

\int \frac{1}{x^2 + 1} \, dx = \arctan(x) + C

Best Practices

Use Proper Spacing

Add spacing around fractions when needed using \,, \:, or \;:

x = \frac{a}{b} + \frac{c}{d}

Parentheses for Complex Numerators/Denominators

Always use parentheses when the numerator or denominator contains multiple terms:

\frac{(a + b)(c + d)}{(e - f)^2}

Choose the Right Mode

Use display mode for important formulas and inline mode for fractions within sentences. Use \dfrac or \tfrac when you need to override the default size.

Common Mistakes to Avoid

  • Missing braces: Always use curly braces {} around the numerator and denominator, even for single characters.
  • Incorrect spacing: Don't use regular spaces in math mode. Use \,, \:, or \; for spacing.
  • Nested fractions without size control: For deeply nested fractions, consider using \cfrac or breaking them into multiple lines.
  • Forgetting parentheses: When numerators or denominators contain operations, always wrap them in parentheses.

Related Topics