I want to use hypertarget caption in hyperlink caption automatically.
Example:
\hypertarget{myTarget}{My Target}
See \hyperlink{myTarget}{\useMyTargetCaption}.
Wanted result:
My Target
See My Target.
hyperref
I want to use hypertarget caption in hyperlink caption automatically.
Example:
\hypertarget{myTarget}{My Target}
See \hyperlink{myTarget}{\useMyTargetCaption}.
Wanted result:
My Target
See My Target.
Best Answer
You can redefine
\hypertarget
so that it defines a new command corresponding to its first argument:In this way, when you issue
this also saves a command named
\myTarget
in the.aux
file.Then we define a new command
\myhyperlink
that takes care of that:When you issue
this results in
MWE:
Output:
If you want to customize it, you can change it, for example, to (requires
xcolor
package`):and the result will be: