Anchor position for AMS subequations
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 205
- Forks
- 41
- PR merge metrics
- No merged PRs in 30d
Description
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 the subequations.
I came up with a possible patch:
% 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?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied TeX.SX example and inspect hyperref's \HyOrg@subequations and \HyperRaiseLinkHook behavior. Done means the main subequations label anchors at the first subequation, while the other subequation anchors and ordinary equation anchors remain correctly positioned.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- latex
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100