LaTeX Fractions - How to Write Fractions in LaTeX

The simplest way to write fractions in LaTeX is by using the \frac command. This command takes two arguments: the numerator and the denominator.

\frac{numerator}{denominator}
Listing 1 - Basic fraction syntax in LaTeX

For example:

\frac{1}{2}
Listing 2 - Example of a simple fraction

Inline and Display Fractions

  • Inline Fractions: To write fractions within a line of text, enclose the fraction in dollar signs $...$. For example: $\frac{3}{4}$.
  • Display Mode Fractions: For standalone fractions, use double dollar signs $$...$$ or the \[ ... \] environment. Example: $$\frac{a+b}{c+d}$$

Complex and Nested Fractions

You can create nested fractions by embedding one \frac command within another.

\frac{\frac{1}{x} + y}{z}
Listing 3 - Example of nested fractions

Size Adjustments for Fractions

  • Display Style: Use \dfrac to create larger fractions suitable for display equations. Example: \dfrac{a}{b}.
  • Text Style: Use \tfrac for smaller fractions in inline text. Example: $\tfrac12$.

Troubleshooting Fraction Errors

  • Missing Braces: Always ensure both the numerator and denominator are enclosed in curly braces {}.
  • Spacing Issues: Use \;, \,, or \: to adjust spacing around fractions.