I just discovered the hypcap packages which improves the \ref
link to point before the figures and tables instead of to captions. How can I do the same with my algorithms written with algorithm2e using the ruled
option?
Here is a minimal example where we cannot read the caption after clicking on the ref:
\documentclass{article}
\usepackage[ruled]{algorithm2e}
\usepackage{hyperref}
\usepackage{hypcap}
\begin{document}
\begin{algorithm}[H]
\capstart
\caption{How to write algorithms}
\label{alg:sample}
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;
\end{algorithm}
Text with a ref to algorithm \ref{alg:sample}.
\end{document}