[tex4ht-commits] [SCM] tex4ht updated: r829 - trunk/lit

michal_h21 at gnu.org.ua michal_h21 at gnu.org.ua
Sat Oct 17 12:56:38 CEST 2020


Author: michal_h21
Date: 2020-10-17 13:56:38 +0300 (Sat, 17 Oct 2020)
New Revision: 829

Modified:
   trunk/lit/ChangeLog
   trunk/lit/tex4ht-4ht.tex
Log:
added tutorial on patching and adapted cleveref

Modified: trunk/lit/ChangeLog
===================================================================
--- trunk/lit/ChangeLog	2020-10-17 10:28:57 UTC (rev 828)
+++ trunk/lit/ChangeLog	2020-10-17 10:56:38 UTC (rev 829)
@@ -32,6 +32,10 @@
 	the new package hook mechanism.
 	* tex4ht-4ht.tex (usepackage.4ht, fancyhdr-hooks.4ht): adapted fancyhdr for
 	the new package hook mechanism.
+	* tex4ht-4ht.tex (usepackage.4ht, cleveref-hooks.4ht): adapted cleveref for
+	the new package hook mechanism. 
+	* tex4ht-4ht.tex: added tutorial on how to write early package patching
+	hooks.
 
 2020-10-16  Michal Hoftich  <michal.h21 at gmail.com>
 

Modified: trunk/lit/tex4ht-4ht.tex
===================================================================
--- trunk/lit/tex4ht-4ht.tex	2020-10-17 10:28:57 UTC (rev 828)
+++ trunk/lit/tex4ht-4ht.tex	2020-10-17 10:56:38 UTC (rev 829)
@@ -439,6 +439,74 @@
 \ConfigureToc{subsubsection} {\empty}{\ }{}{\newline}
 >>>
 
+%%%%%%%%%%%%%%%%%%%%%%%%%
+\Section{Package patching handling}
+%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%
+% tutorial begin
+%%%%%%%%%%%%%%%%%%%%%%%%
+
+By default, .4ht files are loaded at begin document. When we need to patch 
+a package at the moment when it is loaded, we can use the mechanism provided
+by usepackage.4ht.
+
+The obsolete way is to use the following construct:
+
+\Verbatim
+\<use package\><<<
+packagename,>>>
+
+\<add to usepackage\><<<
+\def\:temp{packagename}\ifx\@currname\:temp
+% package redefinitions
+\fi
+>>>
+\EndVerbatim
+
+The downside of this that it loads usepackage.4ht again for each package
+it detects. This can slow down the compilation.
+
+The recommended way is the following: 
+
+\Verbatim
+\<add to usepackage\><<<
+% use package name as the second argument and name of the file
+% that contains redefinitions as the third 
+\Configure{PackageHooks}{packagename.sty}{packagename-hooks.4ht}
+>>>
+
+\<packagename-hooks.4ht\><<<
+% packagename-hooks.4ht (|version), generated from |jobname.tex
+% Copyright 2020 TeX Users Group
+|<TeX4ht copywrite|>
+% package redefinitions
+>>>\AddFile{9}{packagename-hooks}
+\EndVerbatim
+
+The contents of the hooks file can be following:
+
+\Verbatim
+% code before package is loaded
+% ...
+\:AtEndOfPackage{
+  % redefine package commands that are used in the preamble
+  % ...
+}
+\EndVerbatim
+
+You can use the following special commands in the hooks file:
+
+\Verbatim
+\:dontusepackage{packagename} % prevent the package from loading
+\:AtEndOfPackage{code} % redefine macros that can be used in the document preamble
+\EndVerbatim
+
+%%%%%%%%%%%%%%%%%%%%%%%%
+% tutorial end
+%%%%%%%%%%%%%%%%%%%%%%%%
+
+
 \<usepackage.4ht\><<<
 % usepackage.4ht (|version), generated from |jobname.tex
 % Copyright |CopyYear.2003. Eitan M. Gurari
@@ -3353,18 +3421,21 @@
 >>>
 
 
-\<use package\><<<
-cleveref,>>>
-%%%%%%%%%%%%%%%%%%
-
 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.
+
 \<add to usepackage\><<<
-\def\:temp{cleveref}\ifx\@currname\:temp
+\Configure{PackageHooks}{cleveref.sty}{cleveref-hooks.4ht}
+>>>
+
+\<cleveref-hooks.4ht\><<<
+% cleveref-hooks.4ht (|version), generated from |jobname.tex
+% Copyright 2020 TeX Users Group
+|<TeX4ht license text|>
 \let\HyOrg at addtoreset\@addtoreset
-\fi
->>>
+>>> \AddFile{9}{cleveref-hooks}
+
 %%%%%%%%%%%%%%%%%%
 \Section{authblk}
 



More information about the tex4ht-commits mailing list.