Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

up vote 7 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.

share|improve this answer
    
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

share|improve this answer

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).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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