texlive[59783] Master/texmf-dist: cleveref fixes, tex4ht r963-964

commits+karl at tug.org commits+karl at tug.org
Thu Jul 1 00:14:34 CEST 2021


Revision: 59783
          http://tug.org/svn/texlive?view=revision&revision=59783
Author:   karl
Date:     2021-07-01 00:14:34 +0200 (Thu, 01 Jul 2021)
Log Message:
-----------
cleveref fixes, tex4ht r963-964

Revision Links:
--------------
    http://tug.org/svn/texlive?view=revision&revision=963

Modified Paths:
--------------
    trunk/Master/texmf-dist/source/generic/tex4ht/ChangeLog
    trunk/Master/texmf-dist/source/generic/tex4ht/tex4ht-4ht.tex
    trunk/Master/texmf-dist/tex/generic/tex4ht/cleveref-hooks.4ht
    trunk/Master/texmf-dist/tex/generic/tex4ht/cleveref.4ht

Modified: trunk/Master/texmf-dist/source/generic/tex4ht/ChangeLog
===================================================================
--- trunk/Master/texmf-dist/source/generic/tex4ht/ChangeLog	2021-06-30 21:19:31 UTC (rev 59782)
+++ trunk/Master/texmf-dist/source/generic/tex4ht/ChangeLog	2021-06-30 22:14:34 UTC (rev 59783)
@@ -1,3 +1,9 @@
+2021-06-30  Michal Hoftich  <michal.h21 at gmail.com>
+
+	* tex4ht-4ht.tex (cleveref-hooks.4ht, cleveref.4ht): fixed support for
+	\refstepcounter and amsthm theorems.
+	https://tex.stackexchange.com/a/603194/2891
+
 2021-06-27  Karl Berry  <karl at freefriends.org>
 
 	* tex4ht-4ht.tex (mwbk.4ht, natbib.4ht, report.4ht,

Modified: trunk/Master/texmf-dist/source/generic/tex4ht/tex4ht-4ht.tex
===================================================================
--- trunk/Master/texmf-dist/source/generic/tex4ht/tex4ht-4ht.tex	2021-06-30 21:19:31 UTC (rev 59782)
+++ trunk/Master/texmf-dist/source/generic/tex4ht/tex4ht-4ht.tex	2021-06-30 22:14:34 UTC (rev 59783)
@@ -1,4 +1,4 @@
-% $Id: tex4ht-4ht.tex 963 2021-06-27 15:11:41Z karl $
+% $Id: tex4ht-4ht.tex 965 2021-06-30 12:32:19Z michal_h21 $
 % tex tex4ht-4ht   or   ht tex tex4ht-4ht
 %
 % Copyright 2009-2021 TeX Users Group    
@@ -3394,14 +3394,37 @@
 %%%%%%%%%%%%%%%%%%
 \Section{cleveref}
 
-This is basic support for the cleveref package. 
-\Link[https://tex.stackexchange.com/a/220345/2891]{}{}Source.\EndLink
 
 \<cleveref.4ht\><<<
 % cleveref.4ht (|version), generated from |jobname.tex
-% Copyright 2018-2019 TeX Users Group
+% Copyright 2018-2021 TeX Users Group
 |<TeX4ht license text|>
 
+|<cleveref refstepcounter|>
+|<cleveref links|>
+|<cleveref amsthm|>
+
+\Hinput{cleveref}
+
+\endinput
+>>> \AddFile{8}{cleveref}
+
+This is basic support for the cleveref package. 
+\Link[https://tex.stackexchange.com/a/220345/2891]{}{}Source.\EndLink
+
+\<cleveref refstepcounter\><<<
+
+% orig:refstepcounter is saved in cleveref-hooks.4ht
+\let\cref at old@refstepcounter\orig:refstepcounter%
+\def\refstepcounter{%
+  \@ifnextchar[{\refstepcounter at optarg}{\refstepcounter at noarg}%]
+}%
+
+% fix for TeX4ht label mechanism
+\def\cref:currentlabel#1{|<def :currentlabel for refstepcounter|>%
+  \anc:lbl r{#1}%
+}
+
 \def\refstepcounter at noarg#1{%
   \cref at old@refstepcounter{#1}%
   \cref at constructprefix{#1}{\cref at result}%
@@ -3411,6 +3434,7 @@
   \protected at xdef\cref at currentlabel{%
     [\@tempa][\arabic{#1}][\cref at result]%
     \csname p@#1\endcsname\csname the#1\endcsname}
+    \cref:currentlabel{#1}%
     }%
 \def\refstepcounter at optarg[#1]#2{%
   \cref at old@refstepcounter{#2}%
@@ -3418,16 +3442,13 @@
   \@ifundefined{cref@#1 at alias}%
     {\def\@tempa{#1}}%
     {\def\@tempa{\csname cref@#1 at alias\endcsname}}%
-  \protected at edef\cref at currentlabel{%
+  \protected at xdef\cref at currentlabel{%
     [\@tempa][\arabic{#2}][\cref at result]%
-    \csname p@#2\endcsname\csname the#2\endcsname}}%
-\Hinput{cleveref}
+    \csname p@#2\endcsname\csname the#2\endcsname}
+    \cref:currentlabel{#2}%
+  }%
+>>>
 
-|<cleveref links|>
-\endinput
->>> \AddFile{8}{cleveref}
-
-
 Support for links from the \Verb|\cref| command. 
 \Link[https://tex.stackexchange.com/a/475664/2891]{}{}More information.\EndLink
 
@@ -3445,7 +3466,25 @@
 \HLet\@@@setcref=\:tempa
 >>>
 
+Fixes for the amsthm cleveref redefinitions.
+\Link[https://tex.stackexchange.com/q/491933/2891]{}{}More information.\EndLink
 
+\<cleveref amsthm\><<<
+\@ifpackageloaded{amsthm}{
+  \let\cref at thmnoarg\@thm%
+  \def\@thm{\@ifnextchar[{\cref at thmoptarg}{\cref at thmnoarg}}%]
+  \def\:tempb[#1]#2#3#4{%
+   % call original amsthm theorem definition, but
+   % disable \:thm in order to prevent infinite loop
+   \let\:thm\:gobble
+   \cref at thmnoarg{#2}%
+   \o:cref at thmoptarg:[#1]{#2}{#3}{#4}
+  }%
+  \HLet\cref at thmoptarg\:tempb
+}{}%
+>>>
+
+
 Cleveref depends on internal Hyperref macro when Hyperref is loaded. It causes crash,
 because Hyperref exits before this macro is defined.
 \Link[https://tex.stackexchange.com/a/540277/2891]{}{}More information\EndLink.
@@ -3456,9 +3495,17 @@
 
 \<cleveref-hooks.4ht\><<<
 % cleveref-hooks.4ht (|version), generated from |jobname.tex
-% Copyright 2020 TeX Users Group
+% Copyright 2020-2021 TeX Users Group
 |<TeX4ht license text|>
 \let\HyOrg at addtoreset\@addtoreset
+% fixes for \refstepcounter
+\let\orig:refstepcounter\refstepcounter
+\let\orig:@thm\@thm
+\:AtEndOfPackage{%
+\let\refstepcounter\orig:refstepcounter
+\let\@thm\orig:@thm
+}
+
 >>> \AddFile{9}{cleveref-hooks}
 
 %%%%%%%%%%%%%%%%%%

Modified: trunk/Master/texmf-dist/tex/generic/tex4ht/cleveref-hooks.4ht
===================================================================
--- trunk/Master/texmf-dist/tex/generic/tex4ht/cleveref-hooks.4ht	2021-06-30 21:19:31 UTC (rev 59782)
+++ trunk/Master/texmf-dist/tex/generic/tex4ht/cleveref-hooks.4ht	2021-06-30 22:14:34 UTC (rev 59783)
@@ -1,5 +1,5 @@
-% cleveref-hooks.4ht (2020-12-13-11:14), generated from tex4ht-4ht.tex
-% Copyright 2020 TeX Users Group
+% cleveref-hooks.4ht (2021-06-30-14:33), generated from tex4ht-4ht.tex
+% Copyright 2020-2021 TeX Users Group
 %
 % This work may be distributed and/or modified under the
 % conditions of the LaTeX Project Public License, either
@@ -16,7 +16,15 @@
 %
 % If you modify this program, changing the
 % version identification would be appreciated.
-\immediate\write-1{version 2020-12-13-11:14}
+\immediate\write-1{version 2021-06-30-14:33}
 
 \let\HyOrg at addtoreset\@addtoreset
+% fixes for \refstepcounter
+\let\orig:refstepcounter\refstepcounter
+\let\orig:@thm\@thm
+\:AtEndOfPackage{%
+\let\refstepcounter\orig:refstepcounter
+\let\@thm\orig:@thm
+}
 
+

Modified: trunk/Master/texmf-dist/tex/generic/tex4ht/cleveref.4ht
===================================================================
--- trunk/Master/texmf-dist/tex/generic/tex4ht/cleveref.4ht	2021-06-30 21:19:31 UTC (rev 59782)
+++ trunk/Master/texmf-dist/tex/generic/tex4ht/cleveref.4ht	2021-06-30 22:14:34 UTC (rev 59783)
@@ -1,5 +1,5 @@
-% cleveref.4ht (2019-02-19-15:55), generated from tex4ht-4ht.tex
-% Copyright 2018-2019 TeX Users Group
+% cleveref.4ht (2021-06-30-14:33), generated from tex4ht-4ht.tex
+% Copyright 2018-2021 TeX Users Group
 %
 % This work may be distributed and/or modified under the
 % conditions of the LaTeX Project Public License, either
@@ -16,9 +16,24 @@
 %
 % If you modify this program, changing the
 % version identification would be appreciated.
-\immediate\write-1{version 2019-02-19-15:55}
+\immediate\write-1{version 2021-06-30-14:33}
 
 
+
+% orig:refstepcounter is saved in cleveref-hooks.4ht
+\let\cref at old@refstepcounter\orig:refstepcounter%
+\def\refstepcounter{%
+  \@ifnextchar[{\refstepcounter at optarg}{\refstepcounter at noarg}%]
+}%
+
+% fix for TeX4ht label mechanism
+\def\cref:currentlabel#1{\let\cnt:currentlabel\@currentlabel
+\def\:@currentlabel{\ifx \cnt:currentlabel\@currentlabel
+   \expandafter\the\csname c@#1\endcsname\else \@currentlabel\fi}%
+%
+  \anc:lbl r{#1}%
+}
+
 \def\refstepcounter at noarg#1{%
   \cref at old@refstepcounter{#1}%
   \cref at constructprefix{#1}{\cref at result}%
@@ -28,6 +43,7 @@
   \protected at xdef\cref at currentlabel{%
     [\@tempa][\arabic{#1}][\cref at result]%
     \csname p@#1\endcsname\csname the#1\endcsname}
+    \cref:currentlabel{#1}%
     }%
 \def\refstepcounter at optarg[#1]#2{%
   \cref at old@refstepcounter{#2}%
@@ -35,10 +51,11 @@
   \@ifundefined{cref@#1 at alias}%
     {\def\@tempa{#1}}%
     {\def\@tempa{\csname cref@#1 at alias\endcsname}}%
-  \protected at edef\cref at currentlabel{%
+  \protected at xdef\cref at currentlabel{%
     [\@tempa][\arabic{#2}][\cref at result]%
-    \csname p@#2\endcsname\csname the#2\endcsname}}%
-\Hinput{cleveref}
+    \csname p@#2\endcsname\csname the#2\endcsname}
+    \cref:currentlabel{#2}%
+  }%
 
 \ifdefined\@firstoffive\else%
   \def\@firstoffive#1#2#3#4#5{#1}
@@ -52,5 +69,21 @@
 
 \HLet\@@@setcref=\:tempa
 
+\@ifpackageloaded{amsthm}{
+  \let\cref at thmnoarg\@thm%
+  \def\@thm{\@ifnextchar[{\cref at thmoptarg}{\cref at thmnoarg}}%]
+  \def\:tempb[#1]#2#3#4{%
+   % call original amsthm theorem definition, but
+   % disable \:thm in order to prevent infinite loop
+   \let\:thm\:gobble
+   \cref at thmnoarg{#2}%
+   \o:cref at thmoptarg:[#1]{#2}{#3}{#4}
+  }%
+  \HLet\cref at thmoptarg\:tempb
+}{}%
+
+
+\Hinput{cleveref}
+
 \endinput
 



More information about the tex-live-commits mailing list.