I've studied a fair number of cross-referencing (or linking) entries here on the exchange, but I haven't found one that meets my need. Apologies in advance if I have somehow missed the solution.
I want to cross-reference text, not counters. I want the cross-reference link text to automatically pick up any changes in the target declaration. (I specifically do NOT want to have to adjust the link text if I change the target text. The change in the target text should automatically be reflected by any link to it.) Finally, I want to do this for a custom declaration, not a built-in one.
Here is an example custom declaration definition along with an instance of it:
% it is not important how this declaration is defined,
% only that it have link-able text.
\newcommand{\heading}[2]{
\vspace{#2}
{\begin{center}\Large\textbf{#1}\end{center}}
\vspace{#2}
}
...
\heading{Target Link Text}{6pt} % I want to link to this text
Now I want to cross-reference this declaration instance using some form of label and a cross-referencing command. So something like this:
\heading{Target Link Text}{6pt} \label{foo}
...
The linked text is: \somelinkcommand{foo} % replace somelinkcommand by a real command
And in the generated output, we would see this (without quotes):
"The linked text is: Target Link Text"
So the behavior is somewhat akin to the \nameref option in the hyperref package, only it supports custom/user commands. How can I do this, please? Thanks in advance.