Display style in math mode
Introduction
This article explains how to manually adjust the style of typeset mathematics—but we’ll start with a quick reminder of the visible differences between inline and display style math.
Typeset mathematics contained inline (within) with the text of a paragraph needs to take less space than the same math typeset outside the paragraph text as standalone, display-style, material. To see this in practice, let’s explain that the equation \( f(x) = \sum_{i=0}^{n} \frac{a_i}{1+x} \) may diverge or converge depending on the value of \(x\). We can also typeset \(f(x)\) outside the paragraph in display style:
\[ f(x) = \sum_{i=0}^{n} \frac{a_i}{1+x} \]
Even a cursory glance at the previous example reveals changes in the size and formatting of math symbols, such as \(\sum\) and the placement of its limits, together with variations in size/positioning of superscripts, subscripts and fractions.
These mathematical typography issues are an interplay of typesetting algorithms built into TeX engines together with certain spacing parameters contained in math fonts. Those font parameters help fine-tune math typesetting according to the design characteristics of the math font(s) being used.
Overriding default mathematical styles
Occasionally you may want to change the default style used to typeset a piece of mathematics. For example, you might want to change inline math, such as \(f(x) = \frac{1}{1+x}\), and include it in the paragraph but typeset in display style: \(\displaystyle f(x) = \frac{1}{1+x}\), although it does impact heavily on the line spacing.
TeX engines provide several commands which can be used to override the default style in which a piece of math is typeset:
\textstyle
: apply the style used for mathematics typeset in paragraphs\displaystyle
: apply the style used for mathematics typeset on lines by themselves\scriptstyle
: apply the style used for subscripts or superscripts\scriptscriptstyle
: apply the style used for second-order subscripts or superscripts
The canonical example is taken from page 142 of the TeXBook, although we've replaced $$
by LaTeX's preferred \[
and \]
:
\[
a_0+{1\over a_1+
{1\over a_2+
{1 \over a_3 +
{1 \over a_4}}}}
\]
By default, this is typeset as:
\[a_0+{1\over a_1+{1\over a_2 +{1 \over a_3 + {1 \over a_4}}}}\]
The default typesetting style can be amended by using the \displaystyle
command:
\[
a_0+{1\over\displaystyle a_1+
{1\over\displaystyle a_2+
{1 \over\displaystyle a_3 +
{1 \over\displaystyle a_4}}}}
\]
yielding
\[a_0+{1\over\displaystyle a_1+{1\over\displaystyle a_2+{1 \over\displaystyle a_3 +{1 \over\displaystyle a_4}}}}\]
Here’s another example which demonstrates the effect of \textstyle
, \scriptstyle
and \scriptscriptstyle
:
\[
\begin{eqnarray*}
f(x) = \sum_{i=0}^{n} \frac{a_i}{1+x} \\
\textstyle f(x) = \textstyle \sum_{i=0}^{n} \frac{a_i}{1+x} \\
\scriptstyle f(x) = \scriptstyle \sum_{i=0}^{n} \frac{a_i}{1+x} \\
\scriptscriptstyle f(x) = \scriptscriptstyle \sum_{i=0}^{n} \frac{a_i}{1+x}
\end{eqnarray*}
\]
which renders as \[ \begin{eqnarray*} f(x) = \sum_{i=0}^{n} \frac{a_i}{1+x} \\ \textstyle f(x) = \textstyle \sum_{i=0}^{n} \frac{a_i}{1+x} \\ \scriptstyle f(x) = \scriptstyle \sum_{i=0}^{n} \frac{a_i}{1+x} \\ \scriptscriptstyle f(x) = \scriptscriptstyle \sum_{i=0}^{n} \frac{a_i}{1+x} \end{eqnarray*} \]
Here’s an example you can open in Overleaf:
\documentclass{article}
\usepackage{amsmath}
\title{Exploring math display styles}
\author{Overleaf team}
\begin{document}
\maketitle
Depending on the value of \(x\) the equation \( f(x) = \sum_{i=0}^{n} \frac{a_i}{1+x} \) may diverge or converge.
\[ f(x) = \sum_{i=0}^{n} \frac{a_i}{1+x} \]
\vspace{1cm}
Inline maths elements can be set with a different style: \(f(x) = \displaystyle \frac{1}{1+x}\). The same is true for display math material:
\begin{eqnarray*}
f(x) = \sum_{i=0}^{n} \frac{a_i}{1+x} \\
\textstyle f(x) = \sum_{i=0}^{n} \frac{a_i}{1+x} \\
\scriptstyle f(x) = \sum_{i=0}^{n} \frac{a_i}{1+x} \\
\scriptscriptstyle f(x) = \sum_{i=0}^{n} \frac{a_i}{1+x}
\end{eqnarray*}
\end{document}
Further reading
For more information see
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Debugging Compilation timeout errors
- How-to guides
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Fractions and Binomials
- Aligning Equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management in LaTeX
- Bibliography management with biblatex
- Biblatex bibliography styles
- Biblatex citation styles
- Bibliography management with natbib
- Natbib bibliography styles
- Natbib citation styles
- Bibliography management with bibtex
- Bibtex bibliography styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections and equations
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typing exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class
- Tips