# Aligning two sets of equations with alignat?

I'm having difficulties typing the following:

What I am getting with the code

\begin{alignat*}{4}
\end{alignat*}


is something like this:

I have tried very hard but cannot get the spacing right. Can someone please help me with this?

• Why alignat? A simple align does it: \documentclass{article} \usepackage{mathtools} \begin{document} \begin{align} f(x)&=x^{-1}, & f(2) &= 2^{-1}=\frac{1}{2},\\ f'(x)&=-x^{-2}, &f'(2) &=-\frac{1}{2^{2}},\\ f''(x)&=2!x^{-3}, &\frac{f''(2)}{2!}&=2^{-3}=\frac{1}{2^{3}},\\ f'''(x)&=-3!x^{-4}, &\frac{f'''(2)}{3!}&=-\frac{1}{2^{4}},\\ &\vdotswithin{=} & &\vdotswithin{=}\\ f^{(n)}(x)&=(-1)^{n}n!x^{-(n+1)}, & \frac{f^{(n)}(2)}{n!}&=\frac{(-1)^{n}}{2^{n+1}} \end{align} \end{document} – Schrödinger's cat Sep 18 '19 at 14:35
• You're using too many &'s – egreg Sep 18 '19 at 14:37
• Instead of &&\qquad&& f(2) && use &\qquad&& f(2) &. Each & provides an alternating r and l alignment point. – Peter Grill Sep 18 '19 at 14:39
• @Schrödinger'scat Thanks so much, I was led to believe this wasn't possible to do with align. Please leave your comment as an answer to this question. – J. Doe Sep 18 '19 at 14:48

OK, here we go. A simple align (of course with the appropriately set &) yields

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{align}
f(x)&=x^{-1}, & f(2) &= 2^{-1}=\frac{1}{2},\\
f'(x)&=-x^{-2},  &f'(2) &=-\frac{1}{2^{2}},\\
f''(x)&=2!x^{-3},  &\frac{f''(2)}{2!}&=2^{-3}=\frac{1}{2^{3}},\\
f'''(x)&=-3!x^{-4},  &\frac{f'''(2)}{3!}&=-\frac{1}{2^{4}},\\
&\vdotswithin{=} & &\vdotswithin{=}\\
f^{(n)}(x)&=(-1)^{n}n!x^{-(n+1)}, &  \frac{f^{(n)}(2)}{n!}&=\frac{(-1)^{n}}{2^{n+1}}
\end{align}
\end{document}


You have too many &'s. Just three per row suffice.

On the other hand, aligning at the = signs doesn't seem the best idea, as it creates irregular shapes and the = signs are not really related to one another, so I propose a different solution.

I also added \, after the ! when the factorial is immediately followed by another term.

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\begin{alignat*}{2}
f(x)&=x^{-1},         \qquad & f(2) &= 2^{-1}=\frac{1}{2},
\\
\\
\\
\\
\\
\end{alignat*}

\begin{alignat*}{2}
& f(x)=x^{-1},          && f(2) = 2^{-1}=\frac{1}{2},
\\[1ex]
& f'(x)=-x^{-2},        && f'(2) =-\frac{1}{2^{2}},
\\[1ex]
& f''(x)=2!\,x^{-3},    && \frac{f''(2)}{2!}=2^{-3}=\frac{1}{2^{3}},
\\[1ex]
& f'''(x)=-3!\,x^{-4},  && \frac{f'''(2)}{3!}=-\frac{1}{2^{4}},
\\