[Tex/LaTex] Referencing to table

cross-referencingtables

So I have the following table that I want to reference to.

\begin{table}

{\captionof{table}\\
\begin{center}\textbf{Calculation variables} \end{center}\\    \footnotesize{Each variable is calculated according to the proper equation. We tabulated the equations for each of the variables. In the first column we included all the categories in which all the variables fall in. For every variable we formulated an abbreviation, these are included in the second column of the table. The last column shows all the equations that were used to calculate the variables for each company.}}

\label{tab:datavariables}

\begin{tabular}{ccccccc}

\end{tabular}

When trying to reference to it in the text (with \ref{tab:datavariables}) it just returns '??'. What should I do about this.

Best Answer

Your code appears to be needlessly complex. In particular, since you're using a table environment, there would seem to be no justification for using \captionof instead of \caption. A separate matter: The directive \footnotesize is a switch, i.e., it doesn't take an argument.

Do please study the following code carefully; I hope it does what you're looking to achieve.

\documentclass{article}
\usepackage[font=bf,skip=0.333\baselineskip]{caption} % typeset captions in bold
\begin{document}

\begin{table}
\caption{Calculation variables}
\label{tab:datavariables}

{\footnotesize Each variable is calculated according to the proper equation. 
We tabulated the equations for each of the variables. In the first column we 
included all the categories in which all the variables fall in. For every 
variable we formulated an abbreviation, these are included in the second 
column of the table. The last column shows all the equations that were used 
to calculate the variables for each company.\par}

\medskip\centering
\begin{tabular}{ccccccc}
\hline
a & b & c & d & e & f & g \\
\hline
\end{tabular}
\end{table}

A cross-reference to Table \ref{tab:datavariables}.
\end{document}

As with all LaTeX cross-referencing matters, be sure to compile twice to resolve the cross-reference.

Related Question