Understanding the Two Math Modes
In LaTeX, there are two primary ways to typeset mathematical expressions: Inline Mode and Display Mode.
- Inline Mode is used for math that appears within a sentence. It is designed to keep the line height consistent so that the text around it doesn't look awkward or stretched.
- Display Mode is used for important equations that deserve their own line. These expressions are centered and shown in a larger, more readable format with more vertical space.
"Display Style" refers specifically to the formatting rules LaTeX applies when it is in Display Mode. These rules affect how large symbols (like sums and integrals) look, where limits are placed, and how fractions are sized.
Basic Syntax: How to Trigger Display Style
To tell LaTeX to use Display Style, you typically use specific delimiters. While inline math uses single dollar signs ($ ... $), display math uses different brackets.
The Standard Display Environment
The most common way to write an equation in display style is using \[ and \].
The Pythagorean theorem is written as:
\[ a^2 + b^2 = c^2 \]
This appears on its own line and is centered.The Numbered Equation
If you want your equation to be numbered automatically, use the equation environment:
\begin{equation}
E = mc^2
\end{equation}Note: You might see older tutorials using double dollar signs (
$$ ... $$) for display math. While this works, it is considered "obsolete" in LaTeX because it can cause issues with spacing and doesn't play well with certain professional packages. Always prefer\[ ... \]or theequationenvironment.
Forcing Display Style with \displaystyle
Sometimes, you might want an inline formula (one inside a sentence) to look exactly like a display formula. For example, you might want a fraction to be large even though it's inside a paragraph.
You can force this behavior using the command \displaystyle.
Comparison Example
Notice the difference in the size of the fraction in this example:
Standard inline: $\frac{1}{2}$ \\
Forced display style inline: $\displaystyle \frac{1}{2}$When you use \displaystyle, LaTeX ignores the height restrictions of the current line and renders the math with full dimensions.
Warning: Using
\displaystyleinside a paragraph can create "uneven" line spacing (leading), making your text look messy. Use it sparingly.
Key Differences in Appearance
The transition from inline style to display style changes three main things: Fractions, Operators, and Limits.
1. Fractions
In inline mode, fractions are shrunk to fit the line. In display style, they use a full-sized font.
\[ \frac{x+y}{z} \] % Large and clear
vs.
$\frac{x+y}{z}$ % Small and compact2. Summations and Integrals
Large operators like \sum (sigma) and \int (integral) change size significantly.
Compare the summation symbol:
Inline: $\sum_{i=1}^{n} i$
Display: \[ \sum_{i=1}^{n} i \]3. Placement of Limits
In inline mode, limits (the numbers above and below symbols) are placed to the side to save vertical space. In display mode, they are placed directly above and below the symbol.
- Inline: $\lim_{x \to \infty}$ (Limit is to the bottom-right)
- Display: [ \lim_{x \to \infty} ] (Limit is directly underneath)
The Four Math Styles
LaTeX actually has four internal "styles" it uses to determine how math looks. Understanding these can help you fine-tune your documents:
- Display Style (
\displaystyle): Large, used for standalone equations. - Text Style (
\textstyle): The default for inline math ($...$). - Script Style (
\scriptstyle): Used for exponents and subscripts. - Script-Script Style (
\scriptscriptstyle): Used for "sub-subscripts" (exponents of exponents).
You can manually trigger any of these inside math mode. Here is a practical example of how they shrink:
\[
f(x) = \textstyle x \quad
\scriptstyle x \quad
\scriptscriptstyle x
\]Practical Example: A Complex Formula
Let's look at how display style makes a complex limit and sum formula much more readable. By using \[ ... \], LaTeX automatically applies \displaystyle to all the elements within the brackets.
\documentclass{article}
\usepackage{amsmath} % Recommended for all math documents
\begin{document}
In text, the definition of the derivative looks like this:
$f'(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}$.
However, presenting it in \textbf{display style} makes it much clearer for the reader:
\[
f'(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}
\]
Similarly, look at this summation:
\[
\sum_{k=1}^{\infty} \frac{1}{k^2} = \frac{\pi^2}{6}
\]
\end{document}Summary and Best Practices
To create professional-looking math in LaTeX, follow these guidelines:
- Use
\[ ... \]for most equations: It provides the best spacing and automatically uses display style. - Keep inline math simple: If a formula has large fractions or complex limits, it usually belongs on its own line in display style.
- Avoid
$$ ... $$: Stick to modern LaTeX delimiters for better compatibility. - Use the
amsmathpackage: Almost every math document should include\usepackage{amsmath}in the preamble. It improves the look of display style math and adds many helpful environments likealign. - Don't over-use
\displaystyleinside paragraphs: If you find yourself forcing display style inside a sentence frequently, it’s a sign that your math is too complex for inline text and should be moved to a displayed equation.
