[latex3-commits] [latex3/hyperref] develop: use different hook with amsthm, issue #304 (d3b8d4a)

github at latex-project.org github at latex-project.org
Fri Oct 27 15:27:46 CEST 2023


Repository : https://github.com/latex3/hyperref
On branch  : develop
Link       : https://github.com/latex3/hyperref/commit/d3b8d4ab8c17840eb165bf12e5c3a64b784590c6

>---------------------------------------------------------------

commit d3b8d4ab8c17840eb165bf12e5c3a64b784590c6
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Fri Oct 27 15:27:46 2023 +0200

    use different hook with amsthm, issue #304


>---------------------------------------------------------------

d3b8d4ab8c17840eb165bf12e5c3a64b784590c6
 hyperref.dtx                      | 20 +++++++++
 testfiles-pdftex/gh304-amsthm.lvt | 17 ++++++++
 testfiles-pdftex/gh304-amsthm.tlg | 85 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 122 insertions(+)

diff --git a/hyperref.dtx b/hyperref.dtx
index 228069a..6b86417 100644
--- a/hyperref.dtx
+++ b/hyperref.dtx
@@ -10990,6 +10990,26 @@
        }%
      }%  
   } 
+%    \end{macrocode}
+% amsthm doesn't issue an item in the theorem, we delay the target into
+% \cs{deferred at thm@head} and hope that it always begins a paragraph.
+%    \begin{macrocode}
+\AddToHook{package/amsthm/after}
+ {
+  \renewcommand\Hy at theorem@refstepcounter[1]
+   {%
+    \H at refstepcounter{#1}%
+    \hyper at makecurrent{#1}%
+    \global\let\Hy at dth@currentHref\@currentHref
+    \AddToHookNext{cmd/deferred at thm@head/before}
+     {\AddToHookNext{para/begin}
+       {\let\Hy at tempa\@currentHref
+        \MakeLinkTarget*{\Hy at dth@currentHref}%
+        \global\let\@currentHref\Hy at tempa
+       }%
+     }%  
+   }
+ }  
 \@ifundefined{hyper at nopatch@thm}{%  
 \AtBeginDocument{%  
  \@ifpackageloaded{cleveref}
diff --git a/testfiles-pdftex/gh304-amsthm.lvt b/testfiles-pdftex/gh304-amsthm.lvt
new file mode 100644
index 0000000..b5777a3
--- /dev/null
+++ b/testfiles-pdftex/gh304-amsthm.lvt
@@ -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}
\ No newline at end of file
diff --git a/testfiles-pdftex/gh304-amsthm.tlg b/testfiles-pdftex/gh304-amsthm.tlg
new file mode 100644
index 0000000..dc8d8e6
--- /dev/null
+++ b/testfiles-pdftex/gh304-amsthm.tlg
@@ -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.





More information about the latex3-commits mailing list.