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

Michal Hoftich INVALID.NOREPLY at gnu.org.ua
Thu Oct 6 11:54:23 CEST 2022


Author: michal_h21
Date: 2022-10-06 09:54:22 +0000 (Thu, 06 Oct 2022)
New Revision: 1210

Modified:
   trunk/lit/ChangeLog
   trunk/lit/tex4ht-mathjax.tex
Log:
added basic support for \label inside equations in the mathjax mode

Modified: trunk/lit/ChangeLog
===================================================================
--- trunk/lit/ChangeLog	2022-10-05 21:12:23 UTC (rev 1209)
+++ trunk/lit/ChangeLog	2022-10-06 09:54:22 UTC (rev 1210)
@@ -1,3 +1,9 @@
+2022-10-06  Michal Hoftich  <michal.h21 at gmail.com>
+
+	* tex4ht-mathjax.tex (mathjax-latex-4ht.4ht): added basic support
+	for \label commands inside equations.
+	https://tex.stackexchange.com/a/660581/2891
+
 2022-10-05  Michal Hoftich  <michal.h21 at gmail.com>
 
 	* tex4ht-mathml.tex (mathml.4ht): use displaystyle attribute also in

Modified: trunk/lit/tex4ht-mathjax.tex
===================================================================
--- trunk/lit/tex4ht-mathjax.tex	2022-10-05 21:12:23 UTC (rev 1209)
+++ trunk/lit/tex4ht-mathjax.tex	2022-10-06 09:54:22 UTC (rev 1210)
@@ -99,12 +99,24 @@
 The \verb|\VerbMath| command redefines environments to pass their content
 verbatim to the HTML output.
 
+The optional command can contain name of the counter that should be updated.
+It will also use LaTeX 3 regular expressions to search for label commands.
+Thanks to that, cross-referencing to the math environments should work.
+It is a bit limited, for example subequations cannot work. There can be also
+issues in books, where equation numbers are based on chapters, but MathJax
+numbers them consecutively. In these cases, other mechanisms may be necessary.
+
 \<defined commands\><<<
 \ExplSyntaxOn
-\newcommand\VerbMath[1]{%
+\cs_generate_variant:Nn \regex_extract_once:nnNTF {nV}
+\newcommand\VerbMath[2][]{%
   \cs_if_exist:cTF{#1}{
-    \RenewDocumentEnvironment{#1}{+!b}{%
-      \NoFonts\expandafter\VerbMathToks\expandafter{\detokenize{##1}}{#1}\EndNoFonts%
+    \RenewDocumentEnvironment{#2}{+!b}{%
+      \NoFonts\expandafter\VerbMathToks\expandafter{\detokenize{##1}}{#2}\EndNoFonts%
+      \ifx\relax#1\relax\else%
+      \refstepcounter{#1}%
+      \regex_extract_once:nVNTF { label\s* \x{7B}([^\x{7D}]*)\x{7D}} {\l_tmpb_tl} \l_tmp_seq {\label{\seq_item:Nn\l_tmp_seq{2}}} {}%
+      \fi
     }{}
   }{}%
 }
@@ -154,7 +166,7 @@
 \VerbMath{split}
 \VerbMath{multline}
 \VerbMath{multline*}
-\VerbMath{equation}
+\VerbMath[equation]{equation}
 \VerbMath{equation*}
 \VerbMath{math}
 \VerbMath{displaymath}



More information about the tex4ht-commits mailing list.