8

How to align the equation like that in picture

enter image description here

  • 1
    -1: This question is actually quite poor. The title references a picture, which doesn't help people searching through titles. Nor does it show any effort. – Werner Jul 5 '17 at 19:02
17

Nest aligned in align*:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align*}
\sum_{k=0}^{n} a_k(r^{n-k}x+(n-k)r^{n-k})
&= \begin{aligned}[t]
   &\biggl(\,\sum_{k=0}^{n} a_kr^{n-k}\biggr)xe^{rx}\\
   &+\biggl(\,\sum_{k=0}^{n-1} a_kr^{n-k-1}\biggr)xe^{rx}
   \end{aligned}
\\
&= p(r)xe^{rx}+p'(r)e^{rx}
\end{align*}

\end{document}

I have changed the original, which misuses \left and \right. In particular, the size of the parentheses around the summations was wrong.

enter image description here

If you need to fit this in a two column format, here's another suggestion.

\documentclass[twocolumn]{article}
\usepackage{amsmath}

\usepackage{lipsum} % for context, only for the example

\begin{document}

\lipsum*[2]
\begin{align*}
&\sum_{k=0}^{n} a_k(r^{n-k}x+(n-k)r^{n-k})
\\
&\quad=
   \biggl(\,\sum_{k=0}^{n} a_kr^{n-k}\biggr)xe^{rx}
   +\biggl(\,\sum_{k=0}^{n-1} a_kr^{n-k-1}\biggr)xe^{rx}
\\
&\quad= p(r)xe^{rx}+p'(r)e^{rx}
\end{align*}
\lipsum

\end{document}

enter image description here

A four line alternative doesn't seem as attractive, but you might have to resort to it in case the columns are narrower.

\documentclass[twocolumn]{article}
\usepackage{amsmath}

\usepackage{lipsum} % for context, only for the example

\begin{document}

\lipsum*[2]
\begin{align*}
&\sum_{k=0}^{n} a_k(r^{n-k}x+(n-k)r^{n-k})
\\
&\qquad=
   \begin{aligned}[t]
   &\biggl(\,\sum_{k=0}^{n} a_kr^{n-k}\biggr)xe^{rx}\\
   &+\biggl(\,\sum_{k=0}^{n-1} a_kr^{n-k-1}\biggr)xe^{rx}
   \end{aligned}
\\
&\qquad= p(r)xe^{rx}+p'(r)e^{rx}
\end{align*}
\lipsum

\end{document}

enter image description here

  • +1. To replicate the alignment shown in the OP's screenshot, it probably suffices to employ a single align* environment and to start the middle row with &\quad+\biggl(... right? – Mico Jul 3 '17 at 10:37
  • @Mico Possibly, but conceptually wrong. – egreg Jul 3 '17 at 10:39
  • are brackets that are not as high as the sum parameters really the correct way? imho the original looks better... – TheFlow0360 Jul 3 '17 at 15:38
  • 2
    @TheFlow0360 No, they look worse, trust me. ;-) – egreg Jul 3 '17 at 15:48
  • OK, let me rephrase it: is there any official guidance regarding that matter? because I always use \left and \right just like the original does (I don't write mathematical papers, though) – TheFlow0360 Jul 3 '17 at 16:20
8

Since this formula is essentially one equation broken into three lines, I'd suggest to use the split environment from amsmath. It fits better than align semantically. Also, notice that \quad before the + sign gives the desired space. The following code gives the result:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\begin{split}
\sum_{k=0}^{n-1}a_k(r^{n-k}x+(n-k)r^{n-k})
  &=\left(\sum_{k=0}^na_kr^{n-k}\right)xe^{rx}\\
  &\quad+\left(\sum_{k=0}^{n-1}a_k(n-k)r^{n-k-1}\right)e^{rx}\\
  &=p(r)xe^{rx}+p'(r)e^{rx}
\end{split}
\]
\end{document}

enter image description here

  • Instead of \quad before the plus sign, you should insert an empty group {} and let TeX do the spacing (before and after the plus sign). – jk - Reinstate Monica Jul 4 '17 at 8:26
  • The idea was to shift + more than just by a binop skip (the result matches the original picture, probably, I'd shift it even further). Anyway, spacing after the plus sign is correct. – Sergei Golovan Jul 4 '17 at 8:30
5

A variation of second @egreg example in his answer (for exercise, test different possibilities and fun, slightly unusual form ...):

\documentclass[twocolumn]{article}
\usepackage{mathtools}
\makeatletter
\let\origexp\exp% exrwndexp to e as math operator
\DeclareRobustCommand{\exp}{\@ifnextchar^{\Exp^{}}{\origexp }}
\def\Exp^#1{\mathop{\mathrm{e}\mkern -\thickmuskip}^{#1}\,}
\makeatother
\usepackage{lipsum} % for context, only for the example

\begin{document}
\lipsum*[2]
    \begin{align*}
\MoveEqLeft% macro from mathtools, move equation's lines to left
\sum_{k=0}^{n} a_k\left( r^{n-k}x+(n-k)r^{n-k}\right)                              \\
& = \left\lgroup \sum_{k=0}^{n} a_kr^{n-k}\right\rgroup x \exp^{rx}
  + \left\lgroup \sum_{k=0}^{n-1} a_kr^{n-k-1}\right\rgroup x\exp^{rx}  \\
& = p(r)x\exp(rx) + p'(r)\exp(rx)
    \end{align*}
\lipsum
\end{document}

enter image description here

0

I'd do it like this:

\begin{align*}
\sum_{k=0}^{n-1}a_k(r^{n-k}x+(n-k)r^{n-k})
=&\left(\sum_{k=0}^na_kr^{n-k}\right)xe^{rx}\\
 &+\left(\sum_{k=0}^{n-1}a_k(n-k)r^{n-k-1}\right)e^{rx}\\
=&p(r)xe^{rx}+p'(r)e^{rx}
\end{align*}

Perhaps not the best way to do it, but it works and isn't too hard for me to remember. Just put the divider on the opposite side of the equals sign.

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.