# How to reference/add tables/figures/graphs, after some point in the text?

Im new to this, I just have a simple question.

How to declare a table let's say after I mention it in the text.

What I want:

Blah blah blah blah blah blah blah blah blah as shown in Table ~\ref{tab:table_Languages}

MY TABLE CAPTION

| Rank | Language | Share | Trend |
-----------------------------
....


What I have:

MY TABLE CAPTION

| Rank | Language | Share | Trend |
-----------------------------
.....


Blah blah blah blah blah blah blah blah blah as shown in Table ~\ref{tab:table_Languages}

What I use:

\begin{table}
\centering
\label{tab:table_Languages}
\setlength{\tabcolsep}{0.3cm}
\begin{tabular}{|c|p{2cm}|l|l|}
\hline
\textbf{Rank} & \textbf{Language} & \textbf{Share} & \textbf{Trend} \\
\hline
\textbf{1} & Python     & 26.42\%  & +5.2\% \\ \hline
\textbf{2} & Java       & 21.20\%  & -1.3\% \\ \hline
\textbf{3} & JavaScript & 08.21\%  & -0.3\% \\ \hline
\textbf{4} & C\#        & 07.57\%  & -0.5\% \\ \hline
\textbf{5} & PHP        & 07.34\%  & -1.2\% \\ \hline
\textbf{6} & C/C++      & 06.23\%  & -0.3\% \\ \hline
\textbf{7} & R          & 04.13\%  & -0.1\% \\ \hline
\end{tabular}
\end{table}


UPDATE:

Adding \caption{Best ranking Programming Languages in 2019.} creates a nice caption above my example. However it doesn't fix the position and also the value of the counter for the tables is not right, as it gets the Chapter number for a reason as shown in the figure.

• The numbering of tables depends on your used documentclass you did not tell us. If you do not want the table to float do not use floating environment table ... Mar 6 '19 at 19:48
• For an in-depth discussion of how LaTeX places "floating" objects, such as figure and table environments, please see the posting How to influence the position of float environments like figure and table in LaTeX.
– Mico
Mar 6 '19 at 20:19
• Please do tell us which document class you employ.
– Mico
Mar 6 '19 at 20:20
• I have no idea what you all talk about. I just started 1 month ago. I use \documentclass[bsc]{bangorcsthesis} which i use for my uni thesis. I dont know what is going on, and i don't know if that helps Mar 6 '19 at 20:27
• @LoizosVasileiou - You surmised correctly that the "document class" that's in use is given in the argument of the \documentclass directive.
– Mico
Mar 6 '19 at 20:49

(updated the answer to include the OP's piece of information that the bangorcsthesis document class is in use)

You're almost there: In addition to providing \label and \ref statements, you need to inform LaTeX which counter or item to associate the \label with. In the case of figure and table environments, the way to make this association is to issue a \caption directive. This directive not only typesets a (hopefully meaningful) caption, it also increments a figure or table counter in such a way that the subsequent \label statement "knows" what to latch on to. Incidentally, because \label statements try to "latch on" to the most recently incremented counter variable, it is essential to issue figure- and table-related \label statements after the corresponding \caption statements.

The LaTeX kernel provides the basic, yet flexible and quite powerful \label-\ref mechanism. Many LaTeX packages have been written to extend this basic mechanism. Please see the posting Cross-reference packages: which to use, which conflict? for more information about these packages.

\documentclass[bsc]{bangorcsthesis}
\usepackage{array} % for "\newcolumntype" macro
\newcolumntype{C}{>{\bfseries}c}
\begin{document}
\setcounter{chapter}{3} % just for this example

\begin{table}
\centering
\caption{Best Programming Languages in 2019}
\label{tab:table_Languages}
\setlength{\tabcolsep}{3mm}
\begin{tabular}{|C|l|l|r|}
\hline
Rank & \textbf{Language} & \textbf{Share} & \textbf{Trend} \\
\hline
1 & Python     & 26.42\%  & +5.2\% \\
2 & Java       & 21.20\%  & $-$1.3\% \\
3 & JavaScript & 08.21\%  & $-$0.3\% \\
4 & C\#        & 07.57\%  & $-$0.5\% \\
5 & PHP        & 07.34\%  & $-$1.2\% \\
6 & C/C++      & 06.23\%  & $-$0.3\% \\
7 & R          & 04.13\%  & $-$0.1\% \\
\hline
\end{tabular}
\end{table}

\noindent
\dots as shown in Table~\ref{tab:table_Languages}, \dots

\end{document}

• I updated my question due to some issues. Mar 6 '19 at 19:37
• @LoizosVasileiou - I've updated my answer to reflect the pieces of information that (a) you use the bangorcsthesis document class and (b) that the table occurs somewhere in chapter 3.
– Mico
Mar 6 '19 at 20:53