The \label
should always be after \caption
:
Please see figure \ref{loginMock}.
\begin{figure}[H]
\centering
\includegraphics[width=7cm]{loginIdea}
\caption{Landing/Login Page Example}
\label{loginMock}
\end{figure}
\label
enables one to cross-reference a numbered "item"; the "item" can be a sectioning header, a figure, a table, or something else still. To know which numbered item to link to, \label
consults a flag -- let's call it "the name of the most recently incremented counter variable" -- that is set by the low-level \refstepcounter
macro. In the case of figure
and table
environments, the item's counter variables are incremented (via a call to \refstepcounter
) whenever a \caption
directive is issued.
So if you put \label
before \caption
, LaTeX cannot link the label to the counter variable (here: figure
) that you have in mind. Instead, LaTeX links the label to whichever counter was incremented most recently via \refstepcounter
. And, if no such variable was incremented previously in the document, LaTeX -- or, more precisely, the caption
package, which you've loaded -- prints the warning message that you report.