In my document, I'm using the label function to label tables and figures:
\label{}
Then I use the \ref{}
function to refer to the table or figure. in my text.
The problem that I have is that in my text I write this:
As can be seen in Table \ref{table1}.
It will output my text as:
As can be seen in Table 1.
However only the number "1" is clickable and leads up to the table. I want the "Table" part to be clickable as well, so you can click on any part of "Table 1" and get referred up to the table.
I've tried different ways by using \phantomsection\label{}
and then \hyperref[]{}
, but this doesn't output the table or figure number dynamically.
To reference a LaTeX table or equation in LaTeX you need to make sure that you insert a label in your table or equation and that such label has a tab: prefix for tables and a eqn: prefix for equations. Notice the \label{tab:somelabel} inside the \caption . Notice the \label{eqn:somelabel}.
Include \usepackage{hyperref} in the preamble of your document. Assign proper labels to your sections and reference these labels using \ref{} . These references will then be turned into clickable links when creating PDFs with pdflatex.
If you create a list of tables this caption will be used there. You can place it above or below the table. If you need to reference the table within your document, set a label with this command. The label will number the table and, when combined with the \ref command, will allow you to reference it.
Use \autoref
.
\autoref
creates a reference with text depending on the type.
A picture will tell more then thousand words:
Example code:
\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage[colorlinks=true, allcolors=blue]{hyperref}
\begin{document}
\textbackslash ref to the Figure \ref{fig:example}
\textbackslash autoref to the \autoref{fig:example}
\textbackslash nameref to the figure \nameref{fig:example}
\begin{figure}
\centering
\includegraphics[width=0.3\textwidth]{example-image-a}
\caption{\label{fig:example}Example image}
\end{figure}
\end{document}
To change the text inserted by \autoref
for e.g. a table:
\renewcommand{\tableautorefname}{bettertablename}
See the hyperref
manual for all options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With