PREP 2015 Question Authoring - Archived

Using \begin{eqnarray*} … \end{eqnarray*}

Using \begin{eqnarray*} … \end{eqnarray*}

by Daniele Arcara -
Number of replies: 2
I like to use \begin{eqnarray*} … \end{eqnarray*} when writing a solution that has multiple steps. It shows up well in the problem, but it is creating issues when I go and make the pdf hardcopy of my homework assignment.


I get the following errors:

2 errors occured while generating hardcopy:

  • Failed to convert TeX to PDF with command 'cd /var/www/html/wwtmp/MA113/hardcopy/work.v6KbKDsm && /usr/bin/pdflatex >pdflatex.stdout 2>pdflatex.stderr hardcopy' (exit=1 signal=0 core=0).
  • First error in TeX log is:
    ! Missing \endgroup inserted.
    <inserted text>
                    \endgroup
    l.210 \(\displaystyle{ \begin{eqnarray*}
    
    I've inserted something that you may have forgotten.
    (See the <inserted text> above.)
    With luck, this will get me unwedged. But if you
    really didn't forget anything, try typing `2' now; then
    my insertion and my current dilemma will both disappear.
    

The code I use for that part (within a PGML solution) is:

[`` \begin{eqnarray*}
\sum_{n= [$b]}^{\infty} \left( \frac{[$a]}{n} - \frac{[$a]}{n+1} \right) & = & \lim_{b\rightarrow\infty} \sum_{n= [$b]}^b \left( \frac{[$a]}{n} - \frac{[$a]}{n+1} \right) \\
& = & \lim_{b\rightarrow\infty} \left( \frac{[$a]}{[$b]} - \frac{[$a]}{[$b+1]} + \frac{[$a]}{[$b+1]} - \frac{[$a]}{[$b+2]} + \frac{[$a]}{[$b+2]} - \frac{[$a]}{[$b+3]} + \cdots + \frac{[$a]}{b} - \frac{[$a]}{b+1} \right)  \\
& = & \lim_{b\rightarrow\infty} \left( \frac{[$a]}{[$b]} - \frac{[$a]}{b+1} \right) \\
& = & \frac{[$a]}{[$b]} - 0 \\
& = & [$sum].
\end{eqnarray*} ``]

In reply to Daniele Arcara

Re: Using \begin{eqnarray*} … \end{eqnarray*}

by Davide Cervone -
In LaTeX, some environments initiate math mode automatically and are not allowed to appear in math mode themselves. These typically are the various alignment environments like \begin{align}...\end{align}, and so on. The eqnarray environment is one of these.

Because TeX math in WeBWorK (both in PGML and TEXT blocks) are always enclosed in \(...\) or \[...\] in the hardcopy output, you can not use such environments in WeBWorK. (It works on screen because MathJax is not so picky about it, but I suspect in image mode there would be problems.)

Fortunately, there are math-mode alignment environments that should do what you need. For example, you can use \begin{aligned}...\end{aligned} in place of \begin{eqnarray*}...\end{eqnarray*}, but you must remove the ampersands that follow the equal signs.

In your LaTeX documents you should really switch from eqnarray to the align environment anyway. See Lars Madsen's Avoid eqnarray! for details of why.