# Is amsmath aligned environment displaystyle by default?

Is the aligned environment automatically \displaystyle? This test seems to indicate it is:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{aligned} \int_{0}^{\pi}f(x)dx &= \frac{1}{\pi} \\ \end{aligned}

$$\int_{0}^{\pi}f(x)dx = \frac{1}{\pi}$$
\end{document}


Additionally, amsmath.sty contains the following code:

\newcommand{\start@aligned}[2]{%
\RIfM@\else
\nonmatherr@{\begin{\@currenvir}}%
\fi
\savecolumn@ % Assumption: called inside a group
\alignedspace@left
\if #1t\vtop \else \if#1b \vbox \else \vcenter \fi \fi \bgroup
\maxfields@#2\relax
\ifnum\maxfields@>\m@ne
\multiply\maxfields@\tw@
\let\math@cr@@@\math@cr@@@alignedat
\alignsep@\z@skip
\else
\let\math@cr@@@\math@cr@@@aligned
\alignsep@\minalignsep
\fi
\Let@ \chardef\dspbrk@context\@ne
\default@tag
\global\column@\z@
\ialign\bgroup
&\column@plus
\hfil
\strut@
$\m@th\displaystyle{##}$%
\tabskip\z@skip
&\column@plus
$\m@th\displaystyle{{}##}$%
\hfil
\tabskip\alignsep@
\crcr
}


Unfortunately, I'm not much of a tex hacker so I can't be sure but the macro definition does include \displaystyle. However, I wasn't able to track this information down in the documentation. Section 3 (amsmath user guide) lists displayed equations but aligned is not among them.

Is there a good way to determine whether a given math environment is \displaystyle? Normally, I would have assumed inline math defaults to non-display but the aligned environment is used inside  or .

• Yes, every cell in the underlying \halign has \m@th\displaysyle, so it uses that style. – egreg Dec 6 '19 at 16:12
• The alignment building blocks are described in Sec. 3.7 of the documentation. – campa Dec 6 '19 at 16:32
• There are only four math styles, \displaystyle, \textstyle, \scriptstyle and \scriptscriptstyle. You can tell the first two apart by using \sum_1^2. – John Kormylo Dec 6 '19 at 16:51

The code contains the piece

\ialign\bgroup % spaces before and after & included for clarity
& \hfil$\m@th\displaystyle{#}$ & $\m@th\displaystyle{{}#}$\hfil \crcr
%        \____________  ____________/   \_____________  _____________/
%                     \/                               \/
%         first column specification       second column specification


I have deleted a lot of stuff which is irrelevant to the point; I have also introduced spaces around the ampersand & for clarity, though the space before it is actually important; and I have replaced ## by a single #, since the doubling stems from the usual TeX rules for nested definitions. Forget the first & for the time being. \ialign is an initialized form of \halign, the TeX primitive for horizontal alignment (it sets the intercolumn distance to zero). The first column has the specification

\hfil $\m@th\displaystyle{#}$


which means "right-aligned, displaystyle math". Using the notation of the array package this would be a column specifier of the form

>{$\m@th\displaystyle}r<{$}


The second column contains

$\m@th\displaystyle{{}#}$\hfil


which means "left-aligned, displaystyle math, and start with an empty \mathord atom" (important for correct spacing).

What about the first & in the line, which I first told to ignore? That is a TeX construct; quoting from the TeXBook (p. 241)

Preambles often have a periodic structure, and if you put an extra & just before one of the templates, TeX will consider the preamble to be an infinite sequence that begins again at the marked template when the \cr is reached.

Therefore, this sequence of right-aligned, left-aligned columns can be repeated indefinitely. So the aligned environment corresponds basically to a tabular with repeating rlrlrlrl... columns, all in displaystyle math mode.