This answer works when you use the fleqn
package. The example below defines two LaTeX macros \mymidline
and \mylastline
. Both macros essentially expand to their first argument within align*
environments. The \mymidline
macro centers it and the \mylastline
macro right-aligns it. Thereby, the width of the stuff in the second argument is subtracted from the available "display width". For align*
environments that should just be the (longest) left-hand side of the equation. The example below shows how you can do that most efficiently with a macro \LHS
.
\documentclass{article}
\usepackage[DIV15]{typearea}
\usepackage{amsmath,amsfonts}
\usepackage{fleqn}
\usepackage{ulem}
\makeatletter
\newdimen\@tzadima
\newdimen\@tzadimb
\newbox\@tzaboxa
\def\mylinemeasures#1#2{%
\@tzadima\displaywidth%
\advance\@tzadima-\tagwidth@%
\advance\@tzadima-\alignsep@%
\setbox\@tzaboxa\hbox{$\displaystyle#1$}%
\@tzadimb\wd\@tzaboxa%
\advance\@tzadima-\@tzadimb%
\setbox\@tzaboxa\hbox{$\displaystyle#2$}%
\@tzadimb\wd\@tzaboxa%
\advance\@tzadima-\@tzadimb%
}
\def\mymidline#1#2{%
\mylinemeasures{#1}{#2}%
\divide\@tzadima2%
\hbox to \@tzadima{}#1\notag
}
\def\mylastline#1#2{%
\mylinemeasures{#1}{#2}%
\hbox to \@tzadima{}#1%
}
\makeatother
\begin{document}
\begin{align*}
\gdef\LHS{(L\cdot R)^{(i)}[i+1:n,i+1:n]}\LHS
&= \underbrace{L^{(i-1)}[i+1:n,1:i-1]\cdot R^{(i-1)}[1:i-1,i+1:n]}_{\text{untouched}}+\\
&\mymidline{+ L^{(i)}[i+1:n,i] \underbrace{R^{(i)}[i,i+1:n]}_{\text{untouched pivot row}}+}\LHS\\
&\mylastline{+ \underbrace{L^{(i)}[i+1:n,i+1:n]}_{=1_{n-i-1}}\cdot R^{(i)}[i+1:n,i+1:n]}\LHS\\
&= L^{(i-1)}[i+1:n,1:i-1]\cdot R^{(i-1)}[1:i-1,i+1:n]
+\\
&\mymidline{+ \uwave{L^{(i)}[i+1:n,i]\cdot R^{(i-1)}[i,i+1:n]}+}\LHS\\
&\mylastline{+R^{(i-1)}[i+1:n,i+1:n]\uwave{\strut- L^{(i)}[i+1:n,i]\cdot R^{(i-1)}[i,i+1:n]}}\LHS\\
&=L^{(i-1)}[i+1:n,1:i-1]\cdot R^{(i-1)}[1:i-1,i+1:n] +\\
&\mymidline{+ \underbrace{L^{(i-1)}[i+1:n,i]}_{=0}\cdot R^{(i-1)}[i,i+1:n] +}\LHS\\
&\mylastline{+ \underbrace{L^{(i-1)}[i+1:n,i+1:n]}_{=1_{n-i}}\cdot R^{(i-1)}[i+1:n,i+1:n]}\LHS\\
&= A[i+1:n,i+1:n].
\end{align*}
\end{document}

If you have the numbered version align*
you should also consider the width of the equation label and the label separator in the second argument of \mymidline
and \mylastline
.
I didn't find a predefined measure for the label width. After some tests it turned out that \quad\quad(1)
is an appropriate placeholder for the label.
\documentclass{article}
\usepackage[DIV15]{typearea}
\usepackage{amsmath,amsfonts}
\usepackage{fleqn}
\usepackage{ulem}
\makeatletter
\newdimen\@tzadima
\newdimen\@tzadimb
\newbox\@tzaboxa
\def\mylinemeasures#1#2{%
\@tzadima\displaywidth%
\advance\@tzadima-\tagwidth@%
\advance\@tzadima-\alignsep@%
\setbox\@tzaboxa\hbox{$\displaystyle#1$}%
\@tzadimb\wd\@tzaboxa%
\advance\@tzadima-\@tzadimb%
\setbox\@tzaboxa\hbox{$\displaystyle#2$}%
\@tzadimb\wd\@tzaboxa%
\advance\@tzadima-\@tzadimb%
}
\def\mymidline#1#2{%
\mylinemeasures{#1}{#2}%
\divide\@tzadima2%
\hbox to \@tzadima{}#1\notag
}
\def\mylastline#1#2{%
\mylinemeasures{#1}{#2}%
\hbox to \@tzadima{}#1%
}
\makeatother
\begin{document}
\begin{align}
\gdef\LHS{(L\cdot R)^{(i)}[i+1:n,i+1:n]}\LHS
&= \underbrace{L^{(i-1)}[i+1:n,1:i-1]\cdot R^{(i-1)}[1:i-1,i+1:n]}_{\text{untouched}}+\notag\\
&\mymidline{+ L^{(i)}[i+1:n,i] \underbrace{R^{(i)}[i,i+1:n]}_{\text{untouched pivot row}}+}\LHS\\
&\mylastline{+ \underbrace{L^{(i)}[i+1:n,i+1:n]}_{=1_{n-i-1}}\cdot R^{(i)}[i+1:n,i+1:n]}{\LHS\quad\quad(1)}\\
&= L^{(i-1)}[i+1:n,1:i-1]\cdot R^{(i-1)}[1:i-1,i+1:n] +\notag\\
&\mymidline{+ \uwave{L^{(i)}[i+1:n,i]\cdot R^{(i-1)}[i,i+1:n]}+}{(L\cdot R)^{(i)}[i+1:n,i+1:n]}\\
&\mylastline{+R^{(i-1)}[i+1:n,i+1:n]\uwave{\strut- L^{(i)}[i+1:n,i]\cdot R^{(i-1)}[i,i+1:n]}}{\LHS\quad\quad(1)}\\
&=L^{(i-1)}[i+1:n,1:i-1]\cdot R^{(i-1)}[1:i-1,i+1:n] +\notag\\
&\mymidline{+ \underbrace{L^{(i-1)}[i+1:n,i]}_{=0}\cdot R^{(i-1)}[i,i+1:n] +}{(L\cdot R)^{(i)}[i+1:n,i+1:n]}\\
&\mylastline{+ \underbrace{L^{(i-1)}[i+1:n,i+1:n]}_{=1_{n-i}}\cdot R^{(i-1)}[i+1:n,i+1:n]}{\LHS\quad\quad(1)}\\
&= A[i+1:n,i+1:n].
\end{align}
\end{document}

!
in front of it to turn it into a link. A moderator or another user with edit privileges can then reinsert the!
to turn it into an image again. – N.N. Feb 13 '12 at 19:57\documentclass
and the appropriate packages so that those trying to help don't have to recreate it. – Peter Grill Feb 13 '12 at 20:17split
for single long equations rather thanalign
. according to the document,split
is for single long equations,align
is for multiple equations. The numbering should be affected. – xuhdev Jan 15 '16 at 7:14