Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The following equations need to be aligned in two spots. If I use the align* environment then the second column of alignment is pushed to the right edge of the page. I googled this and saw that alignat* was suggested. So I tried that, and now the numbers aren't aligned where the alignment symbol is. How should I align the following properly,

\documentclass{article}
\begin{document}
\begin{alignat*}{2}
    S(1)&=(1.05)S(0)=(1.05)(50000)&=52500\\
    S(2)&=(1.05)S(1)=(1.05)(52500)&=55125\\
    S(3)&=(1.05)S(2)=(1.05)(55125)&=57881.25\\
    S(4)&=(1.05)S(3)=(1.05)(57881.25)&\approx60775.31\\
    S(5)&=(1.05)S(4)\approx(1.05)(60775.31)&\approx63814.08\\
    S(6)&=(1.05)S(5)\approx(1.05)(63814.08)&\approx67004.78\\
    S(7)&=(1.05)S(6)\approx(1.05)(67004.78)&\approx70355.02\\
    S(8)&=(1.05)S(7)\approx(1.05)(70355.02)&\approx73872.77
\end{alignat*}
\end{document}

EDIT: Here is an image of what I want. I created it using the same code but using spaces to align the equals signs.

Example

share|improve this question
    
I like this question: in addition to the author having done their homework first, it's also about a somewhat obscure and difficult construction that needs some airing out. –  Ryan Reich Feb 5 '12 at 6:37
    
Please clarify your question with an image of what you want (a few minutes to mock something up in whatever simple graphics package comes with your system will be fine) and upgrade your code snippet to a minimal working example to allow people to copy, paste and experiment. –  qubyte Feb 5 '12 at 7:01
    
While I still believe my question was clear (the use of the words "aligned in two spots" along with two alignment symbols in the code), I have added the image and updated the code. –  gsingh2011 Feb 5 '12 at 7:07

1 Answer 1

up vote 11 down vote accepted

alignat alternates between right and left column alignment. So, you need to add an additional column to ensure that the last one is left aligned.

\begin{alignat*}{3}
    S(1)&=(1.05)S(0)=(1.05)(50000)         &&=2500\\
    S(2)&=(1.05)S(1)=(1.05)(52500)         &&=5125\\
    S(3)&=(1.05)S(2)=(1.05)(55125)         &&=7881.25\\
    S(4)&=(1.05)S(3)=(1.05)(57881.25)      &&\approx60775.31\\
    S(5)&=(1.05)S(4)\approx(1.05)(60775.31)&&\approx63814.08\\
    S(6)&=(1.05)S(5)\approx(1.05)(63814.08)&&\approx67004.78\\
    S(7)&=(1.05)S(6)\approx(1.05)(67004.78)&&\approx70355.02\\
    S(8)&=(1.05)S(7)\approx(1.05)(70355.02)&&\approx73872.77
\end{alignat*}
share|improve this answer
    
Thanks, this works nicely, but I have to add a space after the last & symbol when I use this method, as the alignment removes it for some reason. Not a big deal though, and thanks for the explanation as well. –  gsingh2011 Feb 5 '12 at 7:11
    
The equality symbols in the final column are a little close to the numbers. Could you put at little padding in? –  qubyte Feb 5 '12 at 7:11
3  
It would probably work better with &&= in place of &=&, because of this issue: tex.stackexchange.com/a/41091/575. –  Ryan Reich Feb 5 '12 at 7:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.