You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to the way subequations was implemented, the hyperlink anchor for the main label is positioned on the baseline of the previous last line of text, then raised by \HyperRaiseLinkDefault. However, it is desired to have the anchor positioned at the same spot as that of the first line of the subequations.
% Code reproduced from https://tex.stackexchange.com/q/453821
% and https://tex.stackexchange.com/a/456282
\documentclass{article}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{cleveref}
% Let's patch \HyOrg@subequations from hyperref
\usepackage{etoolbox}
\makeatletter
% Change \HyperRaiseLinkLength for the main anchor in subequations
\preto\HyOrg@subequations{%
\renewcommand*\HyperRaiseLinkHook{%
% Drop the main anchor from the baseline of previous text by \abovedisplayskip
\setlength\HyperRaiseLinkLength{-\abovedisplayskip}%
% Then, raise the main anchor by 3pt
% (The 3pt is to cancel the -\lineskip from \displ@y, see amsldoc.tex)
\addtolength\HyperRaiseLinkLength{3pt}%
% To see the default position of the main anchor, uncomment the following line:
%\setlength\HyperRaiseLinkLength{0pt}%
}%
}
% Change nothing for the other anchors in subequations
\appto\HyOrg@subequations{%
\let\HyperRaiseLinkHook\@empty
}
\makeatother
\begin{document}
Some text before the subequations.
\begin{subequations}\label{eq:arithmetic}
\begin{align}
a + b &= c \label{eq:arithmetic-a} \\
a + b &= c \label{eq:arithmetic-b} \\
a + b &= c \nonumber \\
a + b &= c \label{eq:arithmetic-c}
\end{align}
\end{subequations}
Testing:
\Cref{eq:arithmetic,eq:arithmetic-a} bring me to the \emph{exact} same place,
while \cref{eq:arithmetic-b,eq:arithmetic-c} bring me to the correct subequations.
\begin{equation}
e^{i\pi} = -1 \label{eq:euler}
\end{equation}
Testing:
\Cref{eq:euler} bring me to Euler's identity.
\end{document}
Is it possible to make this the default behavior for anchoring subequations?
The text was updated successfully, but these errors were encountered:
From TeX.SX: Hyperref with align inside subequations.
Due to the way
subequations
was implemented, the hyperlink anchor for the main label is positioned on the baseline of the previous last line of text, then raised by\HyperRaiseLinkDefault
. However, it is desired to have the anchor positioned at the same spot as that of the first line of thesubequations
.I came up with a possible patch:
Is it possible to make this the default behavior for anchoring
subequations
?The text was updated successfully, but these errors were encountered: