Display Style in LaTeX Math: \displaystyle, \textstyle and Inline vs Display
Quick answer
- Inline math (
$...$) uses\textstyle; display math (\[...\]) uses\displaystyle. - Force the display look inline:
$\displaystyle \sum_{i=1}^n i$. - Only move the limits:
$\sum\limits_{i=1}^n i$. - Use
\[ \]orequation, not$$in LaTeX documents.
\documentclass{article}
\begin{document}
Text style: $\sum_{i=1}^{n} i = \frac{n(n+1)}{2}$.
Display style inline: $\displaystyle \sum_{i=1}^{n} i = \frac{n(n+1)}{2}$.
\end{document}The same formula looks different inline and on its own line: a sum's limits move to the side, fractions shrink, integrals get shorter. LaTeX does this on purpose, so that math inside a paragraph does not push the lines apart. This guide explains the four math styles behind that behaviour, the difference between $$, \[ \] and equation, and how to override the style with \displaystyle, \textstyle and \limits when the default is not what you want. Every example compiles with pdfLaTeX.
Inline vs Display Math
Inline math sits in the line of text. Display math gets its own centred line, with space above and below:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Inline, with dollars $a^2 + b^2 = c^2$ or parentheses \(a^2 + b^2 = c^2\).
Unnumbered display:
\[
\int_0^1 x^2 \, dx = \frac{1}{3}
\]
Numbered display:
\begin{equation}
\int_0^1 x^2 \, dx = \frac{1}{3}
\label{eq:int}
\end{equation}
Unnumbered with amsmath:
\begin{equation*}
\int_0^1 x^2 \, dx = \frac{1}{3}
\end{equation*}
\end{document}| Syntax | Kind | Numbered | Use in LaTeX? |
|---|---|---|---|
$...$, \(...\) | Inline | No | Yes |
\[...\] | Display | No | Yes |
equation* (amsmath) | Display | No | Yes, same as \[...\] |
equation | Display | Yes | Yes |
$$...$$ | Display | No | No: plain TeX, see below |
Why Not $$...$$?
$$ is the display syntax of plain TeX, which LaTeX is built on, so it still compiles. But LaTeX's own display code never runs. The visible consequences: the fleqn option no longer sets equations flush left, a display placed after a paragraph break gets the smaller “short” skip above it (\[ forces the normal one), and amsmath features such as \tag give an error. Replacing $$ with \[ and \] costs nothing and avoids all of them. More on choosing an environment in the mathematical expressions guide.
The Four Math Styles
Every piece of a formula is set in one of four styles. LaTeX chooses them automatically, and you can switch with a command that lasts to the end of the formula or the current group:
| Command | Used by default for | Effect |
|---|---|---|
\displaystyle | Display math | Large operators, limits above and below, full-size fractions |
\textstyle | Inline math; fraction parts in a display; matrix and cases cells | Normal size, limits to the side, small fractions |
\scriptstyle | Subscripts and superscripts; fraction parts inline | About 70% size |
\scriptscriptstyle | Scripts of scripts | About 50% size |
\documentclass{article}
\begin{document}
\[
\displaystyle \sum_{k=1}^{n} \frac{1}{k} \quad
\textstyle \sum_{k=1}^{n} \frac{1}{k} \quad
\scriptstyle \sum_{k=1}^{n} \frac{1}{k} \quad
\scriptscriptstyle \sum_{k=1}^{n} \frac{1}{k}
\]
\end{document}Each switch applies to everything after it, so the line above shrinks step by step. To change one part only, put it in braces: {\displaystyle \int_0^1 f}.
Sums, Integrals and Limits in a Line of Text
Inline, the limits of \sum, \prod and \lim go to the side. There are three ways to change that, from lightest to heaviest:
\documentclass{article}
\begin{document}
Default: $\sum_{i=1}^{n} x_i$ and $\lim_{x \to 0} f(x)$.
Limits only: $\sum\limits_{i=1}^{n} x_i$ and $\lim\limits_{x \to 0} f(x)$.
Full display: $\displaystyle \sum_{i=1}^{n} x_i$ and
$\displaystyle \int_0^1 f(x)\,dx$.
And the reverse, in a display:
\[
\sum\nolimits_{i=1}^{n} x_i \qquad \textstyle \sum_{i=1}^{n} x_i
\]
\end{document}\limits moves the limits but keeps the symbol small, so it disturbs the line spacing less than \displaystyle. \nolimits does the opposite in a display. For integrals, limits are beside the sign in every style; \int\limits puts them above and below. The integrals, sums and limits guide has more examples.
Fractions, Matrices and cases
Inside a fraction, a matrix or cases, LaTeX drops to text style, so a fraction in there comes out small even in a display. Use \dfrac for one fraction, or the display-style variants of the environment:
\documentclass{article}
\usepackage{mathtools} % loads amsmath, adds dcases
\begin{document}
\[
f(x) =
\begin{cases}
\frac{1}{x} & x > 0 \\
0 & x \le 0
\end{cases}
\qquad
f(x) =
\begin{dcases}
\frac{1}{x} & x > 0 \\
0 & x \le 0
\end{dcases}
\]
\[
\begin{pmatrix} \frac{1}{2} & 0 \\ 0 & \dfrac{1}{2} \end{pmatrix}
\]
\end{document}dcases comes from mathtools. The size rules for \frac, \dfrac and \tfrac are covered in fractions and binomials.
Common Mistakes
| Symptom | Cause | Fix |
|---|---|---|
| Uneven gaps between lines of a paragraph | \displaystyle or \dfrac inline | \limits, \frac, or move the formula into a display |
\displaystyle changes more than intended | It lasts to the end of the formula or group | Limit it with braces: {\displaystyle ...} |
Equations ignore fleqn or have odd spacing | $$...$$ | \[...\] or equation* |
| Limit controls must follow a math operator | \limits after something that is not an operator, such as a letter or \mathrm{max} | Use it only after \sum, \int, \lim or an operator declared with \DeclareMathOperator |
Small fractions in cases | Cells are in text style | dcases from mathtools, or \dfrac |
\everymath{\displaystyle} in the preamble | Forces display size on every inline formula | Remove it; apply styles where needed |
Frequently Asked Questions
What does \displaystyle do in LaTeX?
It switches math to display style, the size used for equations on their own line, until the end of the current formula or group. Inline, $\displaystyle \sum_{i=1}^n i$ puts the limits above and below the sum and draws it full size, and fractions get full-size numerators and denominators.
What is the difference between $$, \[ \] and equation?
\[ ... \] and equation* (amsmath) give an unnumbered displayed equation; equation gives a numbered one. $$ ... $$ is plain TeX syntax: it still compiles, but it ignores the fleqn option and can leave wrong vertical spacing, so LaTeX documents should use \[ ... \] instead.
How do I put limits above and below a sum in inline math?
Add \limits after the operator: $\sum\limits_{i=1}^{n} x_i$. Only the limits move; the symbol keeps its inline size. For the full display look, use $\displaystyle\sum_{i=1}^{n} x_i$, but expect it to push the lines of the paragraph apart.
What is the difference between inline and display math?
Inline math, written $...$ or \(...\), sits inside a line of text and is set in text style, compact enough to keep the line spacing even. Display math, written \[...\] or an environment such as equation, gets its own centred line and is set in display style, with larger operators and fractions.
Should I use \everymath{\displaystyle}?
Usually not. It makes every inline formula display size, which forces uneven line spacing throughout the document. Apply \displaystyle to the few formulas that need it, use \dfrac for a single fraction, or move a large formula into a display.
Next Steps
- Mathematical Expressions – Inline and display math from the start
- Fractions and Binomials – \frac, \dfrac, \tfrac and \binom
- Integrals, Sums and Limits – Operators with limits in every position
- Multiline Equations – align, split and gather for longer displays
- Equation Numbering – Numbered displays, \label and \eqref
Free LaTeX Tools
- LaTeX Preview – Compile any example above and see the result instantly
- AI LaTeX Generator – Describe a formula and get the LaTeX
Related Articles
Delta Math: Understanding Change and Difference in Mathematics
Omega Symbol (Ω ω): Definition, Meaning, and Uses in Math and Science
Delta Symbols in Math and Science: Complete Reference Guide
Fractions in LaTeX: Complete Guide to Mathematical Notation
Get the math right with AI
Octree's AI writes formulas from a description, turns $$ into proper displays and tidies inline sums, with the compiled PDF next to your code.