When we are using latex to write paper, we may reference many tables. In this tutorial, we will introduce how to reference tables in latex and avoid to change the table serial number manually.
Create a table with a latex
First you should create a table. Here is an example:
\begin{table} \centering \caption{This is a table test} \begin{tabular}{llll} 1 & 2 & 3 & 4 \\ 5 & 6 & 7 & 8 \end{tabular} \end{table}
This latex code will create a table like:
1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 |
Add a label to a table
To reference this table, we should add a label for it.
\label{table_reference_name}
Where table_reference_name is table label name, we can use it to reference a table, you can change it to your name.
As to table above, we can add label for it like this:
\begin{table} \centering \caption{This is a table test} \begin{tabular}{llll} 1 & 2 & 3 & 4 \\ 5 & 6 & 7 & 8 \end{tabular} \label{table_3} \end{table}
Then we can use table_3 to reference this table in latex.
Reference table in latex
We can use \ref{table_3} to reference this table, where table_3 is the label of table added by us. We can reference it in paragraph like this:
Table \ref{table_3} shows the performance of
The effect is following.
The table serial number is created when compling.
Notice
You should create table first then reference this table, which means \label{table_3} is front of \rel{table_3}. Otherwise, you will fail to reference this table.