[tex4ht] verbatim in latex makes mathjax mode not work in V3

Nasser M. Abbasi nma at 12000.org
Thu Apr 9 02:20:59 CEST 2020


Just found the most amazing bug.

This MWE do not work in mathjax mode, when using V3 because of
some verbatim in the latex

=======================
\documentclass[11pt]{article}%
\usepackage{amsmath}
  
\begin{document}

$\sin x$

I've loaded a CSV:

\begin{verbatim}
Colors = Import[
   "d:\\bitbucket\\diversity\\data\\nlcd\\nlcd-colors.csv", "CSV"]
{{0., " 0.00000000000 0.00000000000 0.00000000000"}, {11.,
   " 0.27843137255 0.41960784314  ...
\end{verbatim}

\end{document}
================================

The command to compile is

make4ht -ulm default -a debug -c ./mathjax.cfg index.tex "htm,mathjax"

But one must use V3 mathjax to see the problem. Here is mathjax.cfg, which
just loads mathjax V3

================
\Preamble{xhtml,p-width}
%this disables make4ht loading mathjax
\Configure{MathjaxSource}{}

%this loads mathjax V 3.0
\Configure{@HEAD}{\HCode{
  <script id="MathJax-script" async
       src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" id="MathJax-script">
     </script>
\Hnewline}}

\begin{document}
\EndPreamble
========================

The HTML no longer render math at all. (raw HTML is at end)

If I just compile the same latex using the command

    make4ht -ulm default -a debug index.tex "htm,mathjax"

Then V2 mathjax is now used (since that is the default now), and
the math shows up OK !

This is all caused by the verbatim in the Latex. Something in that verbatim
is preventing mathjax V3 from working. Removing the verbatime, makes
V3 mathjax works. But I have no control of what is inside verbatim
and can't change it.

Is this a problem with mathjax V3 itself? If so I can report it once
I figure out where, Or is there something tex4ht can do about it?

Can others reproduce this problem? May be I should go back to V2 mathjax.

Here is the raw HTML code generated
================================
<!DOCTYPE html>
<html lang="en-US" xml:lang="en-US" >
<head> <title></title>
<meta  charset="utf-8" />
<meta name="generator" content="TeX4ht (http://www.tug.org/tex4ht/)" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" type="text/css" href="index.css" />
<meta name="src" content="index.tex" />
  <script type="text/x-mathjax-config"> MathJax.Hub.Config({ 'fast-preview': {disabled: true}, TeX: { extensions: ["color.js","AMSmath.js"], equationNumbers: { autoNumber: "AMS" } }, extensions: ["tex2jax.js"], tex2jax: {  inlineMath: [ ["\\\(","\\\)"] ], displayMath: [ ['$$','$$'], ["\\[","\\]"] ], processEscapes: true, processEnvironments: true } }); </script>
  <script type="text/javascript" src=""></script>
  <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" id="MathJax-script"> </script>
</head><body
>
<!--l. 6--><p class="noindent" >\(\sin x\)
</p><!--l. 8--><p class="indent" >   I’ve loaded a CSV:

</p>
<div class="verbatim" id="verbatim-1">
Colors = Import[
  <br />  &#x0022;d:\\bitbucket\\diversity\\data\\nlcd\\nlcd-colors.csv&#x0022;, &#x0022;CSV&#x0022;]
  <br />{{0., &#x0022; 0.00000000000 0.00000000000 0.00000000000&#x0022;}, {11.,
  <br />  &#x0022; 0.27843137255 0.41960784314  ...
</div>
<!--l. 15--><p class="nopar" >
</p>
  
</body>
</html>
==========================================

Thanks,

TL 2019
--Nasser


More information about the tex4ht mailing list.