I read Margin Figures/captions and the answers within. I have stripped the definition of the marginfloats
from the tufte
documentclass into the MWE below.
Can the definition of \@tufte@margin@floatbox
be tweaked so that the hyperlink goes to the top of the figure, and not below the caption?
\documentclass{article}
\usepackage[left=6cm,right=1cm,showframe=true,
asymmetric=true]{geometry}
\usepackage{placeins}
\usepackage{hyperref}
\reversemarginpar
\setlength{\marginparwidth}{5cm}
\makeatletter
% Margin float environment
\newsavebox{\@tufte@margin@floatbox}
\newenvironment{@tufte@margin@float}[2][-1.2ex]%
{\FloatBarrier% process all floats before this point so the figure/table numbers stay in order.
\begin{lrbox}{\@tufte@margin@floatbox}%
\begin{minipage}{\marginparwidth}%
\def\@captype{#2}%
\hbox{}\vspace*{#1}%
\noindent%
}
{\end{minipage}%
\end{lrbox}%
\marginpar{\usebox{\@tufte@margin@floatbox}}%
}
% Margin figure environment
\newenvironment{marginfigure}[1][-1.2ex]%
{\begin{@tufte@margin@float}[#1]{figure}}
{\end{@tufte@margin@float}}
% Margin table environment
\newenvironment{margintable}[1][-1.2ex]%
{\begin{@tufte@margin@float}[#1]{table}}
{\end{@tufte@margin@float}}
\makeatother
\begin{document}
This is a hyperlink to Figure \ref{fig:test}
\newpage
\begin{marginfigure}
\centering
\rule{30pt}{20pt}
\caption{Figure in margin}
\label{fig:test}
\end{marginfigure}
\end{document}
Best Answer
The
hypcap
package attempts to find "a solution of the problem with hyperref, that links to floats points below the caption and not at the beginning of the float." (taken directly from the package documentation) Consequently, it provides\capstart
to denotes the start of floating environment and where the hyperlink should jump to.