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'm trying to type a nice looking long sum of functions:

example of what looks okay

I managed to do it with combination of flalign* and \mspace:

\begin{flalign*}
f(a+h)-f(a)=&f(a_1+h_1,\dots\mspace{25mu}\dots,a_n+h_n)-f(a_1,\dots\mspace{120mu}\dots,a_n)=\\
=&f(a_1+h_1,a_2+h_2,\dots\mspace{1mu}\dots,a_n)-f(a_1,a_2,\dots\mspace{95mu}\dots,a_n)+\\
+&f(a_1+h_1,a_2+h_2,a_3,\dots,a_n)-f(a_1+h_1,a_2,\dots\mspace{55mu}\dots,a_n)+\\
&\dots\\
+&f(a_1+h_1,\dots\mspace{24mu}\dots,a_n+h_n)-f(a_1+h1,\dots,a_{n-1}+h_{n-1},a_n)\\
\end{flalign*}

I'm pretty happy with what I got, but here's my question: is it possible to make right brackets place themselves automatically in the right place? \phantom could help, if not for a_n+h_n instead of a_n bit. And is it possible to use another & pointer (say, &2), to mark the line of "-"s?

On the side note: how come this whole "reputation" does not allow me to make new tags? Aren't they suppose to, you know, HELP people?

share|improve this question
1  
Welcome to TeX.sx! when you say you would like the right brackets "in the right place", can i assume you mean that you want them aligned vertically? as a side note for you, you'd get better spacing if you put the & before equals signs and pluses, and add {} before any plus that begins a line and after any plus that ends a line. for some reasons, look at the answers to this question. –  barbara beeton Oct 12 '12 at 20:13
    
Concerning your side note: as I thought about answering it but couldn't find a really satisfying answer, I put it onto meta: Why is a certain reputation needed to create new tags? –  Benedikt Bauer Oct 12 '12 at 21:20

3 Answers 3

up vote 5 down vote accepted

enter image description here

You need to put the & before the + or = not after otherwise you do not get the correct spacing, note your image has operators without infix spacing at both ends, I think you just want more alignment points.

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{flalign*}
f(a+h)-f(a)&=f(a_1+h_1,\dots&\dots,a_n+h_n)&-f(a_1,\dots&\dots,a_n)={}\\
&=f(a_1+h_1,a_2+h_2,\dots&\dots,a_n)&-f(a_1,a_2,\dots&\dots,a_n)+{}\\
&+f(a_1+h_1,a_2+h_2,a_3,&\dots,a_n)&-f(a_1+h_1,a_2,\dots &\dots,a_n)+{}\\
&\dots\\
&+f(a_1+h_1,\dots&\dots,a_n+h_n)&-f(a_1+h1,&\dots,a_{n-1}+h_{n-1},a_n)\phantom{{}+{}}\\
\end{flalign*}
`



\end{document}
share|improve this answer
    
That is brilliant. Thanks for commenting on position of &, i thought it need to be after + or = or whatever, sothat the place s with "&"s are in line. –  user19502 Oct 12 '12 at 21:08

I don't think that this is a particularly nice way to express your thought.

However, this is one way that requires only to guess the widest vector, which can be done at a first stage. This is surely easier than guessing many spacings.

\documentclass{article}
\usepackage{amsmath}

\newlength{\providewdlen}
\newcommand{\providewd}[2]{
  \settowidth{\providewdlen}{$\displaystyle#1$}
  \makebox[\providewdlen][s]{$\displaystyle#2$}
}
\newcommand{\alignplus}{\mathrel{\providewd{=}{\hfill+}}}

\begin{document}
\begin{align*}
f(a+h)-f(a)
 &= 
    f(\providewd{a_1+h_1,a_2+h_2,\dots\dots,a_n}{a_1+h_1,\dots\hfill\dots,a_n+h_n})
   -f(\providewd{a_1+h1,\dots,a_{n-1}+h_{n-1},a_n}{a_1,\dots\hfill\dots,a_n})\\
 &=
    f(\providewd{a_1+h_1,a_2+h_2,a_3,\dots,a_n}{a_1+h_1,a_2,\dots\hfill\dots,a_n})
   -f(\providewd{a_1+h1,\dots,a_{n-1}+h_{n-1},a_n}{a_1,a_2,\dots\hfill\dots,a_n})\\
 &\alignplus
   f(a_1+h_1,a_2+h_2,a_3,\dots,a_n)
  -f(\providewd{a_1+h1,\dots,a_{n-1}+h_{n-1},a_n}{a_1+h_1,a_2,\dots\hfill\dots,a_n})\\
 & \dots\\
 &\alignplus
   f(\providewd{a_1+h_1,a_2+h_2,a_3,\dots,a_n}{a_1+h_1,\dots\hfill\dots,a_n+h_n})
  -f(a_1+h_1,\dots,a_{n-1}+h_{n-1},a_n)
\end{align*}


\end{document}

Notice that the symbols should not to be repeated at the end of the lines and that & goes before the alignment point. There should not be a trailing \\ in alignment environments.

Since the + is less wide than the =, we need to take care of that too. Note also that flalign* does nothing more than align* in this case; the differences can be seen when there is more than one alignment point.

enter image description here

My feeling is that a simpler approach could be clearer:

\begin{align*}
f(a+h)-f(a)
 &=f(a_1+h_1,\dots,a_n+h_n)-f(a_1,\dots,a_n)\\
 &=
   f(a_1+h_1,a_2,\dots,a_n)-f(a_1,a_2,\dots,a_n)\\
 &\alignplus
   f(a_1+h_1,a_2+h_2,a_3,\dots,a_n)-f(a_1+h_1,a_2,\dots,a_n)\\
 & \dots\\
 &\alignplus
   f(a_1+h_1,\dots,a_n+h_n)-f(a_1+h_1,\dots,a_{n-1}+h_{n-1},a_n)
\end{align*}

enter image description here

share|improve this answer

Notes:

  • I used the scrartcl class only because your original equation was to wide for the standard article class.
  • mathtools provides the \math?lap family and \vdotswithin.
  • I removed one of \dots if they are followed without space.
  • \hphantom intends the equations so that the second part is better aligned.
  • I used the alignat* environment because for one equation the flalign* environment doesn't do much. (There is of course no flalignat environment.)
  • I also removed = and + at the end of rows because I don't think that they make any sense there.

Code

\documentclass{scrartcl}
\usepackage{amsmath,mathtools}
\begin{document}
\begin{alignat*}{4}
f(a+h)-f(a) & = f(a_1 + h_1, \dots                             & \mathllap{\dots, a_n + h_n)} & {} - f(a_1, \dots          & \dots, a_n)   \\
            & = \hphantom{{}+{}} f(a_1 + h_1, a_2 + h_2,       &           \dots, a_n)        & {} - f(a_1, a_2, \mathrlap{\dots}     & \dots, a_n)   \\
            & \hphantom{{}={}} + f(a_1 + h_1, a_2 + h_2, a_3,  &        {} \dots, a_n)        & {} - f(a_1+h_1, \mathrlap{a_2, \dots} & \dots,a_n) \\
            & \hphantom{{}={}} \vdotswithin{+} \\
            & \hphantom{{}={}} + f(a_1+h_1,\dots               & \mathllap{\dots, a_n + h_n)} & {} - f(a_1+h_1,{} & \dots, a_{n-1}+h_{n-1},a_n)\\
\end{alignat*}
\end{document}

Output

enter image description here

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.