Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I make the entire "Table 1" clickable as a reference in Latex?

Tags:

latex

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.

like image 515
WoeIs Avatar asked Jul 07 '18 17:07

WoeIs


People also ask

How do you reference a table in LaTeX?

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}.

How do I make a reference clickable in LaTeX?

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.

How do you reference a table in text overleaf?

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.


1 Answers

Use \autoref.

\autoref creates a reference with text depending on the type.

A picture will tell more then thousand words:

enter image description here

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.

like image 111
rkta Avatar answered Oct 11 '22 12:10

rkta