2

I have three long sums (series) on three lines and want all plus signs be aligned vertivally just like in LaTeX code.

\begin{align}
x          &= 1 \cdot x &+ 0   \cdot x^2 &+ 0   \cdot x^3 &+ 0   \cdot x^4 &+ 0   \cdot x^5 &+ \ldots \\
x A_F(x)   &= 0 \cdot x &+ F_1 \cdot x^2 &+ F_2 \cdot x^3 &+ F_3 \cdot x^4 &+ F_4 \cdot x^5 &+ \ldots \\
x^2 A_F(x) &= 0 \cdot x &+ 0   \cdot x^2 &+ F_1 \cdot x^3 &+ F_2 \cdot x^4 &+ F_3 \cdot x^5 &+ \ldots
\end{align}

But result looks very bad.enter image description here Which environment should I use?

qx87
  • 23

3 Answers3

4

You want to use alignat, with some tricks:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{alignat}{5}
%         R L              L R             R L  L R             R L  L R             R L  L R             R L
x          &= 1 \cdot x +{} & 0   \cdot x^2 &+{} & 0   \cdot x^3 &+{} & 0   \cdot x^4 &+{} & 0   \cdot x^5 &+ \dotsb \\
x A_F(x)   &= 0 \cdot x +{} & F_1 \cdot x^2 &+{} & F_2 \cdot x^3 &+{} & F_3 \cdot x^4 &+{} & F_4 \cdot x^5 &+ \dotsb \\
x^2 A_F(x) &= 0 \cdot x +{} & 0   \cdot x^2 &+{} & F_1 \cdot x^3 &+{} & F_2 \cdot x^4 &+{} & F_3 \cdot x^5 &+ \dotsb
\end{alignat}

\end{document}

The tricks are meant so that every power of x appears in an odd numbered column, whereas the + signs are in even numbered columns. The {} ensure correct spacing.

The R and L tells you what's the alignment at either side of &

enter image description here

egreg
  • 1,121,712
  • But I can't understood the magic. Why there are two && in one of the columns? And what exactly {} does?

    There is very poor reference of alignat in the amsmath docs so I didn't fully det it. Maybe, there is somewhere better description?

    – qx87 Apr 03 '16 at 03:37
  • @qx87 I removed the &&, that had remained from a previous attempt. Basically, \begin{alignat}{<n>} sets up <n> pair of “right-left” aligned columns, with no space between each pair. – egreg Apr 03 '16 at 11:06
1

You can use directly \halign:

$$
\vbox{\baselineskip=1.2\baselineskip \halign{\hfil$\displaystyle#{}$&&\hfil$\displaystyle#{}$\cr
  x          =& 1\cdot x +& 0\cdot x^2   +& 0\cdot x^3   +& 0\cdot x^4 +& 0\cdot x^5     +& \cdots \cr
  x A_F(x)   =& 0\cdot x +& F_1\cdot x^2 +& F_2\cdot x^3 +& F_3\cdot x^4 +& F_4\cdot x^5 +& \cdots \cr
  x^2 A_F(x) =& 0\cdot x +& 0\cdot x^2   +& F_1\cdot x^3 +& F_2\cdot x^4 +& F_3\cdot x^5 +& \cdots \cr
}}$$
wipet
  • 74,238
1

For good measure, here's a LaTeX-based solution that uses just a basic array environment. That way, it's not necessary to enter the = and + symbols -- LaTeX can do this for you.

Note that I would used \cdots instead of \ldots for the typographic ellipses at the end of each equation.

enter image description here

\documentclass{article}
\begin{document}
\[
\begin{array}{ r@{{}={}} *{5}{r@{{}+{}}} c}
x          & 1 \cdot x & 0   \cdot x^2 & 0   \cdot x^3 & 0   \cdot x^4 & 0   \cdot x^5 & \cdots \\
x A_F(x)   & 0 \cdot x & F_1 \cdot x^2 & F_2 \cdot x^3 & F_3 \cdot x^4 & F_4 \cdot x^5 & \cdots \\
x^2 A_F(x) & 0 \cdot x & 0   \cdot x^2 & F_1 \cdot x^3 & F_2 \cdot x^4 & F_3 \cdot x^5 & \cdots
\end{array}
\]
\end{document}
Mico
  • 506,678
  • The original has align, so the lines are numbered. – egreg Apr 03 '16 at 10:56
  • @egreg - Indeed, this solution doesn't provide individual equation numbers. Let's see if the OP weighs in and states how important it is to him/her to have separate equation numbers. – Mico Apr 03 '16 at 11:02