hypertarget seems to aim a line too low

This was my very first question here: Hyperlinks to a bibliography are one line off. The reason is that hyperref links, like all TeX boxes, are placed on the baseline. There is an internal command \Hy@raisedlink which does more or less what Bruno's answer describes. Here is an example of its usage both inside and outside macros:

\documentclass{article}
\usepackage{hyperref}

\makeatletter
 \newcommand{\linkdest}[1]{\Hy@raisedlink{\hypertarget{#1}{}}}
\makeatother

\begin{document}

 Here are targets created
 \makeatletter
  \Hy@raisedlink{\hypertarget{t1}{}}directly
 \makeatother
 and \linkdest{t2}indirectly.  Here is one created by \hypertarget{t3}{}hypertarget.

 \hyperlink{t1}{Here} \hyperlink{t2}{are} \hyperlink{t3}{links}

\end{document}

The first two links should point above their targets, and the third one should point to its baseline.


I remember having the same problem (and failing to get a good solution). A clunky way is to raise the target by hand with \raisebox (from the graphicx package, I believe).

\documentclass{article}
\usepackage{hyperref}
\usepackage{graphicx}
\begin{document}
If we try to go \hypertarget{t1}{here}, this fails 
(it bring us at the bottom of the word ``here''), 
as you can \hyperlink{t1}{check}.

If we use some dirty code to raise the 
target\raisebox{\ht\strutbox}{\hypertarget{t2}{}},  %% 
then we will go to the right place. A \verb|\strut|
is a zero-width object whose height above the baseline
and depth below the baseline are such that it spans
the line completely from top to bottom. Then \verb|\ht\strutbox|
gives the height of such a \verb|\strut|, and our
\hyperlink{t2}{link} points to the right place.
\end{document}