Math & ScienceSplitting formulae inside aligned equation

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
pzinn
Posts: 3
Joined: Thu Dec 22, 2011 1:10 pm

Splitting formulae inside aligned equation

Post by pzinn »

This may be a standard question, but in 15 years of (la)TeX I still haven't found a proper solution to the following problem:
suppose I'm writing a long calculation of the form
X= X1
= X2
= X3
etc
I use amslatex align environment to get all the = signs aligned.
so far, so good.
now, what if one of the r.h.s., say X2, is too long to fit on a line?
I'd like to be able to split it in such a way that the first half is aligned due to the equal sign, and the second half is *shoved to the right*. but despite the plethora of (semi-useless) commands in amslatex, there seems to be no way to position that second half properly. I end up using something like
&=X2a \\ &\hskip{5cm} X2b \\
where the actual hskip has to be adjusted for each equation. This is a very unsatisfactory solution. Anyone know a better one?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

Re: Splitting formulae inside aligned equation

Post by coachbennett1981 »

"Shoved to the right" On the same line?
pzinn
Posts: 3
Joined: Thu Dec 22, 2011 1:10 pm

Re: Splitting formulae inside aligned equation

Post by pzinn »

no, shoved to the right on the next line (since it's too long to fit on one)
Adrian10
Posts: 1
Joined: Fri Dec 23, 2011 11:27 am

Re: Splitting formulae inside aligned equation

Post by Adrian10 »

I have exactly the same problem...
pzinn
Posts: 3
Joined: Thu Dec 22, 2011 1:10 pm

Splitting formulae inside aligned equation

Post by pzinn »

fine, I'll answer myself...
Here's a possibility, but clearly not optimal:

Code: Select all

\newcommand\rightalign[1]{\noalign{\vbox{\hfill $\displaystyle #1$}}}

\begin{align*}
A&=B1
\\
&=B2a
\\
\rightalign{B2b}
&=B3
\end{align*}
(in particular should probably do something about tags/eqnos)
Last edited by Stefan Kottwitz on Mon Dec 26, 2011 9:19 pm, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Re: Splitting formulae inside aligned equation

Post by Stefan Kottwitz »

Great, thank you for posting the solution you found!

Stefan
LaTeX.org admin
Post Reply