Math & ScienceError when I'm trying to align equation at =

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
marcoesteves
Posts: 18
Joined: Tue Jun 09, 2009 3:33 pm

Error when I'm trying to align equation at =

Post by marcoesteves »

Hello People,

I wanna align equation at = signal just to be easy to read, and beautifull :)

THis is my code, and I get an error.

Code: Select all

\begin{equation}
\label{eq1d_e1_bn_calc2}
\begin{align*}
{b_n} &= \frac{2}{L}\left[ {\int_0^{\frac{L}{2}} {x\sin \frac{{n\pi x}}{L}dx + \int_{\frac{L}{2}}^L {(L - x)\sin \frac{{n\pi x}}{L}dx} } } \right]\\
 	  &= \frac{2}{L}\left[ {{{\left( {\frac{L}{{n\pi }}} \right)}^2}\sin \frac{{n\pi x}}{L} - \frac{L}{{n\pi }}x\cos \frac{{n\pi x}}{L}} \right]_0^{\frac{L}{2}} + \frac{2}{L}\left[ {L\left( {\frac{L}{{n\pi }}} \right)\left( { - \cos \frac{{n\pi x}}{L}} \right) - {{\left( {\frac{L}{{n\pi }}} \right)}^2}\sin \frac{{n\pi x}}{L} + \frac{L}{{n\pi }}x\cos \frac{{n\pi x}}{L}} \right]_{\frac{L}{2}}^L.
\end{align*}
\end{equation} 
the error is,
! Package amsmath Error: Erroneous nesting of equation structures;

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Error when I'm trying to align equation at =

Post by localghost »

Actually the error message is very clear. You mustn't nest these two math environments. Replace align* with aligned. See the amsmath manual for details or the excellent »Math mode« document. And by the way, you shouldn't use so much unnecessary curly braces.


Thorsten
bimalastha
Posts: 2
Joined: Fri Mar 25, 2011 12:15 pm

Re: Error when I'm trying to align equation at =

Post by bimalastha »

Try removing align and see if it works...

\begin{equation}
\label{eq1d_e1_bn_calc2}
%remove this \begin{align*}
{b_n} &= \frac{2}{L}\left[ {\int_0^{\frac{L}{2}} {x\sin \frac{{n\pi x}}{L}dx + \int_{\frac{L}{2}}^L {(L - x)\sin \frac{{n\pi x}}{L}dx} } } \right]\\
&= \frac{2}{L}\left[ {{{\left( {\frac{L}{{n\pi }}} \right)}^2}\sin \frac{{n\pi x}}{L} - \frac{L}{{n\pi }}x\cos \frac{{n\pi x}}{L}} \right]_0^{\frac{L}{2}} + \frac{2}{L}\left[ {L\left( {\frac{L}{{n\pi }}} \right)\left( { - \cos \frac{{n\pi x}}{L}} \right) - {{\left( {\frac{L}{{n\pi }}} \right)}^2}\sin \frac{{n\pi x}}{L} + \frac{L}{{n\pi }}x\cos \frac{{n\pi x}}{L}} \right]_{\frac{L}{2}}^L.
%remove this \end{align*}
\end{equation}
marcoesteves
Posts: 18
Joined: Tue Jun 09, 2009 3:33 pm

Error when I'm trying to align equation at =

Post by marcoesteves »

Thanks,
But it's easier use aligned. It works too
bimalastha wrote:Try removing align and see if it works...

\begin{equation}
\label{eq1d_e1_bn_calc2}
%remove this \begin{align*}
{b_n} &= \frac{2}{L}\left[ {\int_0^{\frac{L}{2}} {x\sin \frac{{n\pi x}}{L}dx + \int_{\frac{L}{2}}^L {(L - x)\sin \frac{{n\pi x}}{L}dx} } } \right]\\
&= \frac{2}{L}\left[ {{{\left( {\frac{L}{{n\pi }}} \right)}^2}\sin \frac{{n\pi x}}{L} - \frac{L}{{n\pi }}x\cos \frac{{n\pi x}}{L}} \right]_0^{\frac{L}{2}} + \frac{2}{L}\left[ {L\left( {\frac{L}{{n\pi }}} \right)\left( { - \cos \frac{{n\pi x}}{L}} \right) - {{\left( {\frac{L}{{n\pi }}} \right)}^2}\sin \frac{{n\pi x}}{L} + \frac{L}{{n\pi }}x\cos \frac{{n\pi x}}{L}} \right]_{\frac{L}{2}}^L.
%remove this \end{align*}
\end{equation}
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Error when I'm trying to align equation at =

Post by localghost »

marcoesteves wrote:[…] It works […]
Then please mark the topic (not the last post) accordingly as written in Section 3 of the Board Rules (to be read before posting).
Post Reply