2

How to fix this equation

\begin{eqnarray}
 \frac{1}{2} (1-\varepsilon^2)\left(\partial_\tau \phi\right)^2
&= \frac{1}{2} \left(1-\epsilon ^2\right)\left(
 -\frac{S \epsilon \sin\tau }{\sqrt{\lambda }}
 -\frac{g_2 S^2 \epsilon ^2\sin2\tau }{3 \lambda }\right.\\
&\quad\left. +\epsilon ^3 \left(-\frac{\left(-\frac{1}{54} g_2^2 S
 \left(32+19 S^2\right) \lambda +Z \left(
 \frac{35 g_2^4}{27}
 -\frac{7 g_2 g_4}{4}+\frac{5 g_5}{8}
 -\frac{g_2^2 \lambda }{6}
 +\frac{\lambda ^2}{24}\right)\right) \sin\tau }
 {\lambda ^{5/2}}\right.\right.\\
 &\quad\left.\left.-\frac{S^3 \left(4 g_2^2-3 \lambda \right) \sin3\tau }
       {24 \lambda ^{3/2}}\right)\right)^2 \\
&= \frac{S^2 \epsilon ^2 \sin^2\tau }{2 \lambda }+\frac{2 g_2S^3 \epsilon ^3 \cos\tau \sin^2\tau  }{3 \lambda ^{3/2}}  \\
 & \quad +\frac{1}{216 \lambda ^3}S \epsilon ^4 \Bigl( 280 g_2^4 Z-378 g_2 g_4 Z+135 g_5 Z-128 g_2^2 S \lambda  -16 g_2^2 S^3 \lambda \\
& \quad -36 \text{g2}^2 Z \lambda  -108 S \lambda ^2-27 S^3 \lambda ^2+9 Z \lambda ^2+6 S^3 \left(16 g_2^2-9 \lambda \right) \lambda  \cos2 \tau \Bigr) \sin\tau
\end{eqnarray}

The problem I got that equation crossed the margin and equation number. How to fix it?

2
  • 1
    You shouldn't be using eqnarray to begin with; see the link in the first answer to eqnarray vs. align
    – egreg
    Aug 25 '13 at 23:04
  • Can You fix this please, then I can follow you the way you do? Aug 25 '13 at 23:13
5

Here's one option:

\documentclass[12pt]{article}
\usepackage{mathtools}

\begin{document}

\begin{align}
 \frac{1}{2} (1-\varepsilon^2)(\partial_\tau \phi)^2
&= \frac{1}{2} (1-\epsilon ^2 )\Biggl[
 -S \epsilon\lambda^{-1/2} \sin\tau 
 -\frac{1}{3}g_2 S^2 \epsilon ^2\lambda^{-1}\sin2\tau \notag \\
&\qquad+ \epsilon ^3 \Bigl(\left(N \lambda -ZM \right)\lambda ^{-5/2} \sin\tau 
  \notag\\
 &\quad\qquad -\frac{1}{24}S^3 \left(4 g_2^2-3 \lambda \right) \lambda ^{-3/2}\sin3\tau 
       \Bigr)\Biggr]^2 \\
&= \frac{1}{2}S^2 \epsilon ^2 \sin^2\tau\lambda^{-1}+
  \frac{1}{3}2 g_2S^3 \epsilon ^3 \lambda ^{-3/2}\cos\tau \sin^2\tau  \notag\\
 & \qquad {} +\frac{1}{216}\lambda ^{-3}S \epsilon ^4 \sin\tau \Bigl( 280 g_2^4 Z-378 g_2 g_4 Z+135 g_5 Z \notag\\
& \quad\qquad -128 g_2^2 S \lambda  -16 g_2^2 S^3 \lambda -36 \text{g2}^2 Z \lambda  -108 S \lambda ^2 \notag \\
& \quad\qquad-27 S^3 \lambda ^2+9 Z \lambda ^2+6 S^3 (16 g_2^2-9 \lambda ) \lambda  \cos2 \tau \Bigr),
\end{align}
where 
\begin{align*}
M &=
 \frac{35}{27} g_2^4
 -\frac{7}{4} g_2 g_4+\frac{5}{8} g_5
 -\frac{1}{6}g_2^2 \lambda
 +\frac{1}{24}\lambda ^2
\shortintertext{and}
N &=
  \frac{1}{54} g_2^2 S(32+19 S^2).
\end{align*}

\end{document}

enter image description here

I used align instead of eqnarray (see Avoid eqnarray!). I also suppressed all \left...\right constructs and slightly modified the form of some terms.

Perhaps, a better option would be to use something like:

\documentclass[12pt]{article}
\usepackage{mathtools}

\begin{document}

\begin{multline}
 \frac{1}{2} (1-\varepsilon^2)(\partial_\tau \phi)^2
= \frac{1}{2} (1-\epsilon ^2 )\Biggl[
 -S \epsilon\lambda^{-1/2} \sin\tau 
 -\frac{1}{3}g_2 S^2 \epsilon ^2\lambda^{-1}\sin2\tau  \\
{} + \epsilon ^3 \Bigl(\left(N \lambda -ZM \right)\lambda ^{-5/2} \sin\tau 
  -\frac{1}{24}S^3 \left(4 g_2^2-3 \lambda \right) \lambda ^{-3/2}\sin3\tau 
       \Bigr)\Biggr]^2,
\end{multline}
where 
\begin{align*}
M &=
 \frac{35}{27} g_2^4
 -\frac{7}{4} g_2 g_4+\frac{5}{8} g_5
 -\frac{1}{6}g_2^2 \lambda
 +\frac{1}{24}\lambda ^2
\shortintertext{and}
N &=
  \frac{1}{54} g_2^2 S(32+19 S^2).
\end{align*}
After some calculations, we get
\begin{multline}
\frac{1}{2} (1-\varepsilon^2)(\partial_\tau \phi)^2 = \frac{1}{2}S^2 \epsilon ^2 \sin^2\tau\lambda^{-1}+
  \frac{1}{3}2 g_2S^3 \epsilon ^3 \lambda ^{-3/2}\cos\tau \sin^2\tau  \\
 +\frac{1}{216}\lambda ^{-3}S \epsilon ^4 \sin\tau \Bigl( 280 g_2^4 Z-378 g_2 g_4 Z+135 g_5 Z \\
-128 g_2^2 S \lambda  -16 g_2^2 S^3 \lambda -36 \text{g2}^2 Z \lambda  -108 S \lambda ^2 \\
-27 S^3 \lambda ^2+9 Z \lambda ^2+6 S^3 (16 g_2^2-9 \lambda ) \lambda  \cos2 \tau \Bigr).
\end{multline}

\end{document}

enter image description here

Now the original expression was divided in two main parts, each one having only one associated number.

2

You really should find a way to split this computation into smaller chunks (see answer of Gonzalo Medina). Not only would it be easier to layout, but also easier to read and understand.

Concerning the use of eqnarray: Read the short-math-guide.pdf and use \usepackage{amssymb,amsmath}. The align environment is the drop in replacement for eqnarray, but there is much more, which makes the amsmath package a must-have.

Using align, the tag gets shifted around, when the equation is wide enough to overlap it. \raisetag{2ex} can be used to further adjust it's position.

For large computations, it may be justifiable to adjust the font size like this:

{\footnotesize\begin{align*}
...
\end{align*}}

Stared variant to omit tags, which do follow the size change.
See prevent equation labeling to change sizes on how to avoid that.

Personally I wouldn't tag computations at all, only reference-able formulas.

1
  • Good point about the numbering! I've modified my answer to take this into account. Aug 26 '13 at 1:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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