LaTeX Math Modes: \textstyle, \displaystyle, \scriptstyle, and \scriptscriptstyle

May. 09, 2024

For equations in LaTeX mathematical environments, there are four commands to specified their style1:

  • \textstyle (default for in-line math style): apply the style used for mathematics typeset in paragraphs.
  • \displaystyle (default for display math style): 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.

Here is an example to show the differences between them.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
\documentclass[a4paper,11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage[x11names]{xcolor}
\pagecolor{AntiqueWhite1}
\usepackage{lipsum}
\usepackage{amsmath}

\newcommand{\myequation}{f(n) = \sum_{i=0}^n \frac1n,\ g(x) = \int_0^1\frac1x\mathrm{d}x}
\newcommand{\mytext}{\lipsum[1][1-3]}

\begin{document}
\section{Inline equations (in-text equations)}
	 \verb|\textstyle| (\textcolor{red}{default}): $\textstyle \myequation$, (\mytext)
	 
	 \verb|\displaystyle|: $\displaystyle \myequation$, (\mytext)
	 
	 \verb|\scriptstyle|: $\scriptstyle \myequation$, (\mytext)
	 
	 \verb|\scriptscriptstyle|: $\scriptscriptstyle \myequation$, (\mytext)
	 
\section{Display equations}
	\verb|\textstyle|:
	(\mytext)
	\begin{equation}
		\textstyle \myequation
	\end{equation}
	\mytext
	
	\verb|\displaystyle| (\textcolor{red}{default}):
	(\mytext)
	\begin{equation}
		\displaystyle \myequation
	\end{equation}
	\mytext
	
	\verb|\scriptstyle|:
	(\mytext)
	\begin{equation}
		\scriptstyle \myequation
	\end{equation}
	\mytext
	
	\verb|\scriptscriptstyle|:
	(\mytext)
	\begin{equation}
		\scriptscriptstyle \myequation
	\end{equation}
	 \mytext
\end{document}

img-1

Before, I liked using \dfrac command to generate fraction sign. This is because that once I discovered the effect of \dfrac is better than \frac when I was a totally beginner for LaTeX, and kept this habit since then although I forget the specific reason why. But right now I find aforementioned commands don’t affect the parts generated by \dfrac.

For example, similarly for the above case, but at this time I replace \frac with \dfrac:

1
2
3
% ...
\newcommand{\myequation}{f(n) = \sum_{i=0}^n \dfrac1n,\ g(x) = \int_0^1\dfrac1x\mathrm{d}x}
% ...

then we have:

img-1

So, I search the reason on the Internet, and find it2:

  • \dfrac means that the fraction is set in displaystyle
  • \tfrac means that the fraction is set in textstyle
  • with \frac: the actual context implies the decision above.

Interesting!

References