# Incorrect Typesetting while referencing to a table [duplicate]

I would like to make reference of a table that I have introduced before. However, after I try to typeset the first time, I have double question marks like this table ??.

I know that I need to typeset twice to get a correct reference. But the thing is that sometimes I get double question marks for the first typesetting but often times I get a blank, like this: table in the first typesetting.

No matter what I get in the first time, I will always get a blank after the second typesetting. My pdf looks like this: table and figure 1 show that...

What also confuses me is that I reference a figure right after my reference to the table but everything works fine as it is shown above. I have searched similar questions but I do not have similar preamble as the other guy did. Also I put my label before the caption for my table, which should not be a trouble here. So could any body helps me with this issue?

My code:

\begin{figure}[H]
\centering
\includegraphics[height=4in]{/Users/Desktop/Differentpandn.png}
\caption[]{Distributions of different sample sizes and proportions}
\label{fig:different n and p}
\end{figure}

\begin{table}[H]
\centering
\begin{tabular}{c c c c c}
\multicolumn{5}{c}{\textbf{The Normal Distribution of Different p and n}}\\ \hline
%The table is omitted for convenience
\end{tabular}
\label{tab:Table of different proportions and sizes}
\caption{Center, Shape and Center of different distributions}
\end{table}

From the table \ref{tab:Table of different proportions and sizes}
and figure \ref{fig:different n and p}


My preamble:

\usepackage[margin = 1 in, includefoot]{geometry}
\usepackage{graphicx}
\usepackage{float}
\usepackage[hidelinks]{hyperref}
\usepackage[shortlabels]{enumitem}
\usepackage{amsmath}

• \label must come after \caption.
– Mico
May 27, 2015 at 5:52
• @Mico, thanks for your help. It worked now. But in this question, people say that label after caption is useless: tex.stackexchange.com/questions/208456/… Do you know which one is correct? May 27, 2015 at 6:03
• That posting is about the effects of \restylefloat, which is, AFAICT, not an issue in your example.
– Mico
May 27, 2015 at 6:18
• @Mico, so I should always put \label before \caption to avoid such problem, is that right? May 27, 2015 at 6:25
• No, the exact opposite is true: \label must come after \caption.
– Mico
May 27, 2015 at 6:30