1

This looks like a new serious problem.

I have a document that used to compile OK with tex4ht. I have not build it for sometime. Today when I build it to HTML (in both case using mathjax mode) it is now not able to convert some math to HTML.

This only happens when using mathjax mode. The math is all valid amsmath package math so one would expect mathjax to handle it directly.

Here is MWE

\documentclass[12pt]{book}
\usepackage{amsmath}
\begin{document}
\begin{align}%
\begin{Bmatrix}
c_{1}\\
c_{2}\\
c_{3}\\
c_{4}%
\end{Bmatrix}
&  =%
\begin{pmatrix}
1 & -a & -b & ab\\
1 & a & -b & -ab\\
1 & a & b & ab\\
1 & -a & b & ab
\end{pmatrix}
^{-1}\tag{2}%
\end{align}
\end{document}

And now make4ht -ulm default -a debug foo2.tex "mathjax,htm" gives HTML

enter image description here

tex4ht compiles it OK when removing mathjax options, which indicates mathjax is either not able to handle this correctly or tex4ht generated wrong HTML? But then how did it work OK before?

Here is the raw HTML

<!DOCTYPE html> 
<html lang='en-US' xml:lang='en-US'> 
<head><title></title> 
<meta charset='utf-8' /> 
<meta content='TeX4ht (https://tug.org/tex4ht/)' name='generator' /> 
<meta content='width=device-width,initial-scale=1' name='viewport' /> 
<link href='foo2.css' rel='stylesheet' type='text/css' /> 
<meta content='foo2.tex' name='src' /> 
<script>window.MathJax = { tex: { tags: "ams", }, }; </script> 
 <script async='async' id='MathJax-script' src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js' type='text/javascript'></script>  
</head><body>
<!-- l. 33 --><p class='noindent'>\begin {align} \csname @begin:Bmatrix\endcsname \choose:begin {\let \choose:begin \@firstoftwo \ifx \EndPicture \:Undef \PushStack \envn:list \n:list \SaveEverypar \fi \let \chk:pic \EndPicture \ifx \EndPicture \:UnDef \list:save \let \after:end \empty \csname before:beginBmatrix\endcsname \fi \UseHook {env/Bmatrix/before}\@ifundefined {Bmatrix}{\def \reserved@a {\@latex@error {Environment Bmatrix undefined}\@eha }}{\def \reserved@a {\def \@currenvir {Bmatrix}\edef \@currenvline {\on@line }\ifx \EndPicture \:UnDef \ifx \this:listConfigure \empty \null:listConfigure \csname onBmatrix:list\endcsname \fi \fi \@execute@begin@hook {Bmatrix}\csname Bmatrix\endcsname }}\global \@ignorefalse \begingroup \@endpefalse \reserved@a }{\o:begin: {Bmatrix}} c_{1}\\ c_{2}\\ c_{3}\\ c_{4}\end {Bmatrix} &amp; =\begin {pmatrix} 1 &amp; -a &amp; -b &amp; ab\\ 1 &amp; a &amp; -b &amp; -ab\\ 1 &amp; a &amp; b &amp; ab\\ 1 &amp; -a &amp; b &amp; ab \end {pmatrix} ^{-1}\tag {2} \end {align}
</p>   
 
</body> 
</html>

What has changed to cause this math no longer to work in mathjax mode of current tex4ht?

Using TL 2021, fully updated about 2 week ago. On Linux ubuntu.

Here is a second simpler example that shows this problem

\documentclass[12pt]{book}
\usepackage{amsmath}
\begin{document}
\begin{align}%
\begin{pmatrix}
c_{1}\\
c_{2}\\
c_{3}%
\end{pmatrix}
&  =%
B
\end{align}
\end{document}

Gives

enter image description here

Instead of

enter image description here

Reference: Ticket in tex4ht

1 Answer 1

2

We use LaTeX 3 commands to patch math environments since last November. It seems that environment contents get expanded in this case. We can redefine the command that patches environments to use \detokenize in order to prevent the expansion:

\Preamble{xhtml}

\ExplSyntaxOn
\renewcommand\VerbMath[1]{%
  \cs_if_exist:cTF{#1}{
    \RenewDocumentEnvironment{#1}{+!b}{%
      \NoFonts\expandafter\VerbMathToks\expandafter{\detokenize{##1}}{#1}\EndNoFonts%
    }{}
  }{}%
}


\ExplSyntaxOff
\begin{document}
\EndPreamble

This is a result:

enter image description here

I will update TeX4ht sources, but the fix will be included in TL 2022.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.