Aligning an equation in two places

I have an equation that I want to look something like

a = b
= c
= 1/n[a_1 +
a_2 +
a_3 +
... +
a_n]


That is, I'd like the = signs to be aligned, and I'd like to align the a_ns as well. I suspect that the alignat environment is what I'd want to use here. What's throwing me off is that there's just blank space before each a_i, so there's not the "grid alignment" present here that alignat and align are built for. I'd really appreciate any help, and I hope my question is clear. Thanks very much.

• If you check all the related questions to the right, this almost qualifies as a FAQ. Commented Apr 6, 2020 at 15:04

2 Answers

You wrote

I'd like the = signs to be aligned, and I'd like to align the a_ns as well.

Here's a solution that nests an aligned environment in an align* environment.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
a &= b\\
&= c\\
&= 1/n[\begin{aligned}[t]
&a_1 +{} \\
&a_2 +{} \\
&a_3 +{} \\
&{\dotsb}+{} \\
&a_n]
\end{aligned}
\end{align*}
\end{document}

• Thanks so much, this is exactly what I was looking for! Commented Apr 6, 2020 at 17:22

It seems to work well with alignat.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{alignat*}{4}
a & = b                     \\
& = c                     \\
& = 1/n [ & a_1 & + {}    \\
&         & a_2 & + {}    \\
&         & a_3 & + {}    \\
&         & \hdots & + {} \\
&         & a_n &]
\end{alignat*}
\end{document}


• You may consider to replace \hdots with \dotsm. (+1) Commented Apr 6, 2020 at 15:31