Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The vertical scroll position after navigating to a \hypertarget from a \hyperlink (described in the hyperref manual) seems to be too low. The scroll position is at the baseline of the \hypertarget, so the target cannot be seen after clicking a \hyperlink.

If I run latex -output-format pdf document.tex twice on Mac OS X 10.8.2 to create a PDF from this document—

\documentclass{minimal}
\usepackage[colorlinks=true,raiselinks=true]{hyperref}
\usepackage{lipsum}
\begin{document}
\hyperlink{target1}{target1}
\hyperlink{target2}{target2}
%\hyperlink{target3}{target3}
\par\lipsum[1-7]
\lipsum*[8]
\hypertarget{target1}{target1}
\makeatletter\Hy@raisedlink{\hypertarget{target2}{target2}}\makeatother
%\raisebox{\ht\strutbox}{\hypertarget{target3}{target3}}
\end{document}

—all the \hyperlinks in the resulting document navigate to the baselines of their respective \hypertargets.

The example using \Hy@raisedlink is taken from hypertarget seems to aim a line too low. The example using \raisebox is taken from the same question, but I’ve commented it out because it shows different (but still unexpected) behavior.

This question is related to Certain hyperlinks (memoir+hyperref) placed too low and hypertarget seems to aim a line too low, but I am asking it as a new question because I am not using memoir, and neither of the solutions described in hypertarget seems to aim a line too low seem to work for me.

This issue seems to be the very thing that the hyperref option raiselinks is intended to address, but that option appears to have no effect on the example document.

How should one make a \hypertarget (or equivalent) that is above the baseline?

One could, I suppose, use \Hy@raisedlink with an empty \hypertarget (that is, a \hypertarget with no associated text), but I’m hoping there’s a better way.

share|improve this question

1 Answer 1

up vote 6 down vote accepted

The baseline is well known in TeX, but not the height of the current line. Only TeX knows this at a later time, after paragraph breaking. Measuring the height via boxing looses line breaking. \vadjust pre of pdfTeX was (is?) not stable enough, some circumstances causes segmentation faults. To some degree LuaTeX's attributes might help at the cost of a complete different non-trivial implementation. Back to the question, the current workaround is already mentioned (e.g. \Hy@raisedlink with empty \hypertarget).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.