Need Help Labeling Latex Equation

  • LaTeX
  • Thread starter fluidistic
  • Start date
  • Tags
    Latex
In summary, the individual is seeking help with labeling an equation in their LaTeX document. They have tried using the \label and \begin{eqnarray*} commands, but are running into issues with equation numbers and spacing. The individual is then given advice to use the \begin{equation} and \begin{aligned} commands, with the addition of the \usepackage{amsmath} package. The conversation also includes a simpler alternative using the \begin{multline} command. The individual thanks the responder and confirms that the solution worked for them.
  • #1
fluidistic
Gold Member
3,923
261
Latex "help" needed

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

Code:
\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:
\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?
 
Physics news on Phys.org
  • #2
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:
\begin{equation}
\begin{aligned}
\label{name}
& equation \\
another & equation \\
and yet another & equation
\end{aligned}
\end{equation}
 
Last edited:
  • #3
Thanks for the help!
AlephZero said:
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.
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.


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:
\begin{equation}
\begin{aligned}
\label{name}
& equation \\
another & equation \\
and yet another & equation
\end{aligned}
\end{equation}
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:
\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:
\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*}
 
  • #4
fluidistic said:
Here's the code of what I just tried:
Code:
\begin{equation}
\begin{aligned} 
\label{test}
...
\end{equation}
and it won't work.

You forgot something:

Code:
\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:
\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}.
 

Attachments

  • big eqaution.png
    big eqaution.png
    10.2 KB · Views: 477
Last edited:
  • Like
Likes 1 person
  • #5
Thanks a lot, that worked great!
I just added the \end{aligned} line, now it works simply perfectly. :smile:
 

1. What is the purpose of labeling a latex equation?

Labeling a latex equation is important because it allows you to easily refer to specific equations in your document. This is especially useful when you have multiple equations and want to differentiate between them.

2. How do I label a latex equation?

To label a latex equation, use the \label{labelname} command after the equation. You can then refer to the equation using the \ref{labelname} command.

3. Can I use special characters in my equation label?

Yes, you can use special characters in your equation label. However, it is recommended to use only alphanumeric characters and avoid using spaces or special symbols to avoid any potential errors.

4. Is it necessary to label every equation in my document?

No, it is not necessary to label every equation in your document. You can choose to label only the equations that you need to refer to in your text. However, it is good practice to label equations for clarity and organization.

5. How do I customize the equation label format?

You can customize the equation label format using the \renewcommand{\theequation}{label format} command. For example, you can change the label to include the section number by using \renewcommand{\theequation}{\thesection.\arabic{equation}}.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
936
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
13
Views
977
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top