# Problem with \end{align*}

I have 13 errors all ending with \end{align*}. Here is my code

\begin{align*}
e(\underline{a})x_1=& \ \  \alpha_1\prod\limits_{j=2}^{n}q^{-a_j} \e(\underline{a})\\
\forall \ \  2 \leq i \leq n, \ \ \ e(\underline{a})x_i=& \ \
\prod\limits_{j=2}^{i-1}q^{a_j}~e\left(\underline{a}+e_i).\\
e(\underline{a})y_1=& \ \  \alpha_1^{-1}\lambda_1{(1-
q^{-2})}^{-1}\prod\limits_{j=2}^{n}q^{-a_j} \ e(\underline{a})\\
\forall \ \ 2 \leq i \leq n, \ \  e(\underline{a})y_i =& \left \{
\begin{array}{cc}\prod\limits_{j=2}^{i-1}q^{-
a_j}\prod\limits_{j=i+1}^{n}q^{-2a_j} \ \frac{(\lambda_i-
q^{-2a_i}\lambda_{i-1})}{(1-q^{-2})}~~~e(\underline{a}-e_i),\ \
\text{when} \ \ a_i>0   & \\ \\
\alpha_i^{-1}\prod\limits_{j=2}^{i-1}q^{-
a_j}\prod\limits_{j=i+1}^{n}q^{-2a_j} \ \frac{(\lambda_i-
\lambda_{i-1})}{(1-q^{-2})}~e(\underline{a}-e_i),\ \ \text{when}
\ \ a_i=0  &
\end{array}
\right.
\end{align*}


The message that is shown is the following

l.656 \end{align*}

I've deleted a group-closing symbol because it seems to be spurious, as in $x}$'. But perhaps the } is legitimate and you forgot something else, as in \hbox{$x}'. In such cases the way to recover is to insert both the forgotten and the deleted material, e.g., by typing I$}'.

Can anyone please tell me where I am making mistakes.

• Welcome to TeX.SE.
– Mico
Apr 30 at 6:04
• The main problem lies in the expression e\left(\underline{a}+e_i) in line 4 of your code snippet. It should be either e\left(\underline{a}+e_i\right) or e(\underline{a}+e_i). The secobd opton is better IMNSHO.
– Mico
Apr 30 at 6:19
• Thanks Mico, it really solved my problem. Apr 30 at 6:24
• A good strategy for tracking down syntax errors in a multirow equation-like environment is to proceed row by row: In step 1, comment out all rows but the first and recompile. If the error is in that row, fix it. If it's it, uncomment the code for the next row and recompile, and so on to the end. That is, incidentally, how I managed to find the syntax error in your code.
– Mico
Apr 30 at 6:49
• that is no the error messag, just he locaion. the log file will show the error just above the line you show. Apr 30 at 7:24

## 2 Answers

The main problem, as I noted in an earlier comment, is the presence of an unmatched \left directive in line 4 of your code fragment. Do get rid of that instance of \left. A second, somewhat less serious, problem is \e(\underline{a}) at the end of line 1; you should change it to e(\underline{a}) as the macro \e would appear to be undefined.

I think you should furthermore replace all instances of =& with &= to improve the spacing around the four = symbols. And, do get rid of the all instances visual formatting (such as ~ and hard spaces), and do please drop the \limits qualifiers. Instead of the array environment in the final row, I'd use a dcases ("display-style cases") environment, which is provided by the mathtools package.

Incidentally, what is the e(...) function? Is it the exponential function? If so, you may want to replace all instances of e(...) with either \exp(...) or e^{...}.

\documentclass{article} % or some other suitable document class
\usepackage{mathtools}  % see https://www.ctan.org/pkg/mathtools
\begin{document}
\begin{align*}
i=1\qquad
e(\underline{a})x_1
&= \alpha_1\prod_{j=2}^{n}q^{-a_j} e(\underline{a})\\
2\leq i\leq n\qquad
e(\underline{a})x_i
&= \prod_{j=2}^{i-1}q^{a_j} e(\underline{a}+e_i)\\
i=1\qquad
e(\underline{a})y_1
&= \alpha_1^{-1}\lambda_1(1-q^{-2})^{-1}
\prod_{j=2}^{n}q^{-a_j} e(\underline{a})\\
2\leq i\leq n\qquad
e(\underline{a})y_i
&= \begin{dcases}
\prod_{j=2}^{i-1}q^{-a_j}
\smashoperator{\prod_{j=i+1}^{n}}q^{-2a_j}
\frac{(\lambda_i-q^{-2a_i}\lambda_{i-1})}{(1-q^{-2})}
e(\underline{a}-e_i)
& \text{if $a_i>0$}  \\
\alpha_i^{-1}\prod_{j=2}^{i-1}q^{-a_j}
\smashoperator{\prod_{j=i+1}^{n}}q^{-2a_j}
\frac{(\lambda_i-\lambda_{i-1})}{(1-q^{-2})}
e(\underline{a}-e_i)
& \text{if $a_i=0$}
\end{dcases}
\end{align*}
\end{document}


The line that you show is not the error message, messages always start ! that is the final line which shows the line 656 TeX had reached. For technical reasons TeX always reads an entire alignment before detecting an error so the line number for any error within an align is always the last line.

You provided no example document, but with a document

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align*}
e(\underline{a})x_1=& \ \  \alpha_1\prod\limits_{j=2}^{n}q^{-a_j} \e(\underline{a})\\
\forall \ \  2 \leq i \leq n, \ \ \ e(\underline{a})x_i=& \ \
\prod\limits_{j=2}^{i-1}q^{a_j}~e\left(\underline{a}+e_i).\\
e(\underline{a})y_1=& \ \  \alpha_1^{-1}\lambda_1{(1-
q^{-2})}^{-1}\prod\limits_{j=2}^{n}q^{-a_j} \ e(\underline{a})\\
\forall \ \ 2 \leq i \leq n, \ \  e(\underline{a})y_i =& \left \{
\begin{array}{cc}\prod\limits_{j=2}^{i-1}q^{-
a_j}\prod\limits_{j=i+1}^{n}q^{-2a_j} \ \frac{(\lambda_i-
q^{-2a_i}\lambda_{i-1})}{(1-q^{-2})}~~~e(\underline{a}-e_i),\ \
\text{when} \ \ a_i>0   & \\ \\
\alpha_i^{-1}\prod\limits_{j=2}^{i-1}q^{-
a_j}\prod\limits_{j=i+1}^{n}q^{-2a_j} \ \frac{(\lambda_i-
\lambda_{i-1})}{(1-q^{-2})}~e(\underline{a}-e_i),\ \ \text{when}
\ \ a_i=0  &
\end{array}
\right.
\end{align*}

\end{document}


The error shown on the terminal and log file is:

! Undefined control sequence.
<argument> ...\prod \limits _{j=2}^{n}q^{-a_j} \e
(\underline {a})\\ \forall...
l.24 \end{align*}

?


Showing that align* ending on line 24 has an undefined \e

adding

\newcommand\e{\mathrm{e}}


I get

! Extra }, or forgotten \right.
<template> }
\$}\ifmeasuring@ \savefieldlength@ \fi \set@field \hfil \endtempl...
l.25 \end{align*}

?


because of the spurious \left with no matching right (adding a \right would make the error go, but removing \left is better).

The document then runs without error (although you should also remove all the \limits and \ ) See the other answer for more improvements to the layout and coding style.

\documentclass{article}

\usepackage{amsmath}
\newcommand\e{\mathrm{e}}

\begin{document}

\begin{align*}
e(\underline{a})x_1=& \ \  \alpha_1\prod\limits_{j=2}^{n}q^{-a_j} \e(\underline{a})\\
\forall \ \  2 \leq i \leq n, \ \ \ e(\underline{a})x_i=& \ \
\prod\limits_{j=2}^{i-1}q^{a_j}~e(\underline{a}+e_i)\\
e(\underline{a})y_1=& \ \  \alpha_1^{-1}\lambda_1{(1-
q^{-2})}^{-1}\prod\limits_{j=2}^{n}q^{-a_j} \ e(\underline{a})\\
\forall \ \ 2 \leq i \leq n, \ \  e(\underline{a})y_i =& \left \{
\begin{array}{cc}\prod\limits_{j=2}^{i-1}q^{-
a_j}\prod\limits_{j=i+1}^{n}q^{-2a_j} \ \frac{(\lambda_i-
q^{-2a_i}\lambda_{i-1})}{(1-q^{-2})}~~~e(\underline{a}-e_i),\ \
\text{when} \ \ a_i>0   & \\ \\
\alpha_i^{-1}\prod\limits_{j=2}^{i-1}q^{-
a_j}\prod\limits_{j=i+1}^{n}q^{-2a_j} \ \frac{(\lambda_i-
\lambda_{i-1})}{(1-q^{-2})}~e(\underline{a}-e_i),\ \ \text{when}
\ \ a_i=0  &
\end{array}
\right.
\end{align*}

\end{document}

• You may also want to recommend replacing all four instances of =& with &= and cutting down on the amount of visual formatting (e.g., ~~~` and the many cases of hard spacing).
– Mico
Apr 30 at 8:39
• @Mico yes I made some comments at the end about style but I think you covered most of that well in your answer. I added another answer mostly to answer "how to read a log file" maybe I'll just add an explicit link to yours at the end Apr 30 at 10:31