6

Just a quick question regarding aligning equations in LaTeX. Basically, this is a snippet of my source code:

\begin{align*}
  dU&=\partial Q - \partial W \\
  \partial Q &= dU + \partial W
\end{align*}
Since $U_E$ was already calculated, $U_A$ can be calculated using equation (1.1) as well:
\begin{align*}
  U_A&=\frac{3}{2}PV \\
  U_A&=\frac{3}{2}*10^5*10^{-3}\\
  U_A&=150J
\end{align*}

Now, the problem I'm facing is that the first align* tag is not aligned with the second one, I mean the equations are shifted. I'm not 100% sure why this happens or how to fix this.

  • Welcome to TeX.sx! Your post was migrated here from [so]. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Jan 25 '14 at 18:46

2 Answers2

8

use \intertext:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{align*}
  dU         &=\partial Q - \partial W \\
  \partial Q &= dU + \partial W
%
\intertext{Since $U_E$ was already calculated, $U_A$ can be calculated 
           using equation (1.1) as well:}
%
  U_A        &= \frac{3}{2}PV           \\
  U_A        &= \frac{3}{2}*10^5*10^{-3}\\
  U_A        &= 150J
\end{align*}

\end{document}
1

For keeping equations aligned I prefer using the array environment, i.e.

\begin{array}{ } 
    <similar syntax to align>
\end{array}

I've never noticed the problem you are mentioning with equations between multiple array environments not lining up consistently.

I think the other thing you have to get used to with using LaTeX is that there are things which you aren't really supposed to control because LaTeX by default does the right thing, even if it is contrary to what you have gotten used to doing from using ms word or other word processing software. LaTeX is WYSIWYM. Just worry about the structure of your document and trust LaTeX to make it look right.

  • Well I do trust it - and the result is that it doesn't align it properly. :P Thanks though, I did use array, and I got a similar situation. I wanted to attach a screenshot but couldn't yet. – ivanempire Feb 01 '14 at 20:55