Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Latex help needed

Tags:
  1. Mar 1, 2014 #1

    fluidistic

    User Avatar
    Gold Member

    Latex "help" needed

    Hello,
    I would like to label the following as an equation:

    Code (Text):
    \begin{eqnarray*}
    Enormous equation here
    \end{eqnarray*}
    I have tried the \label{name of equation} line, but it did not work.

    I want to do this because in my latex document I have labeled many equations the following way:
    Code (Text):
    \begin{equation}
    \label{name of equation}
    equation expression
    \end{equation}
    And I would like my "eqnarray*" to look like an equation for a reader of my document. I need to cite that "eqnarray*" at several places in my document so I really need to label it, but I don't know how to do.

    Any idea?
     
  2. jcsd
  3. Mar 1, 2014 #2

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    The reason you don't get equation numbers is because the * in equarray* option switches numbers off!

    But without the *, each equation in the array gets its own number, which is presumably not what you want.

    And in any case, eqnarray is sort of "left over from the an earlier version of LaTeX". The various alignment envoronments in the amsmath package give better spacing than eqnarray.

    Try
    Code (Text):

    \begin{equation}
    \begin{aligned}
    \label{name}
    & equation \\
    another & equation \\
    and yet another & equation
    \end{aligned}
    \end{equation}
     
     
    Last edited: Mar 1, 2014
  4. Mar 1, 2014 #3

    fluidistic

    User Avatar
    Gold Member

    Thanks for the help!
    Well actually it somehow work but not as I want. Since the equation is enormous I have split it into 2 long lines. What I get when I remove the "*" is that both lines are assigned a number (not 1 and 2 but 12 and 13 because the previous equation is labeled as 11). On the top of that the numbers are displayed over/under the equation because it is simply too large. Maybe if I could put the number on the left side (in the margin I suppose), it would be ok. But I would still need to create a single number and not 2.


    I just tried this, I get a lot of errors. Probably because I split a single equation (it has \left [ and 2 kilometers away it has \right ] ) but I am not sure.

    Here's the code of what I just tried:
    Code (Text):
    \begin{equation}
    \begin{aligned}
    \label{test}
    & \frac{\partial ^2 P}{\partial x^2}=\frac{1}{\sqrt{2\pi t} \sigma} \left [ \frac{1}{\sigma ^2 t} \exp \{ -\frac{(x+y-2B)^2}{2\sigma ^2 t}    \} + \frac{(x-y)^2}{\sigma ^4 t^2} \exp \{ - \frac{(x-y)^2}{2\sigma ^2 t}  \}\right. \\
    & \qquad \qquad \left. -\frac{1}{\sigma ^2 t} \exp \{ - \frac{(x-y)^2}{2\sigma ^2 t}  \} -\frac{(x+y-2B)^2}{\sigma ^4 t} \exp \{ -\frac{(x+y-2B)^2}{2\sigma ^2 t}  \} \right ]
    \end{equation}
    and it won't work.
    Here's the code that work but needs to be fixed:
    Code (Text):
    \begin{eqnarray*}
    & & \frac{\partial ^2 P}{\partial x^2}=\frac{1}{\sqrt{2\pi t} \sigma} \left [ \frac{1}{\sigma ^2 t} \exp \{ -\frac{(x+y-2B)^2}{2\sigma ^2 t}    \} + \frac{(x-y)^2}{\sigma ^4 t^2} \exp \{ - \frac{(x-y)^2}{2\sigma ^2 t}  \}\right. \\
    & &\qquad \qquad \left. -\frac{1}{\sigma ^2 t} \exp \{ - \frac{(x-y)^2}{2\sigma ^2 t}  \} -\frac{(x+y-2B)^2}{\sigma ^4 t} \exp \{ -\frac{(x+y-2B)^2}{2\sigma ^2 t}  \} \right ]
    \end{eqnarray*}
     
  5. Mar 1, 2014 #4

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    You forgot something:

    Code (Text):
    \begin{equation}
    \begin{aligned}
    \label{test}
    ......
    \end{aligned} % !!!!!!!!!!!!!!!!!!!!
    \end{equation}
    And you need \usepackage{amsmath} if you don't already have it.

    That works for me - see attachment.

    This is a bit simpler, but the formatting is slightly different:

    Code (Text):

    \begin{multline}
    \label{test}
    \frac{\partial ^2 P}{\partial x^2}=\frac{1}{\sqrt{2\pi t} \sigma} \left [ \frac{1}{\sigma ^2 t} \exp \{ -\frac{(x+y-2B)^2}{2\sigma ^2 t} \} + \frac{(x-y)^2}{\sigma ^4 t^2} \exp \{ - \frac{(x-y)^2}{2\sigma ^2 t} \}\right. \\
    \left. -\frac{1}{\sigma ^2 t} \exp \{ - \frac{(x-y)^2}{2\sigma ^2 t} \} -\frac{(x+y-2B)^2}{\sigma ^4 t} \exp \{ -\frac{(x+y-2B)^2}{2\sigma ^2 t} \} \right ]
    \end{multline}
     
    Note I've deleted the &'s and some of the \quads, and you don't need \ begin{equation} ... \ end{equation}.
     

    Attached Files:

    Last edited: Mar 1, 2014
  6. Mar 1, 2014 #5

    fluidistic

    User Avatar
    Gold Member

    Thanks a lot, that worked great!
    I just added the \end{aligned} line, now it works simply perfectly. :smile:
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Latex help needed
  1. I need help with Latex (Replies: 15)

Loading...