# reference with eqnarray

I'm trying to reference some equations in my latex file and I keep getting ?? as a response. At first, I used eqnarray, but I also tried to use equation and align.

This is the code I'm using now:

\begin{eqnarray}
\label{true1}
\hspace{1cm} \int_{0}^{K} x f(x|1) dx+(1-F(K|1))K &\geq &1-A,\\
\label{true2}
\hspace{1cm} \int_{K}^{\infty}(x-K)(f(x|1)-f(x|0))dx &\geq & c.
\end{eqnarray}

• Do you compile two-times? Off-topic: instead of eqnarray is better to use align defined in amsmath package. Nov 22 '16 at 19:23
• Never use eqnarray, but how exactly are you adding the references? Nov 22 '16 at 19:24

This works fine:

\documentclass{article}

\begin{document}
\begin{eqnarray}
\label{true1}
\hspace{1cm} \int_{0}^{K} x f(x|1) dx+(1-F(K|1))K &\geq &1-A,\\
\label{true2}
\hspace{1cm} \int_{K}^{\infty}(x-K)(f(x|1)-f(x|0))dx &\geq & c.
\end{eqnarray}

Equations (\ref{true1}) and (\ref{true2})
\end{document}


(but align is preferable to eqnarray and \eqref or \cref to (\ref))

• you should mentioned, that references appear after second compilation of code (as I mentioned/asked in my comment). Before you see (famous) ?? ... Nov 22 '16 at 19:51
• This is exactly what I'm doing. Sorry I wasn't more specific. Nevertheless I still not getting the references properly. Nov 22 '16 at 20:06
• @FelipeDamasceno if you ran latex twice on a document and the references do not show, fix the example in your question to be a complete small document that shows the problem (like JPi's example here). People can not debug code they can not see. Nov 22 '16 at 20:33
• @Zarko: you'd already mentioned that! ;-)
– JPi
Nov 22 '16 at 20:47
• I'm using Bakoma Tex, thus the compilation is automatic. Am I thinking it wrongly? Nov 23 '16 at 14:11