Text FormattingShowing error - in equationarray -

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
sachinrajsharma
Posts: 35
Joined: Sun Apr 08, 2012 5:48 am

Showing error - in equationarray -

Post by sachinrajsharma »

Hi,
Good Day!

I have been trying the following source code but unable to get the output showing error " missing \endgroup inserted"

Code: Select all

$$\begin{eqnarray*}
\int_{0}^{\pi /2}f(x)dx &=&\int_{0}^{\pi /2}\sin ^{7}x\cos ^{5}xdx \\
&=&\int_{0}^{\pi /2}\sin ^{7}x\cdot \cos xdx-2\int_{0}^{\pi /2}\sin
^{9}x\cdot \cos xdx \\
&&+\int_{0}^{\pi /2}\sin ^{11}x\cdot \cos xdx \\
&=&\frac{1}{8}-2\cdot \frac{1}{10}+\frac{1}{12}=\frac{1}{120}.
\end{eqnarray*}$$
Please guide how to resolve this.

Regards,

Sachin Sharma
Last edited by cgnieder on Wed May 15, 2013 11:28 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Showing error - in equationarray -

Post by Johannes_B »

Please, always provide a compilable and complete Minimal Working Example using the code-button. This makes testing much easier.

$$ are TeX-Syntax and not to be used with LaTeX. The right expression would be \[ E = mc^2 \].

The environment equationarray is not used anymore, use align instead.


Code: Select all

\documentclass{scrartcl}

\usepackage{mathtools}

\begin{document}
\begin{align}
\int_{0}^{\pi /2}f(x)dx &=&\int_{0}^{\pi /2}\sin ^{7}x\cos ^{5}xdx \\
&=&\int_{0}^{\pi /2}\sin ^{7}x\cdot \cos xdx-2\int_{0}^{\pi /2}\sin
^{9}x\cdot \cos xdx \\
&&+\int_{0}^{\pi /2}\sin ^{11}x\cdot \cos xdx \\
&=&\frac{1}{8}-2\cdot \frac{1}{10}+\frac{1}{12}=\frac{1}{120}.
\end{align}
\end{document} 
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Showing error - in equationarray -

Post by cgnieder »

I like to repeat: {eqnarray} really should be avoided. Also, $$...$$ is plain TeX syntax and should not be used in a LaTeX document.

The &=& is {eqnarray} syntax and doesn't hold for {align} which uses &= instead. Also the splitted line beginning with + should at least be indented with \quad:

Code: Select all

\documentclass{scrartcl}

\usepackage{mathtools}

\begin{document}

\begin{align*}
  \int_{0}^{\pi /2}f(x)dx
    &= \int_{0}^{\pi /2} \sin ^{7}x \cos^{5}xdx \\
    &= \int_{0}^{\pi /2} \sin ^{7}x \cdot \cos xdx - 2\int_{0}^{\pi /2}\sin^{9}x \cdot \cos xdx \\
    &\quad +\int_{0}^{\pi /2}\sin ^{11}x\cdot \cos xdx \\
    &= \frac{1}{8} - 2\cdot \frac{1}{10} + \frac{1}{12} \\
    &= \frac{1}{120}.
\end{align*}

\end{document}
I would also recommend to take a look at mathmode, a document by Herbert Voß which explains many details about math mode and the various environments available.

Regards
site moderator & package author
Post Reply