How can I label a table and then refer it to my latex file?
Asked
Active
Viewed 62 times
0
-
3You already found the right terms. Search for label and ref in a LaTeX introduction. – Johannes_B Apr 17 '18 at 05:41
-
2'caption' to include a caption and number. 'label' to assign a key that you can then refer to using for example ' ref'. – leandriis Apr 17 '18 at 05:43
1 Answers
0
You can use caption for the \caption, \label{xy} and \ref{xy}. See Wikibook
A working example:
\documentclass[10pt,a4paper]{article}
\usepackage{hyperref}
\begin{document}
\section{Animals}
Table \ref{table:animals} <my text>
\begin{table}[h]
\centering
\begin{tabular}{|c|c|}
\hline
Animals & Results \\
\hline
Dog & 4 \\
\hline
Cat & 9 \\
\hline
Bird & 15 \\
\hline
\end{tabular}
\caption{Animals}
\label{table:animals}
\end{table}
\end{document}
For a correct reference counting use \ref after \caption.
optional: The package hyperref produce hypertext links for cross-referencing (a clickable link is also created).
hyperref reference
pipoli
- 1
