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 want to show the derivation of a formula where I encounter long formulae. Unfortunately the derivation is very complex, so I have to show some intermediate steps.

My problem is, that I want to mix the behaviour of multline with align. The first line should be aligned left and the whole rest should be aligned right with respect to the longest line. This block should be aligned at the =.

At the moment, I use the align environment. But in this case, the first line is still aligned left to the $ of the other lines.

Important note: I don't like magic numbers. So I prefer solutions which are completely automatic.


My approach so far:

\documentclass{scrartcl}
% Kodierung
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
% Sprache (neue deutsche Rechtschreibung)
\usepackage[ngerman]{babel}
% Mathematik
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\begin{document}
    \begin{align}
        (a+b+c+d+e+f) \\ % aligned left
        % the following block should be aligned right
        &= a+b+c+d+e+f+g+h+i+j+k+l+m+n\\
    \begin{split}
        &= a+b+c+d+e+f+g+h+i+j+k+l+m+n \\
        & \quad +o+p+q+r+s+t+u+v+w+x+y+z+1+2+3+4
    \end{split}\\
        &= a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p
    \end{align}
\end{document}
share|improve this question
    
Related: tex.stackexchange.com/q/84345/21591 –  mafp Feb 15 '13 at 15:59

2 Answers 2

up vote 3 down vote accepted

Here is what I would do (require mathtools package)

\begin{align}
   \MoveEqLeft[3]  (a+b+c+d+e+f) \\ 
    ={}& a+b+c+d+e+f+g+h+i+j+k+l+m+n\\
\begin{split}
    ={}& a+b+c+d+e+f+g+h+i+j+k+l+m+n \\
    &  +o+p+q+r+s+t+u+v+w+x+y+z+1+2+3+4
\end{split}\\
    ={}& a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p
\end{align}

I would not want to start using multline effects in it, ends up looking strange. The above sort of follows the guides guides set out by the AMS.

enter image description here

share|improve this answer

Here is a version without magic numbers. It uses the mathtools to make the first line appear to have zero width.

\begin{align}
    \mathclap{(a+b+c+d+e+f)} & \notag \\
    &= a+b+c+d+e+f+g+h+i+j+k+l+m+n \\
    &= a+b+c+d+e+f+g+h+i+j+k+l+m+n \notag \\
    & \quad +o+p+q+r+s+t+u+v+w+x+y+z+1+2+3+4 \\
    &= a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p
\end{align}

with mathclap

share|improve this answer
    
Which gives you problems, if the lines are long, then the first line goes into the left margin. The magic number is not that magic, it is the number of ems to move the first line backwards. Plus it follows the MAS recommendstion about the indentation from the left –  daleif Feb 15 '13 at 13:44
    
I have to admit, that your answer is the best according to my question for shorter equations like daleif noted. I meant magic numbers like here where the length of the environment is given by the user. –  Stefan Feb 15 '13 at 13:49
1  
I would not use that constrction either. The only reason why I use a number here is because I align to the right of the =. The default is 2, as recommended by AMS –  daleif Feb 15 '13 at 13:51
    
@daleif I removed the 3 and aligned to the left of the = to follow the recommendation. –  Stefan Feb 15 '13 at 13:58
    
Then you have to add the \quad which is cumbersome (I have macros in my editor to do &= -> = {} & so I save some time). Besides, aligning to the right is not as often as aligning to the left. –  daleif Feb 15 '13 at 14:26

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.