diff options
Diffstat (limited to 'Master')
4 files changed, 116 insertions, 22 deletions
diff --git a/Master/texmf-dist/source/generic/tex4ht/ChangeLog b/Master/texmf-dist/source/generic/tex4ht/ChangeLog index 96bd7624c87..33bbb67a9ad 100644 --- a/Master/texmf-dist/source/generic/tex4ht/ChangeLog +++ b/Master/texmf-dist/source/generic/tex4ht/ChangeLog @@ -1,3 +1,9 @@ +2021-06-30 Michal Hoftich <michal.h21@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@freefriends.org> * tex4ht-4ht.tex (mwbk.4ht, natbib.4ht, report.4ht, diff --git a/Master/texmf-dist/source/generic/tex4ht/tex4ht-4ht.tex b/Master/texmf-dist/source/generic/tex4ht/tex4ht-4ht.tex index fdf31d5c556..5add32447a6 100644 --- a/Master/texmf-dist/source/generic/tex4ht/tex4ht-4ht.tex +++ b/Master/texmf-dist/source/generic/tex4ht/tex4ht-4ht.tex @@ -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 @@ definitions. %%%%%%%%%%%%%%%%%% \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@old@refstepcounter\orig:refstepcounter% +\def\refstepcounter{% + \@ifnextchar[{\refstepcounter@optarg}{\refstepcounter@noarg}%] +}% + +% fix for TeX4ht label mechanism +\def\cref:currentlabel#1{|<def :currentlabel for refstepcounter|>% + \anc:lbl r{#1}% +} + \def\refstepcounter@noarg#1{% \cref@old@refstepcounter{#1}% \cref@constructprefix{#1}{\cref@result}% @@ -3411,6 +3434,7 @@ This is basic support for the cleveref package. \protected@xdef\cref@currentlabel{% [\@tempa][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname} + \cref:currentlabel{#1}% }% \def\refstepcounter@optarg[#1]#2{% \cref@old@refstepcounter{#2}% @@ -3418,15 +3442,12 @@ This is basic support for the cleveref package. \@ifundefined{cref@#1@alias}% {\def\@tempa{#1}}% {\def\@tempa{\csname cref@#1@alias\endcsname}}% - \protected@edef\cref@currentlabel{% + \protected@xdef\cref@currentlabel{% [\@tempa][\arabic{#2}][\cref@result]% - \csname p@#2\endcsname\csname the#2\endcsname}}% -\Hinput{cleveref} - -|<cleveref links|> -\endinput ->>> \AddFile{8}{cleveref} - + \csname p@#2\endcsname\csname the#2\endcsname} + \cref:currentlabel{#2}% + }% +>>> Support for links from the \Verb|\cref| command. \Link[https://tex.stackexchange.com/a/475664/2891]{}{}More information.\EndLink @@ -3445,6 +3466,24 @@ Support for links from the \Verb|\cref| command. \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@thmnoarg\@thm% + \def\@thm{\@ifnextchar[{\cref@thmoptarg}{\cref@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@thmnoarg{#2}% + \o:cref@thmoptarg:[#1]{#2}{#3}{#4} + }% + \HLet\cref@thmoptarg\:tempb +}{}% +>>> + Cleveref depends on internal Hyperref macro when Hyperref is loaded. It causes crash, because Hyperref exits before this macro is defined. @@ -3456,9 +3495,17 @@ because Hyperref exits before this macro is defined. \<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@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} %%%%%%%%%%%%%%%%%% diff --git a/Master/texmf-dist/tex/generic/tex4ht/cleveref-hooks.4ht b/Master/texmf-dist/tex/generic/tex4ht/cleveref-hooks.4ht index 078f681f41c..fa43268436f 100644 --- a/Master/texmf-dist/tex/generic/tex4ht/cleveref-hooks.4ht +++ b/Master/texmf-dist/tex/generic/tex4ht/cleveref-hooks.4ht @@ -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@addtoreset\@addtoreset +% fixes for \refstepcounter +\let\orig:refstepcounter\refstepcounter +\let\orig:@thm\@thm +\:AtEndOfPackage{% +\let\refstepcounter\orig:refstepcounter +\let\@thm\orig:@thm +} + diff --git a/Master/texmf-dist/tex/generic/tex4ht/cleveref.4ht b/Master/texmf-dist/tex/generic/tex4ht/cleveref.4ht index 7af226d474a..e9aead433fb 100644 --- a/Master/texmf-dist/tex/generic/tex4ht/cleveref.4ht +++ b/Master/texmf-dist/tex/generic/tex4ht/cleveref.4ht @@ -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@old@refstepcounter\orig:refstepcounter% +\def\refstepcounter{% + \@ifnextchar[{\refstepcounter@optarg}{\refstepcounter@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@noarg#1{% \cref@old@refstepcounter{#1}% \cref@constructprefix{#1}{\cref@result}% @@ -28,6 +43,7 @@ \protected@xdef\cref@currentlabel{% [\@tempa][\arabic{#1}][\cref@result]% \csname p@#1\endcsname\csname the#1\endcsname} + \cref:currentlabel{#1}% }% \def\refstepcounter@optarg[#1]#2{% \cref@old@refstepcounter{#2}% @@ -35,10 +51,11 @@ \@ifundefined{cref@#1@alias}% {\def\@tempa{#1}}% {\def\@tempa{\csname cref@#1@alias\endcsname}}% - \protected@edef\cref@currentlabel{% + \protected@xdef\cref@currentlabel{% [\@tempa][\arabic{#2}][\cref@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@thmnoarg\@thm% + \def\@thm{\@ifnextchar[{\cref@thmoptarg}{\cref@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@thmnoarg{#2}% + \o:cref@thmoptarg:[#1]{#2}{#3}{#4} + }% + \HLet\cref@thmoptarg\:tempb +}{}% + + +\Hinput{cleveref} + \endinput |