tex4ht 在 mathjax 模式下遇到 $\frac{\partial u}{\partial x}=0$ 问题

tex4ht 在 mathjax 模式下遇到 $\frac{\partial u}{\partial x}=0$ 问题

由于某种原因,在最近更新 texlive 之后,mathjax 模式下的 tex4ht 不再为此生成有效的数学运算

\documentclass[12pt]{article} 
\usepackage{amsmath}
\begin{document}   
\[
\frac{\partial u}{\partial x}=0
\]
\end{document}

使用编译

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

给予

在此处输入图片描述

lualatex foo.tex给出了正确的输出

在此处输入图片描述

生成的 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='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>  
</head><body>
<!-- l. 9 --><p class='noindent'>\[ \frac {

tial u}{

tial x}=0 \]
</p>   
 
</body> 
</html>

发生了什么?为什么 tex4ht 不再生成正确的数学运算?这仅在使用 mathjax 模式时发生。当不使用 mathjax 模式时,输出是正确的。

TL 2021 大约两周前在 Linux 上更新。

附言:问题已添加至 tex4ht

答案1

感谢您的报告。此问题是由之前对 MathJax 处理的更改引起的。问题是 MathMode 中的段落产生了 \par 命令而不是空行。我使用正则表达式修复了这个问题,但问题是它将 \partial 替换为两个空行和字符串“tial”。我更新了正则表达式,因此它要求在 \par 后留一些空格,这似乎解决了这个问题。

以下是更新版本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}


\ExplSyntaxOn
\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 }
  \HCode{\l_tmpb_tl}
}
\ExplSyntaxOff

\NewConfigure{MathJaxConfig}{1}

\long\def\AltlMath#1\){\expandafter\alteqtoks{\(#1\)}\)}
\long\def\AltlDisplay#1\]{\alteqtoks{\[#1\]}\]}
\long\def\AltMathOne#1${\alteqtoks{\(#1\)}$}
% this seems a bit hacky -- we need to skip some code inserted at the
% beginning of each display math
\long\def\AltlDisplayDollars\fi#1$${\alteqtoks{\[#1\]}$$}

\newcommand\VerbMathToks[2]{%
  \alteqtoks{\begin{#2}
    #1
  \end{#2}}%
}
\ExplSyntaxOn
\newcommand\VerbMath[1]{%
  \cs_if_exist:cTF{#1}{
    \RenewDocumentEnvironment{#1}{+!b}{%
      \NoFonts\expandafter\VerbMathToks\expandafter{##1}{#1}\EndNoFonts%
    }{}
  }{}%
}
\ExplSyntaxOff
\def\fixmathjaxtoc#1{\Configure{writetoc}{\def#1{\detokenize{#1}}}}
\def\fixmathjaxsec#1{\def#1{\detokenize{#1}}}

\AtBeginDocument{%
\VerbMath{subarray}
\VerbMath{smallmatrix}
\VerbMath{matrix}
\VerbMath{pmatrix}
\VerbMath{bmatrix}
\VerbMath{Bmatrix}
\VerbMath{vmatrix}
\VerbMath{Vmatrix}
\VerbMath{cases}
\VerbMath{subequations}
\VerbMath{aligned}
\VerbMath{alignedat}
\VerbMath{gathered}
\VerbMath{gather}
\VerbMath{gather*}
\VerbMath{alignat}
\VerbMath{alignat*}
\VerbMath{xalignat}
\VerbMath{xalignat*}
\VerbMath{xxalignat}
\VerbMath{align}
\VerbMath{align*}
\VerbMath{flalign}
\VerbMath{flalign*}
\VerbMath{split}
\VerbMath{multline}
\VerbMath{multline*}
\VerbMath{equation}
\VerbMath{equation*}
\VerbMath{math}
\VerbMath{displaymath}
\VerbMath{eqnarray}
\VerbMath{eqnarray*}
\ConfigureEnv{gather}{}{}{}{}
\ConfigureEnv{gather*}{}{}{}{}
\ConfigureEnv{multline}{}{}{}{}
\ConfigureEnv{multline*}{}{}{}{}
\fixmathjaxsec\left
\fixmathjaxsec\right
\fixmathjaxtoc\int
\fixmathjaxtoc\,
\fixmathjaxtoc\sin
\fixmathjaxtoc\cos
\fixmathjaxtoc\tan
\fixmathjaxtoc\arcsin
\fixmathjaxtoc\arccos
\fixmathjaxtoc\arctan
\fixmathjaxtoc\csc
\fixmathjaxtoc\sec
\fixmathjaxtoc\cot
\fixmathjaxtoc\sinh
\fixmathjaxtoc\cosh
\fixmathjaxtoc\tanh
\fixmathjaxtoc\coth
\fixmathjaxtoc\log
\fixmathjaxtoc\ln
\fixmathjaxtoc\sum
\fixmathjaxtoc\(
\fixmathjaxtoc\)
\fixmathjaxtoc\begin
\fixmathjaxtoc\end
\fixmathjaxtoc\\
\fixmathjaxtoc\exp

}
\endinput

重要的变化是这样的:

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

现在它测试 之后的空格\par

生成的 HTML:

在此处输入图片描述

相关内容