Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LaTex, align alignment characters between align blocks

I would like to align two alignment characters between two align blocks so that I can have some text in the middle of a derivation with equations maintaining the horizontal alignment. For example the following excerpt of latex using align

\begin{align*}
    \frac{\delta \phi}{\delta x_1} = {} &\frac{9}{8}\frac{\delta_1\phi}{\delta_1x_1}-\frac{1}{8}\frac{\delta_3\phi}{\delta_3x_1} \\
    & \frac{9}{8}\frac{1}{h_1}\left[\phi(x_1+h_1/2)-\phi(x_i-h_1/2)\right]-\frac{1}{8}\frac{1}{3h_1}\left[\phi(x_i+3h_1/2)-\phi(x_1-3h_1/2)\right]
\end{align*}
some text in the middle
\begin{align*}
    & \frac{9}{8}\frac{1}{h_1}\left[\phi(x_1+h_1/2)-\phi(x_i-h_1/2)\right]-\frac{1}{8}\frac{1}{3h_1}\left[\phi(x_i+3h_1/2)-\phi(x_1-3h_1/2)\right]
\end{align*}

Ideally I would like the left of the equation in the second block to line up with that of the second equation in the first block. I could do a workaround by not having text in the middle, however, I would like this functionality.

EDIT

I would like to have a good amount of text between. Say three to four lines that line up as normal paragraphs. Adding text in the alignment block is the workaround I poorly alluded to.

like image 978
ccook Avatar asked May 12 '10 09:05

ccook


2 Answers

There is a very convenient command:

\begin{align*}
    \int_0^1 x^2 &= \frac{1}{3} \\
    \intertext{I am the intertext. I am typesetted as normal text but dude, 
               the tabbing/alignment is carried over to the next slide. 
               Check it out!}
    \int_0^1 x^3 &= \frac{1}{4}
\end{align*}

It's described in the ams userguide as far as I remember. But then, I also only discovered it very recently.

like image 169
Lagerbaer Avatar answered Sep 22 '22 17:09

Lagerbaer


Use \noalign:

\begin{align*} 
    \frac{\delta \phi}{\delta x_1} = {} &\frac{9}{8}\frac{\delta_1\phi}{\delta_1x_1}-\frac{1}{8}\frac{\delta_3\phi}{\delta_3x_1} \\ 
    & \frac{9}{8}\frac{1}{h_1}\left[\phi(x_1+h_1/2)-\phi(x_i-h_1/2)\right]-\frac{1}{8}\frac{1}{3h_1}\left[\phi(x_i+3h_1/2)-\phi(x_1-3h_1/2)\right]\\ 
    \noalign{\noindent some text in the middle.}
    & \frac{9}{8}\frac{1}{h_1}\left[\phi(x_1+h_1/2)-\phi(x_i-h_1/2)\right]-\frac{1}{8}\frac{1}{3h_1}\left[\phi(x_i+3h_1/2)-\phi(x_1-3h_1/2)\right] 
\end{align*} 
like image 45
Alexey Malistov Avatar answered Sep 22 '22 17:09

Alexey Malistov