8

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}
  • 1
    this facility may be provided by the nameref package. check the package documentation for more information. (i've never used the package for that purpose, so i'm not sure whether this selection really works.) – barbara beeton Apr 3 '14 at 14:31
  • 1
    @barbarabeeton: \nameref{tab:mytable} yields This is a pretty table, which is what I was looking for. – user3371321 Apr 3 '14 at 14:41
9

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}
  • 1
    The full document is using hyperref. Thanks! – user3371321 Apr 3 '14 at 14:42
  • 1
    Just \usepackage{nameref} would be sufficient; but hyperref loads it. – egreg Apr 3 '14 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.