1

I have a pretty special requirement for my current thesis. When I reference a figure from my appendix in the main document I have to cite the content of the caption as well.

\documentclass{article}

\usepackage{graphicx}   % dummy image
\usepackage{duckuments} % dummy text
\usepackage{cleveref}   % can be used if necessary

\begin{document}
    \section{Image}
        \blindduck

        \begin{figure}
            \centering
            \includegraphics[width=.5\linewidth]{example-image-duck}
            \caption{Duck image}
            \label{fig:duck}
        \end{figure}

    \section{Reference}
        See \Cref{fig:duck} for more information.

        %Desired output Figure 1 "Duck image"
\end{document}

When I reference my image I would like to cite the content from the figure's caption as well, like "See Figure 1.2 "Duck image". Is it possible to get the content of a caption by label and when, how can I reach the content from a specific caption?

1 Answer 1

1

Like this?

\documentclass{article}
\usepackage{nameref}
\usepackage[colorlinks]{hyperref}
\usepackage{cleveref}
\newcommand\captionref[1]{\Cref{#1}:~\nameref{#1}}
\begin{document}
\begin{figure}
\hfil\fbox{This is the nice figure}
\caption{This is the caption of the nice figure.\label{xxx}}
\end{figure}
This is the boring text, so stop reading this  
and please see again the \captionref{xxx}.  
\end{document}
2
  • This works fine. I didn't know of the package nameref so far. Is it required to load nameref to load before hyperref?
    – faltfe
    Sep 7, 2018 at 9:02
  • 1
    @faltfe In general, you have to be careful with the order of packages for cross references and hyperref matter, but at least in this example the problem is not nameref but cleveref. If you load it before of hyperref, the link of of the number is lost.
    – Fran
    Sep 7, 2018 at 9:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .