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.

  • 1
    Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – karlkoeller 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} 

enter image description here

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 \begin{equation} and $$? I haven't had to use \begin{equation} before. – user70257 Jan 10 '15 at 19:59
  • @user70257 Take a look at the link in my answer. – karlkoeller Jan 10 '15 at 20:00
  • 1
    @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? – karlkoeller Jan 10 '15 at 20:02
  • 1
    @Pim -- take a look at Merge user accounts – barbara beeton Jan 10 '15 at 20:22
  • 1
    @Pim Use tex.stackexchange.com/contact to contact the StackExchange staff: they can merge your accounts together. – karlkoeller 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}

enter image description here


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. – Manuel Jan 11 '15 at 2:37
  • @Manuel I appreciate your input. – Steven B. Segletes 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. – Manuel 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. – Steven B. Segletes Jan 11 '15 at 2:52

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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