[latex3-commits] [git/LaTeX3-latex3-hyperref] develop: fix thm handling with cleveref (19494eb)
Ulrike Fischer
fischer at troubleshooting-tex.de
Sat Apr 22 13:06:46 CEST 2023
Repository : https://github.com/latex3/hyperref
On branch : develop
Link : https://github.com/latex3/hyperref/commit/19494eb3c582fa63ddf76b16c98be9d1ab0587c4
>---------------------------------------------------------------
commit 19494eb3c582fa63ddf76b16c98be9d1ab0587c4
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Sat Apr 22 13:06:46 2023 +0200
fix thm handling with cleveref
>---------------------------------------------------------------
19494eb3c582fa63ddf76b16c98be9d1ab0587c4
ChangeLog.txt | 4 ++
doc/hyperref-doc.tex | 2 +
hyperref.dtx | 11 ++-
testfiles-pdftex/nopatch.lvt | 3 +
testfiles-pdftex/nopatch.tlg | 4 ++
.../{thm-003.lvt => thm-003-cleveref.lvt} | 2 +-
.../{thm-003.tlg => thm-003-cleveref.tlg} | 66 ++++++++---------
testfiles-pdftex/thm-003.tlg | 12 ++--
testfiles-pdftex/thm-004.lvt | 18 +++++
testfiles-pdftex/thm-004.tlg | 84 ++++++++++++++++++++++
10 files changed, 163 insertions(+), 43 deletions(-)
diff --git a/ChangeLog.txt b/ChangeLog.txt
index ede86c2..dc719fb 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,3 +1,7 @@
+2023-04-22 Ulrike Fischer
+ * fix cleveref/ntheorem incompability https://tex.stackexchange.com/q/683581/2388
+ * add nopatch option for \@thm
+
2023-04-20 Ulrike Fischer
* fix spacing issues in theorems with new \@thm handling, issues 11,48.
This requires etoolbox and the LaTeX para hooks.
diff --git a/doc/hyperref-doc.tex b/doc/hyperref-doc.tex
index 05b8a02..37f1599 100644
--- a/doc/hyperref-doc.tex
+++ b/doc/hyperref-doc.tex
@@ -571,6 +571,8 @@ side-effects must be carefully tested!
\item[longtable] hyperref redefines \cs{LT at start} and \cs{LT at array} to move the targets in a better place.
This code can be suppressed by defining \cs{hyper at nopatch@longtable}
+
+\item[theorems] hyperref patches \cs{@thm}. This code can be suppressed by defining \cs{hyper at nopatch@thm}
\end{description}
\section{Package options}
diff --git a/hyperref.dtx b/hyperref.dtx
index 94376fe..5c06319 100644
--- a/hyperref.dtx
+++ b/hyperref.dtx
@@ -10996,10 +10996,15 @@
\global\let\@currentHref\Hy at tempa
}%
}
+\@ifundefined{hyper at nopatch@thm}{%
\AtBeginDocument{%
-\ifpatchable\@thm{\refstepcounter}
- {\patchcmd\@thm{\refstepcounter}{\Hy at theorem@refstepcounter}{}{}}
- {}}
+ \@ifpackageloaded{cleveref}
+ {\AddToHook{cmd/@thm/before}{\ifhmode\unskip\fi}}
+ {%
+ \ifpatchable\@thm{\refstepcounter}
+ {\patchcmd\@thm{\refstepcounter}{\Hy at theorem@refstepcounter}{}{}}
+ {}%
+ }}}{}
% \end{macrocode}
%
% \section{Footnotes}\label{footnotes}
diff --git a/testfiles-pdftex/nopatch.lvt b/testfiles-pdftex/nopatch.lvt
index 68c955e..4a6f47b 100644
--- a/testfiles-pdftex/nopatch.lvt
+++ b/testfiles-pdftex/nopatch.lvt
@@ -13,6 +13,7 @@
\def\hyper at nopatch@counter{}
\def\hyper at nopatch@varioref{}
\def\hyper at nopatch@sectioning{}
+\def\hyper at nopatch@thm{}
\makeatother
\usepackage{hyperref}
\begin{document}
@@ -41,4 +42,6 @@
\ShowCommand\Vref at star
%sectioning
\ShowCommand\@ssect
+%
+\ShowCommand\@thm
\end{document}
\ No newline at end of file
diff --git a/testfiles-pdftex/nopatch.tlg b/testfiles-pdftex/nopatch.tlg
index 9c7a00a..466efc2 100644
--- a/testfiles-pdftex/nopatch.tlg
+++ b/testfiles-pdftex/nopatch.tlg
@@ -59,6 +59,10 @@ l. ...\ShowCommand\Vref at star
#1#2#3#4#5->\NR at gettitle {#5}\NR at ssect {#1}{#2}{#3}{#4}{\Sectionformat {#5}{#1}}.
<argument> \@ssect
l. ...\ShowCommand\@ssect
+> \@thm=macro:
+#1#2->\refstepcounter {#1}\@ifnextchar [{\@ythm {#1}{#2}}{\@xthm {#1}{#2}}.
+<argument> \@thm
+l. ...\ShowCommand\@thm
(nopatch.aux)
Package rerunfilecheck Info: File `nopatch.out' has not changed.
(rerunfilecheck) Checksum: D41D8CD98F00B204E9800998ECF8427E;0.
diff --git a/testfiles-pdftex/thm-003.lvt b/testfiles-pdftex/thm-003-cleveref.lvt
similarity index 98%
copy from testfiles-pdftex/thm-003.lvt
copy to testfiles-pdftex/thm-003-cleveref.lvt
index 4f65841..016bbbf 100644
--- a/testfiles-pdftex/thm-003.lvt
+++ b/testfiles-pdftex/thm-003-cleveref.lvt
@@ -5,7 +5,7 @@
\usepackage{
hyperref,
ntheorem}
-
+\usepackage{cleveref}
\newtheorem{definition}{Definition}[section]
\begin{document}
diff --git a/testfiles-pdftex/thm-003.tlg b/testfiles-pdftex/thm-003-cleveref.tlg
similarity index 97%
copy from testfiles-pdftex/thm-003.tlg
copy to testfiles-pdftex/thm-003-cleveref.tlg
index ff5c0fb..3b0e62f 100644
--- a/testfiles-pdftex/thm-003.tlg
+++ b/testfiles-pdftex/thm-003-cleveref.tlg
@@ -34,13 +34,13 @@ Completed box being shipped out [1]
.....\hbox(0.0+0.0)x390.0
...\glue 25.0
...\glue(\lineskip) 0.0
-...\vbox(592.0+0.0)x390.0, glue set 143.98462fil
+...\vbox(592.0+0.0)x390.0, glue set 155.98334fil
....\write-{}
....\pdfdest name{Doc-Start} xyz
....\write-{}
....\pdfdest name{chapter.1} xyz
-....\write3{\protect \BOOKMARK [0][-]{chapter.1}{\376\377\000T\000o\000o\000\040\\ETC.}
-....\write1{\@writefile{toc}{\protect \contentsline {chapter}{\protect \numberline \ETC.}
+....\write3{\protect \BOOKMARK [0][-]{chapter.1}{\376\377\000T\000o\000o\000\040\000m\000u\000c\000h\000\040\000v\000s\000p\000a\000c\000e}{}% 1}
+....\write1{\@writefile{toc}{\protect \contentsline {chapter}{\protect \numberline {1}Too much vspace}{\thepage }{chapter.1}\protected at file@percent }}
....\write1{\@writefile{lof}{\protect \addvspace {10\p@ }}}
....\write1{\@writefile{lot}{\protect \addvspace {10\p@ }}}
....\glue(\topskip) 12.0
@@ -185,20 +185,20 @@ Completed box being shipped out [1]
.....\OT1/cmr/m/n/12 g
.....\OT1/cmr/m/n/12 .
.....\penalty 10000
+.....\hbox(0.0+0.0)x0.0
+......\hbox(0.0+0.0)x0.0, shifted -14.5
+.......\pdfdest name{definition.1.0.1} xyz
+.......\penalty 10000
+.....\penalty 10000
.....\glue(\parfillskip) 0.0 plus 1.0fil
.....\glue(\rightskip) 0.0
....\penalty -51
....\glue 10.0 plus 4.0 minus 6.0
-....\write1{\@writefile{thm}{\protect \contentsline {definition}{{Definition}{1.0\ETC.}
+....\write1{\@writefile{thm}{\protect \contentsline {definition}{{Definition}{1.0.{1}}{proof script}}{\thepage }{definition.1.0.1}\protected at file@percent }}
....\glue(\parskip) 0.0 plus 1.0
....\glue(\parskip) 0.0
....\glue(\baselineskip) 3.16669
....\hbox(9.0+3.0)x390.0, glue set - 0.05005
-.....\penalty 10000
-.....\hbox(0.0+0.0)x0.0
-......\hbox(0.0+0.0)x0.0, shifted -14.5
-.......\pdfdest name{definition.1.0.1} xyz
-.......\penalty 10000
.....\hbox(9.0+3.0)x180.4847
......\glue 0.0
......\glue 0.0
@@ -365,7 +365,7 @@ Completed box being shipped out [1]
.....\glue(\parfillskip) 0.0 plus 1.0fil
.....\glue(\rightskip) 0.0
....\penalty -51
-....\glue 13.0 plus 6.0 minus 8.0
+....\glue 10.0 plus 4.0 minus 6.0
....\glue(\parskip) 0.0 plus 1.0
....\glue(\parskip) 0.0
....\glue(\baselineskip) 3.83337
@@ -454,20 +454,20 @@ Completed box being shipped out [1]
.....\OT1/cmr/m/n/12 n
.....\OT1/cmr/m/n/12 g
.....\penalty 10000
+.....\hbox(0.0+0.0)x0.0
+......\hbox(0.0+0.0)x0.0, shifted -14.5
+.......\pdfdest name{definition.1.0.2} xyz
+.......\penalty 10000
+.....\penalty 10000
.....\glue(\parfillskip) 0.0 plus 1.0fil
.....\glue(\rightskip) 0.0
....\penalty -51
....\glue 10.0 plus 4.0 minus 6.0
-....\write1{\@writefile{thm}{\protect \contentsline {definition}{{Definition}{1.0\ETC.}
+....\write1{\@writefile{thm}{\protect \contentsline {definition}{{Definition}{1.0.{2}}{proof script}}{\thepage }{definition.1.0.2}\protected at file@percent }}
....\glue(\parskip) 0.0 plus 1.0
....\glue(\parskip) 0.0
....\glue(\baselineskip) 3.16669
....\hbox(9.0+3.0)x390.0, glue set - 0.05005
-.....\penalty 10000
-.....\hbox(0.0+0.0)x0.0
-......\hbox(0.0+0.0)x0.0, shifted -14.5
-.......\pdfdest name{definition.1.0.2} xyz
-.......\penalty 10000
.....\hbox(9.0+3.0)x180.4847
......\glue 0.0
......\glue 0.0
@@ -634,7 +634,7 @@ Completed box being shipped out [1]
.....\glue(\parfillskip) 0.0 plus 1.0fil
.....\glue(\rightskip) 0.0
....\penalty -51
-....\glue 13.0 plus 6.0 minus 8.0
+....\glue 10.0 plus 4.0 minus 6.0
....\glue(\parskip) 0.0 plus 1.0
....\glue(\parskip) 0.0
....\glue(\baselineskip) 3.83337
@@ -724,20 +724,20 @@ Completed box being shipped out [1]
.....\OT1/cmr/m/n/12 g
.....\OT1/cmr/m/n/12 .
.....\penalty 10000
+.....\hbox(0.0+0.0)x0.0
+......\hbox(0.0+0.0)x0.0, shifted -14.5
+.......\pdfdest name{definition.1.0.3} xyz
+.......\penalty 10000
+.....\penalty 10000
.....\glue(\parfillskip) 0.0 plus 1.0fil
.....\glue(\rightskip) 0.0
....\penalty -51
....\glue 10.0 plus 4.0 minus 6.0
-....\write1{\@writefile{thm}{\protect \contentsline {definition}{{Definition}{1.0\ETC.}
+....\write1{\@writefile{thm}{\protect \contentsline {definition}{{Definition}{1.0.{3}}{proof script}}{\thepage }{definition.1.0.3}\protected at file@percent }}
....\glue(\parskip) 0.0 plus 1.0
....\glue(\parskip) 0.0
....\glue(\baselineskip) 3.16669
....\hbox(9.0+3.0)x390.0, glue set - 0.05005
-.....\penalty 10000
-.....\hbox(0.0+0.0)x0.0
-......\hbox(0.0+0.0)x0.0, shifted -14.5
-.......\pdfdest name{definition.1.0.3} xyz
-.......\penalty 10000
.....\hbox(9.0+3.0)x180.4847
......\glue 0.0
......\glue 0.0
@@ -904,7 +904,7 @@ Completed box being shipped out [1]
.....\glue(\parfillskip) 0.0 plus 1.0fil
.....\glue(\rightskip) 0.0
....\penalty -51
-....\glue 13.0 plus 6.0 minus 8.0
+....\glue 10.0 plus 4.0 minus 6.0
....\glue(\parskip) 0.0 plus 1.0
....\glue(\parskip) 0.0
....\glue(\baselineskip) 3.83337
@@ -993,20 +993,20 @@ Completed box being shipped out [1]
.....\OT1/cmr/m/n/12 n
.....\OT1/cmr/m/n/12 g
.....\penalty 10000
+.....\hbox(0.0+0.0)x0.0
+......\hbox(0.0+0.0)x0.0, shifted -14.5
+.......\pdfdest name{definition.1.0.4} xyz
+.......\penalty 10000
+.....\penalty 10000
.....\glue(\parfillskip) 0.0 plus 1.0fil
.....\glue(\rightskip) 0.0
....\penalty -51
....\glue 10.0 plus 4.0 minus 6.0
-....\write1{\@writefile{thm}{\protect \contentsline {definition}{{Definition}{1.0\ETC.}
+....\write1{\@writefile{thm}{\protect \contentsline {definition}{{Definition}{1.0.{4}}{proof script}}{\thepage }{definition.1.0.4}\protected at file@percent }}
....\glue(\parskip) 0.0 plus 1.0
....\glue(\parskip) 0.0
....\glue(\baselineskip) 3.16669
....\hbox(9.0+3.0)x390.0, glue set - 0.05005
-.....\penalty 10000
-.....\hbox(0.0+0.0)x0.0
-......\hbox(0.0+0.0)x0.0, shifted -14.5
-.......\pdfdest name{definition.1.0.4} xyz
-.......\penalty 10000
.....\hbox(9.0+3.0)x180.4847
......\glue 0.0
......\glue 0.0
@@ -1173,7 +1173,7 @@ Completed box being shipped out [1]
.....\glue(\parfillskip) 0.0 plus 1.0fil
.....\glue(\rightskip) 0.0
....\penalty -51
-....\glue 13.0 plus 6.0 minus 8.0
+....\glue 10.0 plus 4.0 minus 6.0
....\glue -2.33331
....\glue 0.0 plus 1.0fil
....\glue 0.0
@@ -1185,6 +1185,6 @@ Completed box being shipped out [1]
.....\OT1/cmr/m/n/12 1
.....\glue 0.0 plus 1.0fil
.\kern 0.0
-(thm-003.aux)
-Package rerunfilecheck Info: File `thm-003.out' has not changed.
+(thm-003-cleveref.aux)
+Package rerunfilecheck Info: File `thm-003-cleveref.out' has not changed.
(rerunfilecheck) Checksum: FDD0757A91C70E4B0CE5CD04E27FAE4E;124.
diff --git a/testfiles-pdftex/thm-003.tlg b/testfiles-pdftex/thm-003.tlg
index ff5c0fb..3a392a4 100644
--- a/testfiles-pdftex/thm-003.tlg
+++ b/testfiles-pdftex/thm-003.tlg
@@ -39,8 +39,8 @@ Completed box being shipped out [1]
....\pdfdest name{Doc-Start} xyz
....\write-{}
....\pdfdest name{chapter.1} xyz
-....\write3{\protect \BOOKMARK [0][-]{chapter.1}{\376\377\000T\000o\000o\000\040\\ETC.}
-....\write1{\@writefile{toc}{\protect \contentsline {chapter}{\protect \numberline \ETC.}
+....\write3{\protect \BOOKMARK [0][-]{chapter.1}{\376\377\000T\000o\000o\000\040\000m\000u\000c\000h\000\040\000v\000s\000p\000a\000c\000e}{}% 1}
+....\write1{\@writefile{toc}{\protect \contentsline {chapter}{\protect \numberline {1}Too much vspace}{\thepage }{chapter.1}\protected at file@percent }}
....\write1{\@writefile{lof}{\protect \addvspace {10\p@ }}}
....\write1{\@writefile{lot}{\protect \addvspace {10\p@ }}}
....\glue(\topskip) 12.0
@@ -189,7 +189,7 @@ Completed box being shipped out [1]
.....\glue(\rightskip) 0.0
....\penalty -51
....\glue 10.0 plus 4.0 minus 6.0
-....\write1{\@writefile{thm}{\protect \contentsline {definition}{{Definition}{1.0\ETC.}
+....\write1{\@writefile{thm}{\protect \contentsline {definition}{{Definition}{1.0.{1}}{proof script}}{\thepage }{definition.1.0.1}\protected at file@percent }}
....\glue(\parskip) 0.0 plus 1.0
....\glue(\parskip) 0.0
....\glue(\baselineskip) 3.16669
@@ -458,7 +458,7 @@ Completed box being shipped out [1]
.....\glue(\rightskip) 0.0
....\penalty -51
....\glue 10.0 plus 4.0 minus 6.0
-....\write1{\@writefile{thm}{\protect \contentsline {definition}{{Definition}{1.0\ETC.}
+....\write1{\@writefile{thm}{\protect \contentsline {definition}{{Definition}{1.0.{2}}{proof script}}{\thepage }{definition.1.0.2}\protected at file@percent }}
....\glue(\parskip) 0.0 plus 1.0
....\glue(\parskip) 0.0
....\glue(\baselineskip) 3.16669
@@ -728,7 +728,7 @@ Completed box being shipped out [1]
.....\glue(\rightskip) 0.0
....\penalty -51
....\glue 10.0 plus 4.0 minus 6.0
-....\write1{\@writefile{thm}{\protect \contentsline {definition}{{Definition}{1.0\ETC.}
+....\write1{\@writefile{thm}{\protect \contentsline {definition}{{Definition}{1.0.{3}}{proof script}}{\thepage }{definition.1.0.3}\protected at file@percent }}
....\glue(\parskip) 0.0 plus 1.0
....\glue(\parskip) 0.0
....\glue(\baselineskip) 3.16669
@@ -997,7 +997,7 @@ Completed box being shipped out [1]
.....\glue(\rightskip) 0.0
....\penalty -51
....\glue 10.0 plus 4.0 minus 6.0
-....\write1{\@writefile{thm}{\protect \contentsline {definition}{{Definition}{1.0\ETC.}
+....\write1{\@writefile{thm}{\protect \contentsline {definition}{{Definition}{1.0.{4}}{proof script}}{\thepage }{definition.1.0.4}\protected at file@percent }}
....\glue(\parskip) 0.0 plus 1.0
....\glue(\parskip) 0.0
....\glue(\baselineskip) 3.16669
diff --git a/testfiles-pdftex/thm-004.lvt b/testfiles-pdftex/thm-004.lvt
new file mode 100644
index 0000000..670837f
--- /dev/null
+++ b/testfiles-pdftex/thm-004.lvt
@@ -0,0 +1,18 @@
+% https://tex.stackexchange.com/q/683581/2388
+%
+\documentclass[a4paper,12pt]{report}
+\input{regression-test}
+\usepackage{hyperref}
+\usepackage{ntheorem}
+\usepackage{cleveref}
+
+\theoremstyle{plain}
+\newtheorem{lemma}{Lemma}[section]
+
+\begin{document}
+\START\showoutput
+
+\begin{lemma}
+ lemma
+\end{lemma}
+\end{document}
diff --git a/testfiles-pdftex/thm-004.tlg b/testfiles-pdftex/thm-004.tlg
new file mode 100644
index 0000000..0fd3301
--- /dev/null
+++ b/testfiles-pdftex/thm-004.tlg
@@ -0,0 +1,84 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+LaTeX Font Info: External font `cmex10' loaded for size
+(Font) <12> on input line ....
+LaTeX Font Info: External font `cmex10' loaded for size
+(Font) <8> on input line ....
+LaTeX Font Info: External font `cmex10' loaded for size
+(Font) <6> on input line ....
+Package hyperref Info: bookmark level for unknown lemma defaults to 0 on input line ....
+\tf at thm=\write...
+Completed box being shipped out [1]
+\vbox(679.0+0.0)x421.0
+.\hbox(0.0+0.0)x0.0
+.\vbox(0.0+0.0)x0.0, glue set - 18.99626fil
+..\kern 0.0
+..\kern 20.0
+..\kern -1.00374
+..\hbox(0.0+0.0)x0.0, glue set - 29.99626fil
+...\kern 0.0
+...\kern 31.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(679.0+0.0)x421.0
+..\glue 20.0
+..\vbox(659.0+0.0)x390.0, shifted 31.0
+...\vbox(12.0+0.0)x390.0, glue set 12.0fil
+....\glue 0.0 plus 1.0fil
+....\hbox(0.0+0.0)x390.0
+.....\hbox(0.0+0.0)x390.0
+...\glue 25.0
+...\glue(\lineskip) 0.0
+...\vbox(592.0+0.0)x390.0, glue set 566.93944fil
+....\write-{}
+....\pdfdest name{Doc-Start} xyz
+....\pdfdest name{lemma.0.0.1} xyz
+....\write1{\@writefile{thm}{\protect \contentsline {lemma}{{Lemma}{0.0.{1}}{}}{\thepage }{lemma.0.0.1}\protected at file@percent }}
+....\glue(\topskip) 3.66669
+....\hbox(8.33331+0.0)x390.0, glue set 274.94144fil
+.....\hbox(8.23334+0.0)x81.45827
+......\glue 0.0
+......\glue 0.0
+......\glue -5.87494
+......\hbox(8.23334+0.0)x81.45827
+.......\glue 5.87494
+.......\OT1/cmr/bx/n/12 L
+.......\OT1/cmr/bx/n/12 e
+.......\OT1/cmr/bx/n/12 m
+.......\OT1/cmr/bx/n/12 m
+.......\OT1/cmr/bx/n/12 a
+.......\glue 4.5 plus 2.25 minus 1.5
+.......\OT1/cmr/bx/n/12 0
+.......\OT1/cmr/bx/n/12 .
+.......\OT1/cmr/bx/n/12 0
+.......\OT1/cmr/bx/n/12 .
+.......\OT1/cmr/bx/n/12 1
+......\glue 5.87494
+.....\penalty 0
+.....\OT1/cmr/m/it/12 l
+.....\OT1/cmr/m/it/12 e
+.....\OT1/cmr/m/it/12 m
+.....\OT1/cmr/m/it/12 m
+.....\OT1/cmr/m/it/12 a
+.....\penalty 10000
+.....\glue(\parfillskip) 0.0 plus 1.0fil
+.....\glue(\rightskip) 0.0
+....\penalty -51
+....\glue 13.0 plus 6.0 minus 8.0
+....\glue 0.0 plus 1.0fil
+....\glue 0.0
+....\glue 0.0 plus 0.0001fil
+...\glue(\baselineskip) 22.26668
+...\hbox(7.73332+0.0)x390.0
+....\hbox(7.73332+0.0)x390.0, glue set 192.06253fil
+.....\glue 0.0 plus 1.0fil
+.....\OT1/cmr/m/n/12 1
+.....\glue 0.0 plus 1.0fil
+.\kern 0.0
+(thm-004.aux)
+Package rerunfilecheck Info: File `thm-004.out' has not changed.
+(rerunfilecheck) Checksum: D41D8CD98F00B204E9800998ECF8427E;0.
More information about the latex3-commits
mailing list.