For some reason, after recent update of texlive, tex4ht in mathjax mode no longer generate valid math for this

\frac{\partial u}{\partial x}=0

Compiled using

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


enter image description here

But lualatex foo.tex gives the correct output

enter image description here

The HTML generated is

<!DOCTYPE html> 
<html lang='en-US' xml:lang='en-US'> 
<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='foo.css' rel='stylesheet' type='text/css' /> 
<meta content='foo.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>  
<!-- l. 9 --><p class='noindent'>\[ \frac {

tial u}{

tial x}=0 \]

What happened? Why tex4ht no longer generates correct math? This only happens when using mathjax mode. When not using mathjax mode, the output is correct.

TL 2021 updated about 2 weeks ago on Linux.

ps. issue added to tex4ht

  • 2
    \par from \partial has been changed to a blank line which looks.... unfortunate Commented Dec 1, 2021 at 22:32
  • @michal.h21 sorry I had a stray mkutils.lua (from I think answering an earlier question here about something) I deleted it.... Commented Dec 2, 2021 at 10:50
  • @DavidCarlisle ah, that explains it nicely :)
    – michal.h21
    Commented Dec 2, 2021 at 12:18
  • 1
    @Nasser; Good catch...
    – MadyYuvi
    Commented Dec 2, 2021 at 14:55

1 Answer 1


Thanks for the report. This issue was caused by previous change to the MathJax processing. The problem was that paragraphs in MathMode produced \par command instead of blank lines. I've used regex to fix that, but the issue is that it replaces \partial with two blank lines and string "tial". I've updated the regex, so it requires some white space after \par, which seems to fix the issue.

Here is updated version of mathjax-latex-4ht.4ht:

% mathjax-latex-4ht.sty (2021-12-02-10:19), generated from tex4ht-mathjax.tex
% Copyright 2018-2021 TeX Users Group
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
% This work has the LPPL maintenance status "maintained".
% The Current Maintainer of this work
% is the TeX4ht Project <http://tug.org/tex4ht>.
% If you modify this program, changing the
% version identification would be appreciated.
\immediate\write-1{version 2021-12-02-10:19}

\cs_new_protected:Npn \alteqtoks #1
  \tl_set:Nx \l_tmpa_tl {\detokenize{#1}}
  % % replace < > and & with xml entities
  \regex_replace_all:nnN { \x{26} } { &amp; } \l_tmpa_tl
  \regex_replace_all:nnN { \x{3C} } { &lt; } \l_tmpa_tl
  \regex_replace_all:nnN { \x{3E} } { &gt; } \l_tmpa_tl
  % replace \par command with blank lines
  \regex_replace_all:nnN { \x{5C}par\b } {\x{A}\x{A}} \l_tmpa_tl
  \tl_set:Nx \l_tmpb_tl{ \l_tmpa_tl }


% this seems a bit hacky -- we need to skip some code inserted at the
% beginning of each display math




The important changes is this:

  \regex_replace_all:nnN { \x{5C}par\b } {\x{A}\x{A}} \l_tmpa_tl

It now tests for white space after \par.

Resulting HTML:

enter image description here

  • 2
    \b (word boundary) might be safer than \s so \par\wibble still matches. Commented Dec 2, 2021 at 9:33
  • @DavidCarlisle thanks, I will update it in TL.
    – michal.h21
    Commented Dec 2, 2021 at 9:39
  • Thanks Michal. Tested on large file completed and see no issues.
    – Nasser
    Commented Dec 3, 2021 at 5:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .