## Multi-line Equation Problem in Latex

 Quote by Fenn Alright, I found my answer, in case anyone is looking. It's the subequations environment from the amsmath package. \begin{align} I = \begin{pmatrix} 1 & 0 \\ 0 & 1\end{pmatrix} \end{align} \begin{subequations}\begin{align} f &= ma\\ E &= mc^2\\ \pi &\text{ is exactly three!} \end{align}\end{subequations}
It is nice Fenn, thank you. I may re-consider the numbering of certain equations based on this.

Regards
 I'm now using them for clusters of similar equations, so my index numbers don't get too outrageous. \begin{subequations}\begin{align} Y_1^{+1}(\theta,\phi) &= -\sqrt{\frac{3}{8\pi}}\sin\theta e^{i\phi} \\ Y_1^0(\theta,\phi) &= \sqrt{\frac{3}{4\pi}}\cos\theta \\ Y_1^{-1}(\theta,\phi) &= \sqrt{\frac{3}{8\pi}}\sin\theta e^{-i\phi} \end{align}\end{subequations}
 Recognitions: Science Advisor \begin{subequations} \begin{align} \frac{u(x_0+\Delta x)-u(x_0)}{\Delta x} &=\frac{du}{dx} + \frac{\Delta x}{2}\frac{d^2 u}{dx^2} +\cdots \\ \frac{u(x_0)-u(x_0-\Delta x)}{\Delta x} &=\frac{du}{dx} - \frac{\Delta x}{2}\frac{d^2 u}{dx^2} +\cdots \\ \frac{u(x_0+\Delta x)-u(x_0-\Delta x)}{\Delta x} &= \frac{du}{dx} + \frac{\Delta x^2}{6}\frac{d^3 u}{dx^3}+ \cdots \end{align} \end{subequations} Nice!! big fan!
 Hi Fenn, I tried this but it didn't work. I don't know what else to do. Please help. TQ
 Hi sni, Can you be more informative about what you are trying to do, and how it is not working?
 i tried using \newln but the equation still exceeds the page.
 Could you please post an example of what you are trying to do? These forums will parse LaTeX formatting if you enclose it within the a set of [ tex ] and [ /tex ] delimiters (remove the spaces to get them to work.) eg: $$\newcommand{\parenthnewln}[1]{\right.\\#1&\left.{}} \begin{split} f(x)=1+&g(x)\\ =1+&\left(x+x^2+\dots \parenthnewln{+}x^n+\ldots\right) \end{split}$$ You can also show your code verbatim by enclosing it in [ code ] and [ /code ] delimiters. Code: \newcommand{\parenthnewln}[1]{\right.\\#1&\left.{}} $$\begin{split} f(x)=1+&g(x)\\ =1+&\left(x+x^2+\dots \parenthnewln{+}x^n+\ldots\right) \end{split}$$
 $$\begin{eqnarray} \begin{split} \frac{1}{2}v(e^{X}P_{1}+2e^{X}\frac{\partial P_{1}}{\partial X}+e^{X}\frac{\partial^2 P_{1}}{\partial X^2}-Ke^{-r(T-t)}\frac{\partial^2 P_{2}}{\partial X^2})+(r-\frac{1}{2}v)(e^{X}P_{1}+e^{X}\frac{\partial P_{1}}{\partial X}-Ke^{-r(T-t)}\frac{\partial P_{2}}{\partial X}) \\ + \rho\sigma v(e^{X}\frac{\partial P_{1}}{\partial v}+e^{X}\frac{\partial^2 P_{1}}{\partial X\partial v} -Ke^{-r(T-t)}\frac{\partial^2 P_{2}}{\partial X\partial v})+\frac{1}{2}v\sigma^2(e^{X}\frac{\partial^2 P_{1}}{\partial v^2}-Ke^{-r(T-t)}\frac{\partial^2 P_{2}}{\partial v^2}) +[\kappa(\theta-v)-\lambda v] \\ (e^{X}\frac{\partial P_{1}}{\partial v}-Ke^{-r(T-t)}\frac{\partial P_{2}}{\partial v})-r(e^{X}P_{1}-Ke^{-r(T-t)}P_{2})+(e^{X}\frac{\partial P_{1}}{\partial t}-rKe^{-r(T-t)}\partial P_{2}-Ke^{-r(T-t)}\frac{\partial P_{2}}{\partial t}) = 0 e^{X}\left[\frac{1}{2}v\frac{\partial^2 P_{1}}{\partial X^2}+\rho\sigma v\frac{\partial^2 P_{1}}{\partial X\partial v}+\frac{1}{2}v\sigma^2\frac{\partial^2 P_{1}}{\partial v^2} +[\kappa(\theta-v)-\lambda v]\frac{\partial P_{1}}{\partial v}+(r+\frac{1}{2}v)\frac{\partial P_{1}}{\partial X}+\frac{\partial P_{1}}{\partial t}\right] \\ - Ke^{-r(T-t)}\left[\frac{1}{2}v\frac{\partial^2 P_{2}}{\partial X^2}+\rho\sigma v\frac{\partial^2 P_{2}}{\partial X\partial v}+\frac{1}{2}v\sigma^2\frac{\partial^2 P_{2}}{\partial v^2}+[\kappa(\theta-v)-\lambda v]\frac{\partial P_{2}}{\partial v}+(r-\frac{1}{2}v)\frac{\partial P_{2}}{\partial X}+\frac{\partial P_{2}}{\partial t}\right] &=& 0 \end{split} \end{eqnarray} [\tex]  Here's a quick tweaking of your markup, where I have used a modified version of these \newln and \parenthnewln commands that I suggested in an earlier post: [tex] \newcommand{\newln}{\\&\hspace{2em}} \newcommand{\parenthnewln}{\right.\newln\left.{}} \begin{eqnarray} \begin{split} \frac{1}{2}v&(e^{X}P_{1}+2e^{X}\frac{\partial P_{1}}{\partial X}+e^{X}\frac{\partial^2 P_{1}}{\partial X^2}-Ke^{-r(T-t)}\frac{\partial^2 P_{2}}{\partial X^2})&\newln % +(r-\frac{1}{2}v)(e^{X}P_{1}+e^{X}\frac{\partial P_{1}}{\partial X}-Ke^{-r(T-t)}\frac{\partial P_{2}}{\partial X})&\newln % +\rho\sigma v(e^{X}\frac{\partial P_{1}}{\partial v}+e^{X}\frac{\partial^2 P_{1}}{\partial X\partial v} -Ke^{-r(T-t)}\frac{\partial^2 P_{2}}{\partial X\partial v})\newln % +\frac{1}{2}v\sigma^2(e^{X}\frac{\partial^2 P_{1}}{\partial v^2}-Ke^{-r(T-t)}\frac{\partial^2 P_{2}}{\partial v^2})&\newln % +[\kappa(\theta-v)-\lambda v] (e^{X}\frac{\partial P_{1}}{\partial v}-Ke^{-r(T-t)}\frac{\partial P_{2}}{\partial v})&\newln % -r(e^{X}P_{1}-Ke^{-r(T-t)}P_{2})\newln % +(e^{X}\frac{\partial P_{1}}{\partial t}-rKe^{-r(T-t)}\partial P_{2}-Ke^{-r(T-t)}\frac{\partial P_{2}}{\partial t}) &= 0\\ % e^{X}&\left[\frac{1}{2}v\frac{\partial^2 P_{1}}{\partial X^2}+\rho\sigma v\frac{\partial^2 P_{1}}{\partial X\partial v} % +\frac{1}{2}v\sigma^2\frac{\partial^2 P_{1}}{\partial v^2}\parenthnewln % +[\kappa(\theta-v)-\lambda v]\frac{\partial P_{1}}{\partial v}+(r+\frac{1}{2}v)\frac{\partial P_{1}}{\partial X}+\frac{\partial P_{1}}{\partial t}\right]\newln % -Ke^{-r(T-t)}\left[\frac{1}{2}v\frac{\partial^2 P_{2}}{\partial X^2}+\rho\sigma v\frac{\partial^2 P_{2}}{\partial X\partial v}\parenthnewln % +\frac{1}{2}v\sigma^2\frac{\partial^2 P_{2}}{\partial v^2}\parenthnewln % +[\kappa(\theta-v)-\lambda v]\frac{\partial P_{2}}{\partial v}+(r-\frac{1}{2}v)\frac{\partial P_{2}}{\partial X}+\frac{\partial P_{2}}{\partial t}\right] &= 0 \end{split} \end{eqnarray}$$ For some reason the [ tex ] markup does not appear to be working properly, so I have included the code as well. Code: \newcommand{\newln}{\\&\hspace{2em}} \newcommand{\parenthnewln}{\right.\newln\left.{}} \begin{eqnarray} \begin{split} \frac{1}{2}v&(e^{X}P_{1}+2e^{X}\frac{\partial P_{1}}{\partial X}+e^{X}\frac{\partial^2 P_{1}}{\partial X^2}-Ke^{-r(T-t)}\frac{\partial^2 P_{2}}{\partial X^2})&\newln % +(r-\frac{1}{2}v)(e^{X}P_{1}+e^{X}\frac{\partial P_{1}}{\partial X}-Ke^{-r(T-t)}\frac{\partial P_{2}}{\partial X})&\newln % +\rho\sigma v(e^{X}\frac{\partial P_{1}}{\partial v}+e^{X}\frac{\partial^2 P_{1}}{\partial X\partial v} -Ke^{-r(T-t)}\frac{\partial^2 P_{2}}{\partial X\partial v})\newln % +\frac{1}{2}v\sigma^2(e^{X}\frac{\partial^2 P_{1}}{\partial v^2}-Ke^{-r(T-t)}\frac{\partial^2 P_{2}}{\partial v^2})&\newln % +[\kappa(\theta-v)-\lambda v] (e^{X}\frac{\partial P_{1}}{\partial v}-Ke^{-r(T-t)}\frac{\partial P_{2}}{\partial v})&\newln % -r(e^{X}P_{1}-Ke^{-r(T-t)}P_{2})\newln % +(e^{X}\frac{\partial P_{1}}{\partial t}-rKe^{-r(T-t)}\partial P_{2}-Ke^{-r(T-t)}\frac{\partial P_{2}}{\partial t}) &= 0\\ % e^{X}&\left[\frac{1}{2}v\frac{\partial^2 P_{1}}{\partial X^2}+\rho\sigma v\frac{\partial^2 P_{1}}{\partial X\partial v} % +\frac{1}{2}v\sigma^2\frac{\partial^2 P_{1}}{\partial v^2}\parenthnewln % +[\kappa(\theta-v)-\lambda v]\frac{\partial P_{1}}{\partial v}+(r+\frac{1}{2}v)\frac{\partial P_{1}}{\partial X}+\frac{\partial P_{1}}{\partial t}\right]\newln % -Ke^{-r(T-t)}\left[\frac{1}{2}v\frac{\partial^2 P_{2}}{\partial X^2}+\rho\sigma v\frac{\partial^2 P_{2}}{\partial X\partial v}\parenthnewln % +\frac{1}{2}v\sigma^2\frac{\partial^2 P_{2}}{\partial v^2}\parenthnewln % +[\kappa(\theta-v)-\lambda v]\frac{\partial P_{2}}{\partial v}+(r-\frac{1}{2}v)\frac{\partial P_{2}}{\partial X}+\frac{\partial P_{2}}{\partial t}\right] &= 0 \end{split} \end{eqnarray} I have put new lines within an equation using the \newln command. If the new line is within a set of parenthesis (the \left[ and \right]), then I use \parenthnewln. Remember that you can always add white space (blank lines need the % comment in equation environments) to make your work more legible.
 thank you so much! this looks so nice. does it only work to one single equation? can it be used for multiple equations e.g proof?thanks
 Fenn, I labeled the code \end{split}\label{eq:eu}\end{eqnarray} but the equation number disappears. I want it to be on the second formula.why is this so? the referencing works fine as the equation number shows

Hi Fenn, I have tried on other LONG equations that I have. Unfortunately, not all worked out fine. Some were indented to half of the page and gone missing for the second half. I realize that this happens with multi equations where for example

\begin{eqnarray}
Eq 1 (Long) = Eq 2 (Long)
Eq 3 (Long) = Eq 4 (Long)
\end{eqnarray}

Hope you can help me with this problem. I have tons of equations to adjust. TQ so much

 Quote by Fenn Here's a quick tweaking of your markup, where I have used a modified version of these \newln and \parenthnewln commands that I suggested in an earlier post: $$\newcommand{\newln}{\\&\hspace{2em}} \newcommand{\parenthnewln}{\right.\newln\left.{}} \begin{eqnarray} \begin{split} \frac{1}{2}v&(e^{X}P_{1}+2e^{X}\frac{\partial P_{1}}{\partial X}+e^{X}\frac{\partial^2 P_{1}}{\partial X^2}-Ke^{-r(T-t)}\frac{\partial^2 P_{2}}{\partial X^2})&\newln % +(r-\frac{1}{2}v)(e^{X}P_{1}+e^{X}\frac{\partial P_{1}}{\partial X}-Ke^{-r(T-t)}\frac{\partial P_{2}}{\partial X})&\newln % +\rho\sigma v(e^{X}\frac{\partial P_{1}}{\partial v}+e^{X}\frac{\partial^2 P_{1}}{\partial X\partial v} -Ke^{-r(T-t)}\frac{\partial^2 P_{2}}{\partial X\partial v})\newln % +\frac{1}{2}v\sigma^2(e^{X}\frac{\partial^2 P_{1}}{\partial v^2}-Ke^{-r(T-t)}\frac{\partial^2 P_{2}}{\partial v^2})&\newln % +[\kappa(\theta-v)-\lambda v] (e^{X}\frac{\partial P_{1}}{\partial v}-Ke^{-r(T-t)}\frac{\partial P_{2}}{\partial v})&\newln % -r(e^{X}P_{1}-Ke^{-r(T-t)}P_{2})\newln % +(e^{X}\frac{\partial P_{1}}{\partial t}-rKe^{-r(T-t)}\partial P_{2}-Ke^{-r(T-t)}\frac{\partial P_{2}}{\partial t}) &= 0\\ % e^{X}&\left[\frac{1}{2}v\frac{\partial^2 P_{1}}{\partial X^2}+\rho\sigma v\frac{\partial^2 P_{1}}{\partial X\partial v} % +\frac{1}{2}v\sigma^2\frac{\partial^2 P_{1}}{\partial v^2}\parenthnewln % +[\kappa(\theta-v)-\lambda v]\frac{\partial P_{1}}{\partial v}+(r+\frac{1}{2}v)\frac{\partial P_{1}}{\partial X}+\frac{\partial P_{1}}{\partial t}\right]\newln % -Ke^{-r(T-t)}\left[\frac{1}{2}v\frac{\partial^2 P_{2}}{\partial X^2}+\rho\sigma v\frac{\partial^2 P_{2}}{\partial X\partial v}\parenthnewln % +\frac{1}{2}v\sigma^2\frac{\partial^2 P_{2}}{\partial v^2}\parenthnewln % +[\kappa(\theta-v)-\lambda v]\frac{\partial P_{2}}{\partial v}+(r-\frac{1}{2}v)\frac{\partial P_{2}}{\partial X}+\frac{\partial P_{2}}{\partial t}\right] &= 0 \end{split} \end{eqnarray}$$ For some reason the [ tex ] markup does not appear to be working properly, so I have included the code as well. Code: \newcommand{\newln}{\\&\hspace{2em}} \newcommand{\parenthnewln}{\right.\newln\left.{}} \begin{eqnarray} \begin{split} \frac{1}{2}v&(e^{X}P_{1}+2e^{X}\frac{\partial P_{1}}{\partial X}+e^{X}\frac{\partial^2 P_{1}}{\partial X^2}-Ke^{-r(T-t)}\frac{\partial^2 P_{2}}{\partial X^2})&\newln % +(r-\frac{1}{2}v)(e^{X}P_{1}+e^{X}\frac{\partial P_{1}}{\partial X}-Ke^{-r(T-t)}\frac{\partial P_{2}}{\partial X})&\newln % +\rho\sigma v(e^{X}\frac{\partial P_{1}}{\partial v}+e^{X}\frac{\partial^2 P_{1}}{\partial X\partial v} -Ke^{-r(T-t)}\frac{\partial^2 P_{2}}{\partial X\partial v})\newln % +\frac{1}{2}v\sigma^2(e^{X}\frac{\partial^2 P_{1}}{\partial v^2}-Ke^{-r(T-t)}\frac{\partial^2 P_{2}}{\partial v^2})&\newln % +[\kappa(\theta-v)-\lambda v] (e^{X}\frac{\partial P_{1}}{\partial v}-Ke^{-r(T-t)}\frac{\partial P_{2}}{\partial v})&\newln % -r(e^{X}P_{1}-Ke^{-r(T-t)}P_{2})\newln % +(e^{X}\frac{\partial P_{1}}{\partial t}-rKe^{-r(T-t)}\partial P_{2}-Ke^{-r(T-t)}\frac{\partial P_{2}}{\partial t}) &= 0\\ % e^{X}&\left[\frac{1}{2}v\frac{\partial^2 P_{1}}{\partial X^2}+\rho\sigma v\frac{\partial^2 P_{1}}{\partial X\partial v} % +\frac{1}{2}v\sigma^2\frac{\partial^2 P_{1}}{\partial v^2}\parenthnewln % +[\kappa(\theta-v)-\lambda v]\frac{\partial P_{1}}{\partial v}+(r+\frac{1}{2}v)\frac{\partial P_{1}}{\partial X}+\frac{\partial P_{1}}{\partial t}\right]\newln % -Ke^{-r(T-t)}\left[\frac{1}{2}v\frac{\partial^2 P_{2}}{\partial X^2}+\rho\sigma v\frac{\partial^2 P_{2}}{\partial X\partial v}\parenthnewln % +\frac{1}{2}v\sigma^2\frac{\partial^2 P_{2}}{\partial v^2}\parenthnewln % +[\kappa(\theta-v)-\lambda v]\frac{\partial P_{2}}{\partial v}+(r-\frac{1}{2}v)\frac{\partial P_{2}}{\partial X}+\frac{\partial P_{2}}{\partial t}\right] &= 0 \end{split} \end{eqnarray} I have put new lines within an equation using the \newln command. If the new line is within a set of parenthesis (the \left[ and \right]), then I use \parenthnewln. Remember that you can always add white space (blank lines need the % comment in equation environments) to make your work more legible.
 Hi sni, Working with equation formatting and layout in LaTeX can get very tedious if the equation is very long. I suggest you start with smaller equations and practice using the markup to do what you want. A very useful technique is to comment (%) out sections of equations while you're setting it up, and slowly removing the comment markers as you build it. When I posted my suggestion to your problem, I commented out all but the first line, checked to see what it looked like, and slowly introduced more of the equation as I became more familiar with its content, and the overall formatting use.
 yes,i 've figured that now. thanks though for your advise. i really2 appreciate it.