Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
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 at 14:31
1  
@barbarabeeton: \nameref{tab:mytable} yields This is a pretty table, which is what I was looking for. –  user3371321 Apr 3 at 14:41

1 Answer 1

up vote 7 down vote accepted

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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