Typevia
Mathematical Typesetting

Introduction to Mathematical Fractions and Binomials

One of the primary reasons people choose LaTeX over traditional word processors is its unparalleled ability to typeset complex mathematical formulas. Among the most common elements in mathematical writing are fractions and binomial coefficients.

In this guide, you will learn how to create clear, professional-looking fractions and binomials, understand the difference between "inline" and "display" math modes, and explore advanced formatting for complex equations.

Note: To follow along with these examples, you should include the amsmath package in your document's preamble. While basic fractions work in standard LaTeX, amsmath provides essential commands for professional math typesetting.

\usepackage{amsmath}

1. Creating Basic Fractions

The fundamental command for creating a fraction in LaTeX is \frac. It requires two arguments: the numerator and the denominator.

Syntax

\frac{numerator}{denominator}

Practical Example

Here is how you would write a simple fraction within a sentence:

The probability is calculated as \frac{1}{2}.

In LaTeX, math can be written in two modes:

  1. Inline Mode: Within a line of text using single dollar signs $ ... $.
  2. Display Mode: On its own centered line using double dollar signs $$ ... $$ or the \[ ... \] environment.
\documentclass{article}
\usepackage{amsmath}
\begin{document}

This is an inline fraction: $\frac{x + y}{z}$.

This is a display fraction:
\[
\frac{x + y}{z}
\]

\end{document}

Key Tip: Notice that in inline mode, LaTeX automatically shrinks the fraction to prevent it from disrupting the line spacing of your paragraph. In display mode, the fraction is shown at full size.


2. Controlling Fraction Size: dfrac and tfrac

Sometimes, the automatic resizing of fractions isn't what you want. You might want a full-sized fraction inside a text paragraph, or a small fraction inside a complex formula. The amsmath package provides two specific commands for this:

  • \dfrac: Forces display size, regardless of the mode.
  • \tfrac: Forces text (small) size, regardless of the mode.

Example: Comparing Sizes

\begin{itemize}
    \item Standard inline: $\frac{1}{2}$
    \item Forced display size in text: $\dfrac{1}{2}$
    \item Forced text size in display: 
    \[
    \tfrac{1}{2}
    \]
\end{itemize}

When to use which?

  • Use \dfrac in text sparingly, as it can create ugly gaps between your lines of text.
  • Use \tfrac when you have fractions inside other fractions (nested fractions) to keep the overall expression from becoming excessively tall.

3. Nested Fractions and Continued Fractions

Mathematics often involves fractions within fractions. While you can simply nest \frac commands, the result can quickly become hard to read because the font size decreases with each level of nesting.

Nested Fractions

\[
x = \frac{1}{1 + \frac{a}{b}}
\]

If the nested fraction looks too small, you can use \dfrac for the inner parts:

\[
x = \frac{1}{1 + \dfrac{a}{b}}
\]

Continued Fractions

For continued fractions (common in number theory), the amsmath package provides a specialized command: \cfrac. This ensures that all parts of the fraction maintain a consistent, readable size.

\[
\pi = 3 + \cfrac{1}{7 + \cfrac{1}{15 + \cfrac{1}{1}}}
\]

4. Typesetting Binomial Coefficients

Binomial coefficients (often read as "$n$ choose $k$") are used extensively in statistics and combinatorics. They look like two numbers stacked vertically inside large parentheses.

In LaTeX, the standard command is \binom.

Syntax

\binom{n}{k}

Example

The number of ways to choose 2 items from 5 is given by:
\[
\binom{5}{2} = 10
\]

Just like fractions, binomials have size-specific variants:

  • \dbinom: Forces display size.
  • \tbinom: Forces text size.

5. Best Practices and Common Pitfalls

To create the most professional documents, keep these tips in mind:

Use Slanted Fractions for Simple Inline Text

For very simple fractions in the middle of a sentence (like 1/2 or 3/4), it is often stylistically better to use a forward slash / rather than \frac. This maintains the "color" and rhythm of the text block.

  • Good: "Add 1/2 cup of water..."
  • Too Bulky: "Add $\frac12$ cup of water..."

Don't Forget the Braces

A common mistake for beginners is omitting the curly braces {}. If you write \frac12, LaTeX will interpret the first two characters as the numerator and denominator. However, if you write \frac102, LaTeX will only see 1 and 0 as the arguments, leaving the 2 to sit awkwardly next to the fraction. Always use braces for clarity.

Grouping Complex Numerators

When your numerator or denominator contains multiple terms, ensure they are entirely enclosed within the braces:

% Correct
\frac{x^2 + 2x + 1}{x - 1}

% Incorrect (will result in an error or weird formatting)
\frac x^2 + 2x + 1 x - 1

6. Summary Table

CommandResult DescriptionBest Use Case
\frac{a}{b}Standard fractionGeneral use
\dfrac{a}{b}Large fractionInside text where size must be kept
\tfrac{a}{b}Small fractionInside large equations or matrices
\cfrac{a}{b}Continued fractionRecursive/Nested fractions
\binom{n}{k}Binomial coefficientCombinatorics and Probability

By mastering these commands, you can handle almost any fractional expression in your academic or technical documents. Practice by trying to typeset a complex formula from a textbook to get a feel for how nesting and sizing work together!