# How do I use the target caption of a \hypertarget as the link caption in a \hyperlink?

I'm building a software requirements document and using my own set of counters to generate unique requirement identifiers. I'm also grouping different requirements into longtables, e.g.

\begin{longtable}{l p{4in}}
F\FormatCntr{ModuleCntr}-\FormatCntr{ComponentCntr} & Some Requirements Category\stepcounter{RequirementCntr}\\
\hline
F\FormatCntr{ModuleCntr}-\FormatCntr{ComponentCntr}.\FormatCntr{RequirementCntr} & Specific software requirement
\end{longtable}


This will generate something like:

F00-01 Some Requirements

F00-01-01 Specific software requirement.

Now at some point later in the text, I want to cross-reference back to that specific requirement. I can use \hypertarget and \hyperlink and say something like "See this requirement" and have "this" link back to the referenced requirement but it would be much more elegant to say "See requirement F00-01-01" but "F00-01-01" must be linked automatically due to the dynamic nature of the counters.

You can use the normal \label/\ref system. If a counter is increased via \refstepcounter, then an anchor is placed at this location and the counter appearance and the anchor name are made available for the next \label. Then \ref, \pageref can be used to reference the label. For free link texts \hyperref with the optional argument can be used:
\hyperref[<label name>]{<free link text>}

• @user36792: subsection is an example of an counter that often comes with the values of other counters (section, chapter). The only important issue for hyperref is the uniqueness of the anchor names. Usually it makes use of \the<counter>, but prefers \theH<counter>, if it exists. Thus the latter macro can be provided to get uniqueness, if \the<counter> is not unique. – Heiko Oberdiek Sep 16 '13 at 20:47