5

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.

1
  • 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 2

5

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.

enter image description here

\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}
1
  • 1
    Thanks so much, this is exactly what I was looking for! Commented Apr 6, 2020 at 17:22
4

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}

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .