Math & ScienceUn-aligned line within the align environment

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Enedrox
Posts: 8
Joined: Mon Mar 07, 2011 6:23 am

Un-aligned line within the align environment

Post by Enedrox »

I was wondering whether it is possible to tell LaTeX to ignoring aligning a particular line within the align environment in a similar way as it is possible to add/removing numbering of a particular line.

Additionally, is it possible to align cases to the surrounding align environment? If not (and assuming one can un-align a particular line), then I could simply add space before/after the cases in order to math the rest of the alignment, but this is a rather cumbersome way of doing it.

I realise one possibilty would be to have:

Code: Select all

\begin{align*}
The start
\end{align*}
\[ This is not aligned \]
\begin{align*}
the end
\end{align*}
except that the drawback with this is that the lining up in the second align environment no longer matches the first align.

My particular scenario is the following:

Code: Select all

\begin{align*}
	\frac{4}{x^3+2x^x} &= \frac{4}{x^2(x+2)} \\
	\frac{4}{x^2(x+2)} &\equiv \frac{A}{x} + \frac{B}{x^2} + \frac{C}{x+2} \\
	\therefore 0x^2+0x^1+4x^0 &= Ax(x+2) + B(x+2)+Cx^2 \\
	&= Ax^2+2Ax+Bx+2B+Cx^2 \\
	\begin{cases}	x^2: & 0 = A + C \\
						x^1: & 0 = 2A+B \\
						x^0: & 4 = 2B \\
			\end{cases} \\ % These cases should be, if possible, aligned with the surrounding environment
	A=-1, B=2, C=1 \\ % This line should be centered
	\frac{4}{x^2(x+2)} &\equiv \frac{-1}{x} + \frac{2}{x^2} + \frac{1}{x+2} \\
\end{align*}
Thanks!

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

achim
Posts: 49
Joined: Wed Aug 05, 2009 2:29 pm

Un-aligned line within the align environment

Post by achim »

I'm not too sure what you mean with the 'align cases' thing, but you can indeed 'unalign' things in-between the align environment and then go on with the same alignment as before.

Code: Select all

\begin{align*}
x &= \sin t
\intertext{Text in here will be printed as a normal paragraph. In here you can obviously use math code again, $E = mc^2$.}
x &= \cos 2t
\end{align*}
(I didn't run this code but it should work)

Cheers
OS: Kubuntu
Distribution: TexLive
Editor: Kile
Enedrox
Posts: 8
Joined: Mon Mar 07, 2011 6:23 am

Un-aligned line within the align environment

Post by Enedrox »

Inserting intertext which includes math mode would only just make this line aligned to the left. What I would like to know if it is possible is whether one could mark one line to by centered (but still in math mode) and then have the rest being all the same align environment. Something like:

Code: Select all

\begin{align*}
y &= ABC \\
&= XYZ \\
A=X, B=Y, C=Z \\% This is centered
ABC &= XYZ \\%The aligning continues just as before
I realise that one could write something like:

Code: Select all

\begin{align*}
y &= ABC \\
&= XYZ \\
\end{align*}
\[   A=X, B=Y, C=Z \]% This is centered
\begin{align*}
ABC &= XYZ \\%The aligning continues just as before
\end{align*}
but the problem is that the alignment of the = signs in the new align environment will not match the first align environment.


Lastly, what I talk about with the cases is whether it is possible to set the reference for the alignment (in this case the "&=") within the cases environment such that the equal signs in the cases environment align with the rest of the align environment. I'm guessing the latter is not possible because both environment use the "&" sign, but then I don't exactly know how LaTeX reads the file, hence the question.
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Un-aligned line within the align environment

Post by Juanjo »

Follow this scheme:

Code: Select all

\begin{align*}
   y &= ABC \\
     &= XYZ \\
   \noalign{\centering $A=X, B=Y, C=Z$}
   ABC &= XYZ
\end{align*}
So, for your particular scenario:

Code: Select all

\begin{align*}
   \frac{4}{x^3+2x^x} &= \frac{4}{x^2(x+2)} \\
   \frac{4}{x^2(x+2)} &\equiv \frac{A}{x} + \frac{B}{x^2} + \frac{C}{x+2} \\
   \therefore\ 0x^2+0x^1+4x^0 &= Ax(x+2) + B(x+2)+Cx^2 \\
   &= Ax^2+2Ax+Bx+2B+Cx^2 \\
   \noalign{\centering 
      $\begin{cases}   
         x^2: & 0 = A + C \\
         x^1: & 0 = 2A+B \\
         x^0: & 4 = 2B \\
       \end{cases}$ \\
      $A=-1,\ B=2,\ C=1$}
   \frac{4}{x^2(x+2)} &\equiv \frac{-1}{x} + \frac{2}{x^2} + \frac{1}{x+2}
\end{align*}
The \noalign command is Plain TeX. The mathtools package defines \shortintertext, which plays the same role (it is an improvement of \intertext). Note that you shouldn't write the \\ command at the end of the last line in the align environment. The aligment you search for the cases environment is a different matter.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
Post Reply