[tex4ht] Very strange problem with tex4ht using mathjax mode. Problem with \ followed by \] on new line. CR being stripped causing problem.

Nasser M. Abbasi nma at 12000.org
Thu Dec 20 08:13:38 CET 2018

This is probably the weirdest problem I found using mathjax.

I am having hard time understanding how to work around this
The same HTML generated using mathjax mode looks Ok on my computer
but does not look OK after ftp'ed up to the the server then looking
at it in the browser there.

Here is a MWE


Any one notice any problem with the above code? It is
valid latex and compiles OK with all systems.

Compiled this using

       make4ht foo1.tex "htm,mathjax"

And there is _NO_ problem, when I view it on my computer, running
windows 10, via localhost: URL using my local apache web server running
on windows.

Here comes the issue. I ftp the above HTML file to my hosting server
and then view it there, now it is no longer working.

The same exact HTML file and .css.
Here is screen shot side by side. Both views are using Chrom browser.
One on local PC and one on the server.


When I view source of the page on screen, it looks the same as on my PC
<!DOCTYPE html>
<html lang="en-US" xml:lang="en-US" >
<meta  charset="iso-8859-1" />
<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="foo1.css" />
<meta name="src" content="foo1.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="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<!--l. 6--><p class="noindent" >Therefore \[ A=0\\] Hence

The web hosting server runs Linux Apache. So it could be some encoding

The problem goes away when changing




Now you might ask, when I wrote A=0\ there instead of A=0? I did not.
This is fragment of code generated by Scientific word. SW tends to add
lots of \ for spacing everywhere.

Next, I went to this file DIFF free site, which does byte by byte difference.

I copied the HTML on my PC and the HTML on the server and compared them
side by side.

It turned out that on the server the _carriage return_ after A\ was
stripped out!, so the code on the server actually is A\\]  while on the PC
the CR is still there, so it actually like this


Here is screen shot side by side the file difference. Left
screen shot is on the server, and right side is same HTML on the PC


note that there is no issue with the code as is compiled in latex or SVG for
math. Only issue is with mathjax and only when ftp'ing it to the Linux server.

Any suggestion what one should do to avoid this problem? Is problem this to
be expected?

luckily this problem does not show in many places. For now, I can manually
remove the \ after the A. But SW will put it back next time
I edit the file. And this problem could be there in many
other places also but I have not noticed it before.

I am using TL 2018

>make4ht --version
make4ht version v0.2c

More information about the tex4ht mailing list