I was testing some links within my produced PDF file and recognized that all of the links to an algorithm (from the algorithm2e
package) will jump to the beginning of the algorithm with skipping half of the algorithm's header and the caption of the algorithm. I use the ruled
option of the algorithm2e
package such that the caption will be above the actual algorithm.
Here is a minimal example:
\documentclass{scrbook}
\usepackage[colorlinks=true,linkcolor=blue]{hyperref}
\usepackage[ruled]{algorithm2e}
\begin{document}
Der Algorithmus \ref{alg:roundoff} approximiert das ''Closest Vector Problem``.
\newpage
\begin{algorithm}
\caption{\label{alg:roundoff}Babais \textsf{ROUNDING OFF-PROCEDURE}}
\emph{Berechne $r_1, r_2, \ldots, r_n \in R$, sodass $\vec{q} = r_1\vec{b}_1+r_2\vec{b}_2+\cdots+r_n\vec{b}_n$ gilt.}\\
$\vec{v} := \vec{0}$\\
\For{$i = 1,2,\ldots,n$}
{
$\vec{v} := \vec{v} + \lfloor r_i\rceil \cdot \vec{b}_i$
}
\end{algorithm}
\end{document}
This code will produce a (blue) link on the first page to the algorithm on the second page. But when zoomed and after clicking the link, it will jump to the following part of the algorithm:
Question: Is it possible to adjust the jump position for algorithms (from package algorithm2e
) such that a click will jump to the position before the algorithm header/caption even if the ruled
option of the algorithm2e
package is used?
latex + latex + dvips + ps2pdf