4

I'm having difficulties typing the following: enter image description here

What I am getting with the code

\begin{alignat*}{4}
        f(x)&=x^{-1}, &&\qquad&& f(2) &&= 2^{-1}=\frac{1}{2},\\
        f'(x)&=-x^{-2}, &&\qquad &&f'(2) &&=-\frac{1}{2^{2}},\\
        f''(x)&=2!x^{-3}, &&\qquad &&\frac{f''(2)}{2!}&&=2^{-3}=\frac{1}{2^{3}},\\
        f'''(x)&=-3!x^{-4}, &&\qquad &&\frac{f'''(2)}{3!}&&=-\frac{1}{2^{4}},\\
        &\vdotswithin{=}&&\qquad  &&\vdotswithin{=}&&\\
        f^{(n)}(x)&=(-1)^{n}n!x^{-(n+1)}, &&\qquad&&  \frac{f^{(n)}(2)}{n!}&&=\frac{(-1)^{n}}{2^{n+1}}.
    \end{alignat*}

is something like this: enter image description here

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

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

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}      

enter image description here

4

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},
\\
f'(x)&=-x^{-2},       \qquad & f'(2) &=-\frac{1}{2^{2}},
\\
f''(x)&=2!\,x^{-3},   \qquad & \frac{f''(2)}{2!}&=2^{-3}=\frac{1}{2^{3}},
\\
f'''(x)&=-3!\,x^{-4}, \qquad & \frac{f'''(2)}{3!}&=-\frac{1}{2^{4}},
\\
&\vdotswithin{=}      \qquad & & \vdotswithin{=}
\\
f^{(n)}(x)&=(-1)^{n}n!\,x^{-(n+1)}, \qquad &  \frac{f^{(n)}(2)}{n!}&=\frac{(-1)^{n}}{2^{n+1}}.
\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}},
\\
&\qquad\vdots           && \qquad\vdots
\\
& f^{(n)}(x)=(-1)^{n}n!\,x^{-(n+1)},\qquad  &&  \frac{f^{(n)}(2)}{n!}=\frac{(-1)^{n}}{2^{n+1}}.
\end{alignat*}

\end{document}

enter image description here

  • Thank you, this is very nice. And the vertical dot placement according to your suggesting is perfectly fine also. Putting \, after ! also makes things less cluttered. I hope your know that your help is very much appreciated. – J. Doe Sep 18 '19 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.