# Aligning long set of equations

I'm trying to make a big series of equation equalities in LaTeX, however, my equation just keeps going on out of the page width. Here is what I have:

$$TCU_{1,2}(y_1,y_2)=\frac{25}{4y_1}+\frac{125}{120-y_1} =\frac{25(120-y_1)}{(4y_1)(120-y_1)}+\frac{125(4y_1)}{(120-y_1)(4y_1)} \\ =\frac{25(120-y_1)+125(4y_1)}{(120-y_1)(4y_1)}=\frac{3000+475y_1}{(120-y_1)(4y_1)}$$


I need it to align beneath each other, how do I do this? I only use the amsmath package. and an article documentclass.

• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Jan 10 '15 at 19:56

Use split inside equation*

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation*}
\begin{split}
TCU_{1,2}(y_1,y_2)&=\frac{25}{4y_1}+\frac{125}{120-y_1} \\
&=\frac{25(120-y_1)}{(4y_1)(120-y_1)}+\frac{125(4y_1)}{(120-y_1)(4y_1)} \\
&=\frac{25(120-y_1)+125(4y_1)}{(120-y_1)(4y_1)}\\
&=\frac{3000+475y_1}{(120-y_1)(4y_1)}
\end{split}
\end{equation*}
\end{document}


If you want to number the equation, use the equation environment instead of equation*.

Also, don-t use $$..$$ in LaTeX. See Why is $...$ preferable to $$...$$? for reference.

• Thanks! Can you tell me the difference between and ? I haven't had to use before. Jan 10 '15 at 19:59
• @user70257 Take a look at the link in my answer. Jan 10 '15 at 20:00
• @user70257 And remember that you can accept the answer to mark the question as solved, if it solved your problem. See How do you accept an answer? Jan 10 '15 at 20:02
• @Pim -- take a look at Merge user accounts Jan 10 '15 at 20:22
• @Pim Use tex.stackexchange.com/contact to contact the StackExchange staff: they can merge your accounts together. Jan 10 '15 at 20:46

Here I use a left-aligned stack. The interline gap is settable with \setstackgap{S}{gap-size}. The default Shortstack gap is 3pt, which seems to small for my taste in this situation.

\documentclass{article}
\usepackage{amsmath}
\usepackage[usestackEOL]{stackengine}
\stackMath
\setstackgap{S}{8pt}% SETS GAP BETWEEN STACK LINES
\begin{document}
\begin{equation*}
TCU_{1,2}(y_1,y_2)\Shortunderstack[l]{
{}=\dfrac{25}{4y_1}+\dfrac{125}{120-y_1} \\
{}=\dfrac{25(120-y_1)}{(4y_1)(120-y_1)}+\dfrac{125(4y_1)}{(120-y_1)(4y_1)} \\
{}=\dfrac{25(120-y_1)+125(4y_1)}{(120-y_1)(4y_1)}\\
{}=\dfrac{3000+475y_1}{(120-y_1)(4y_1)}
}
\end{equation*}
\end{document}


The identical result could be obtained with a TABstack:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tabstackengine}
\stackMath
\setstackgap{S}{8pt}% SETS GAP BETWEEN STACK LINES
\begin{document}
\begin{equation*}
\alignShortunderstack{%
TCU_{1,2}(y_1,y_2)
=&\dfrac{25}{4y_1}+\dfrac{125}{120-y_1} \\
=&\dfrac{25(120-y_1)}{(4y_1)(120-y_1)}+\dfrac{125(4y_1)}{(120-y_1)(4y_1)} \\
=&\dfrac{25(120-y_1)+125(4y_1)}{(120-y_1)(4y_1)}\\
=&\dfrac{3000+475y_1}{(120-y_1)(4y_1)}
}
\end{equation*}
\end{document}

• I think I said it before, but I will say it again: the interface for that package is awful (just my opinion, don't worry), I think you should think about a better interface (proably with key-value optional arguments). It would gain usability and users. Jan 11 '15 at 2:37
• @Manuel I appreciate your input. Jan 11 '15 at 2:40
• Rereading, it may seem like “bad words”, I meant no “aggression”; while I really think your packages are useful, they lack of an acceptable interface. Jan 11 '15 at 2:47
• @Manuel I take it in the spirit in which it was intended, namely constructive criticism. Given lots of free time, I would move upon it, but that commodity has been in relatively short supply of late. Jan 11 '15 at 2:52