# Why isn't eqref working?

I am trying to use \eqref as in the following, but instead of (1), I get a set of blank parentheses as the result. Could anyone help me fix the problem?

\documentclass[10pt]{article}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage[left=1.5in,right=1.5in,bottom=1.5in,top=1.5in]{geometry}

\begin{document}

\label{eq:2} \begin{align*} 1\cdot 2+2\cdot 3+3\cdot 4+ \cdots+k\cdot(k+1)+(k+1)(k+2) &= \frac{(k+1)(k+2)(k+3)}{3} \\ &= \frac{(k^2+3k+2)(k+3)}{3} \\ &= \frac{k^3+3k^2+3k^2+9k+2k+6}{3} \\ &= \frac{k^3+6k^2+11k+6}{3}. \end{align*}

assuming ~\eqref{eq:2} ...

\end{document}

• Your document does not compile - that's the problem. – Werner Jan 23 '14 at 6:04

You're not allowed to use the equation or align* environments inside a display math $...$ context. They create these themselves. Instead, use

\documentclass[10pt]{article}
\usepackage{amsmath}
\usepackage[margin=1.5in]{geometry}
\begin{document}

$$\label{eq:2} \begin{split} 1\cdot 2+2\cdot 3+3\cdot 4+ \cdots+k\cdot(k+1)+(k+1)(k+2) &= \frac{(k+1)(k+2)(k+3)}{3} \\ &= \frac{(k^2+3k+2)(k+3)}{3} \\ &= \frac{k^3+3k^2+3k^2+9k+2k+6}{3} \\ &= \frac{k^3+6k^2+11k+6}{3}. \end{split}$$

assuming~\eqref{eq:2} ...

\end{document}


The above split usage follows directly from an example in the amsmath user guide (Table 3.1, p 4).

• it's also worth noting that a * on a display math environment suppresses the equation number. – barbara beeton Jan 23 '14 at 7:42

What you need to use is eqnarray environment instead of align & equation. eqnarray is available in amsmath package. In that case, your code will be like :

\begin{eqnarray*}\label{eq:2}
1\cdot 2+2\cdot 3+3\cdot 4+ \cdots+k\cdot(k+1)+(k+1)(k+2) &=& \frac{(k+1)(k+2)(k+3)}{3}       \\
&=& \frac{(k^2+3k+2)(k+3)}{3} \\
&=& \frac{k^3+3k^2+3k^2+9k+2k+6}{3} \\
&=& \frac{k^3+6k^2+11k+6}{3}.
\end{eqnarray*}

assuming \eqref{eq:2} ...


In above case, equation number will not be visible beside the equation. You can put the equation number on selective lines by using \nonumber for the lines for which you don't want numbering. Suppose I want numbering only in the first & last line of the equation with equation refernce, then I will use this code :

\begin{eqnarray}
1\cdot 2+2\cdot 3+3\cdot 4+ \cdots+k\cdot(k+1)+(k+1)(k+2) &=& \frac{(k+1)(k+2)(k+3)}{3} \label{eq:1}     \\
&=& \frac{(k^2+3k+2)(k+3)}{3} \nonumber \\
&=& \frac{k^3+3k^2+3k^2+9k+2k+6}{3} \nonumber \\
&=& \frac{k^3+6k^2+11k+6}{3}. \label{eq:2}
\end{eqnarray}

assuming \eqref{eq:1} and \eqref{eq:2}...

• Hi, welcome. eqnarray should in general not be used at all, see tug.org/TUGboat/tb33-1/tb103madsen.pdf. And it is not actually defined by amsmath, but by LaTeX itself. – Torbjørn T. Feb 13 '17 at 13:35
• @TorbjørnT. I always used eqnarray & never got a single problem. But thanks for the link...will take care next time. – DeusExMachina Feb 13 '17 at 13:38
• @AvinashAnand eqnarray compiles fine, but looks inconsistent with the rest of the math envs + has other problems. – daleif Feb 13 '17 at 13:51