views:

392

answers:

4

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.

+2  A: 

Try the following:

\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]\\
    & \mbox{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*}

If you have lots of text, you probably want to use \phantom:

\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, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text,
\begin{align*}
    \phantom{\frac{\delta \phi}{\delta x_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*}

If you don't want to use \phantom, the only solution I can come up with is the following:

\usepackage{multirow}
....
\begin{document}
\[ \begin{array}{rl}
        \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]\\[5mm]
\multicolumn{2}{l}{\parbox{\linewidth}{Some text in the middle, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text}}\\[1cm]
        & \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{array} \]
\end{document}

I don't think there is a straight forward way of "linking up" the width of one column of one table / eqnarray / align with another.

aioobe
This works with short text, however, with longer text it doesnt wrap properly. The left alignment also doesnt align with the paragraphs around it. Thanks though
ccook
See my edited answer.
aioobe
Thanks, but, is it possible to 'link' the two alignment characters? Using phantom would need me to create a phantom instance of the widest part of the first equation, no? It also wouldn't update the upper align from the lower align block. Or is this just not possible?
ccook
+1  A: 

If you don't have to much text, you can use the \text command from the math environment to display your text inside a single align* environment.

\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]\\
    \text{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*}
Lohrun
Thank you, though, the problem is I would like to have a good amount of text, say, a small paragraph.
ccook
+6  A: 

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*} 
Alexey Malistov
This works. Thank you
ccook
I've always used `\intertext` for this, instead of `\noalign`. Do you know if there's a difference between the two?
Antal S-Z
`\noalign` is inner TeX command. `\intertext` uses `\noalign` and it is `\ifvmode \else \\\@empty \fi \noalign {\penalty \postdisplaypenalty \vskip \belowdisplayskip \vbox {\normalbaselines \ifdim \linewidth =\columnwidt h \else \parshape \@ne \@totalleftmargin \linewidth \fi \noindent #1\par }\pena lty \predisplaypenalty \vskip \abovedisplayskip }`
Alexey Malistov
+3  A: 

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.

Lagerbaer
Nice find! Thanks!
ccook