Skip to content

Commit

Permalink
use different hook with amsthm, issue #304
Browse files Browse the repository at this point in the history
  • Loading branch information
u-fischer committed Oct 27, 2023
1 parent 0ce00cb commit d3b8d4a
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 0 deletions.
20 changes: 20 additions & 0 deletions hyperref.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -10990,6 +10990,26 @@
}%
}%
}
% \end{macrocode}
% amsthm doesn't issue an item in the theorem, we delay the target into
% \cs{deferred@thm@head} and hope that it always begins a paragraph.
% \begin{macrocode}
\AddToHook{package/amsthm/after}
{
\renewcommand\Hy@theorem@refstepcounter[1]
{%
\H@refstepcounter{#1}%
\hyper@makecurrent{#1}%
\global\let\Hy@dth@currentHref\@currentHref
\AddToHookNext{cmd/deferred@thm@head/before}
{\AddToHookNext{para/begin}
{\let\Hy@tempa\@currentHref
\MakeLinkTarget*{\Hy@dth@currentHref}%
\global\let\@currentHref\Hy@tempa
}%
}%
}
}
\@ifundefined{hyper@nopatch@thm}{%
\AtBeginDocument{%
\@ifpackageloaded{cleveref}
Expand Down
17 changes: 17 additions & 0 deletions testfiles-pdftex/gh304-amsthm.lvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
\documentclass{article}
\input{regression-test}
\usepackage{amsthm}
\usepackage{hyperref}

\newtheorem{theorem}{Theorem}

\begin{document}
\START \showoutput

\begin{theorem}
bla \label{thm:lab}
\end{theorem}

\ref{thm:lab}

\end{document}
85 changes: 85 additions & 0 deletions testfiles-pdftex/gh304-amsthm.tlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
Completed box being shipped out [1]
\vbox(633.0+0.0)x407.0
.\hbox(0.0+0.0)x0.0
.\vbox(0.0+0.0)x0.0, glue set - 14.99626fil
..\kern 0.0
..\kern 16.0
..\kern -1.00374
..\hbox(0.0+0.0)x0.0, glue set - 60.99626fil
...\kern 0.0
...\kern 62.0
...\kern -1.00374
...\pdfdest name{page.1} xyz
...\penalty 10000
...\glue 0.0 plus 1.0fil minus 1.0fil
..\glue 0.0 plus 1.0fil minus 1.0fil
.\glue(\lineskip) 0.0
.\vbox(633.0+0.0)x407.0
..\glue 16.0
..\vbox(617.0+0.0)x345.0, shifted 62.0
...\vbox(12.0+0.0)x345.0, glue set 12.0fil
....\glue 0.0 plus 1.0fil
....\hbox(0.0+0.0)x345.0
.....\hbox(0.0+0.0)x345.0
...\glue 25.0
...\glue(\lineskip) 0.0
...\vbox(550.0+0.0)x345.0, glue set 519.94446fil
....\write-{}
....\pdfdest name{Doc-Start} xyz
....\glue(\topskip) 3.05556
....\hbox(6.94444+0.0)x345.0, glue set 266.37817fil
.....\penalty 10000
.....\hbox(0.0+0.0)x0.0
......\hbox(0.0+0.0)x0.0, shifted -12.0
.......\pdfdest name{theorem.1} xyz
.......\penalty 10000
.....\OT1/cmr/bx/n/10 T
.....\OT1/cmr/bx/n/10 h
.....\OT1/cmr/bx/n/10 e
.....\OT1/cmr/bx/n/10 o
.....\OT1/cmr/bx/n/10 r
.....\OT1/cmr/bx/n/10 e
.....\OT1/cmr/bx/n/10 m
.....\kern 0.0
.....\glue 3.83331 plus 1.91666 minus 1.27777
.....\OT1/cmr/bx/n/10 1
.....\kern 0.0
.....\OT1/cmr/bx/n/10 .
.....\glue 5.0 plus 1.0 minus 1.0
.....\OT1/cmr/m/it/10 b
.....\OT1/cmr/m/it/10 l
.....\OT1/cmr/m/it/10 a
.....\glue 3.57774 plus 1.53333 minus 1.0222
.....\write1{\newlabel{thm:lab}{{1}{\thepage }{}{theorem.1}{}}}
.....\penalty 10000
.....\penalty 10000
.....\glue(\parfillskip) 0.0 plus 1.0fil
.....\glue(\rightskip) 0.0
....\penalty -51
....\glue 8.0 plus 2.0 minus 4.0
....\glue(\parskip) 0.0 plus 1.0
....\glue(\parskip) 0.0
....\glue(\baselineskip) 5.55556
....\hbox(6.44444+0.0)x345.0, glue set 324.99998fil
.....\hbox(0.0+0.0)x15.0
.....\pdfstartlink(*+*)x* attr{/Border[0 0 1]/H/I/C[1 0 0]} action goto name{theorem.1}
.....\OT1/cmr/m/n/10 1
.....\pdfendlink
.....\penalty 10000
.....\glue(\parfillskip) 0.0 plus 1.0fil
.....\glue(\rightskip) 0.0
....\glue 0.0 plus 1.0fil
....\glue 0.0
....\glue 0.0 plus 0.0001fil
...\glue(\baselineskip) 23.55556
...\hbox(6.44444+0.0)x345.0
....\hbox(6.44444+0.0)x345.0, glue set 170.0fil
.....\glue 0.0 plus 1.0fil
.....\OT1/cmr/m/n/10 1
.....\glue 0.0 plus 1.0fil
.\kern 0.0
(gh304-amsthm.aux)
Package rerunfilecheck Info: File `gh304-amsthm.out' has not changed.
(rerunfilecheck) Checksum: D41D8CD98F00B204E9800998ECF8427E;0.

0 comments on commit d3b8d4a

Please sign in to comment.