I have a multiline equation of the following type:

\begin{equation}
\begin{split}
f(x,y) & =a\\
& =b\\
& +c\\
& +d.
\end{split}
\end{equation}

But the output I would like to have is as follows:

 f(x,y) = a
        = b
          + c
          + d

That is, the lines continuing the sum shall have additional indentation, that is, the +'s shall not be directly below the "=". Whatever I tried didn't work as intended. Do you have any suggestions as of how to accomplish this?

up vote 12 down vote accepted

A simple solution with \phantom command:

\begin{equation}
\begin{split}
f(x,y) & =a\\
       & =b\\
       &\phantom{=}\, +c\\
       &\phantom{=}\, +d.
\end{split}
\end{equation}

gives:

enter image description here

This is the better looking alignment, in my opinion. Anyway, you can adjust it with spacing commands. For example, the following code

\begin{equation}
\begin{split}
f(x,y) & =a\\
       & =b\\
       &\phantom{=}\, +c\\
       &\quad +d\\
       &\phantom{=}\; +e.
\end{split}
\end{equation}

produces:

enter image description here

As you can see, a little spacing is added in consecutive lines.

  • I typically use \quad with is roughly of the size of \phantom{=}. – Bruno Le Floch Jul 10 '13 at 0:15
  • @BrunoLeFloch Thanks for your comment, I've added some more info in the answer. – karlkoeller Jul 10 '13 at 5:32

You can just "flip around" the use of the alignment character &:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\begin{equation}
  \begin{split}
    f(x,y) & =a \\
    & =b \\
    & +c \\
    & +d.
  \end{split}
\end{equation}

\begin{equation}
  \begin{split}
    f(x,y) ={}& a\\
    ={}& b \\
    & {}+c \\
    & {}+d.
  \end{split}
\end{equation}
\end{document}

The additional empty groups {} ensure the correct spacing around binary operators/relations. If you wish the alignment of the +s to be more aligned with the RHS of the equations above, you could also use:

\begin{equation}
  \begin{split}
    f(x,y) ={}& a\\
    ={}& b \\
    & \mskip-\medmuskip +c \\
    & \mskip-\medmuskip +d.
  \end{split}
\end{equation}

which removes the space around the binary operator +.

enter image description here

There are various answers here that explain how to achieve this manually, but I think that it is worth mentioning the breqn package, which attempts to automatically break long display math equations. Here is an example:

\documentclass{article}

\usepackage[a6paper]{geometry}
\usepackage{breqn}

\begin{document}

\begin{dmath*}
  f(x,y) = 2x( x^2 + 2x + 1) + 2y(y^2 + 2y + 1) 
  + 2z(z^2 + 2z + 1).
\end{dmath*}
\end{document}

which gives

enter image description here

Note that the + is automatically aligned at the right location. The breqn package is somewhat experimental. Do read its documentation for caveats; but when it works, it works beautifully.

While @Werner's answer works well for your particular case, if you actually need two (or more) explicit lines of alignment, you can use the alignedat environment:

\documentclass{report}
\usepackage{amsmath}
\begin{document}
\begin{equation}
    \begin{alignedat}{2}
    f(x) & ={} && a \\
        & ={} && b \\
        & && + c \\
        & && + d.
    \end{alignedat}
\end{equation}
\end{document}

(I do not include the picture, since the result is exactly the same as in Werner's answer; the trick with \mskip/\medmuskip can be applied as well).

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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