[Tex/LaTex] Table and Figure Caption Citation Problem

captionscross-referencingtables

When I build a LaTeX code, the references to figures and tables labels are not recognized, so latex builder prints "?" in the place. And simplifying the entire text I found out that even the simple dummy document

\documentclass{book}
  \begin{document}
    Some text cites Table \cite{whatever}

  \begin{table}[h]
    \caption{my caption}\label{whatever}
    \begin{tabular}{l}
      Text
    \end{tabular}
  \end{table}
\end{document}

generates this:

Some text cites Table [?]

Table 1: my caption

Text

I'm using MiKTeX 2.4-64 for a couple of months, but I do not remember getting this type of errors with past versions MiKTeX versions. Would someone have a clue on how to fix this?

Best Answer

After processing your document, you will receive the following warning:

LaTeX Warning: Citation `whatever' on page 1 undefined on input line 3.

which gives you a hint about the cause of the problem: you are using \cite and you should be using \ref instead (the output [?] also indicates that a citation was incorrectly expected). Simply replace:

Some text cites Table \cite{whatever}

with

Some text cites Table~\ref{whatever}

\cite is for bibliographical citations.