[Tex/LaTex] How to get caption of figure/table using table reference

captionscross-referencing

How can I get the caption of figures and tables using their references?

Something along the lines of \refcaption{tab:mytable} would print This is a pretty table., which is the caption of the table below.

\documentclass{article}
\usepackage{booktabs,longtable,tabu}
\begin{document}

\begin{longtabu}{lll}
    \toprule
    h1 & h2 & h3 \\
    \midrule
  \endhead
    \bottomrule
    \caption{This is a pretty table.}
    \label{tab:mytable}
  \endlastfoot
  a & b & c \\
  d & e & f \\
\end{longtabu}

Table~\ref{tab:mytable} looks good and its description is the following: \textbf{HOW TO GET DESC?}.

\end{document}

Best Answer

Here you have something to play around with. I hope, you were planing to use the package hyperref.

enter image description here

\documentclass{article}
\usepackage{booktabs,longtable,tabu}
\usepackage{csquotes}
\usepackage{hyperref}
\begin{document}

\begin{longtabu}{lll}
    \toprule
    h1 & h2 & h3 \\
    \midrule
  \endhead
    \bottomrule
    \caption{This is a pretty table.}
    \label{tab:mytable}
  \endlastfoot
  a & b & c \\
  d & e & f \\
\end{longtabu}

\autoref{tab:mytable} looks good and its description is the following: \enquote{\nameref{tab:mytable}.} You can also have a look at \Nameref{tab:mytable}
\end{document}