make4ht erstellt Bilder für Doppeldollarformeln trotz Mathjax-Option

make4ht erstellt Bilder für Doppeldollarformeln trotz Mathjax-Option

Ich möchte die folgende (minimierte) TeX-Datei in HTML konvertieren:

\documentclass{article}
\begin{document}
We have $a = a$, \(a = a\) and also
\[c = c\] and even
\begin{equation*}
  E = mc^2.
\end{equation*}
All seems to work, except for
$$F = ma.$$
\end{document}

Meine Konfigurationsdatei ist

\RequirePackage{amsmath,amsfonts,amssymb,amsthm,enumitem,booktabs,float,graphicx,hyperref}

\Preamble{xhtml}

\Configure{MathJaxConfig}{{
tex: {
      tags: "ams",
      \detokenize{%
      inlineMath: [ [’$’,’$’], ["\\\(","\\\)"] ],
      displayMath: [ [’$$’,’$$’], ["\\[","\\]"] ],}
      processEscapes: true,
      processEnvironments: true,
      packages: [’base’, ’color’, ’ams’, ’boldsymbol’, ’newcommand’, ’verb’]
  }
}}
\Configure{MathjaxSource}{https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js}


\def\eqref#1{$\mathrm{(\ref{#1})}$}

\begin{document}

\EndPreamble

und der Befehl, den ich ausführe, ist

make4ht -c /CONF/sample.cfg markup.tex "mathjax"

Leider werden dadurch Bilder für jede Formel erzeugt, die zwischen zwei Dollarzeichen $$ steht. Wie kann ich das beheben? Ich habe versucht, die Lösungen nachzuahmen, umDasUndDasAntworten von Michal durch Detokenisierung von allem zwischen zwei Dollarzeichen, aber es hat nicht funktioniert.

Außerdem möchte ich MathML nicht verwenden, da es meine Formeln nicht so gut analysiert wie TeX-to-MathJax.

Antwort1

Es sollte mit der aktuellen TeX Live-Distribution funktionieren, Sie können die Unterstützung aber auch mit der folgenden Konfigurationsdatei hinzufügen:

\Preamble{xhtml}
\catcode`\:=11
\Configure{$$}{\:HandleMathjaxCatcodes}{\:RestoreMathjaxCatcodes}{\expandafter\AltlDisplayDollars}
\long\def\AltlDisplayDollars#1$${\alteqtoks{\[#1\]}$$}
\catcode`\:=12
\begin{document}
\EndPreamble

Es konvertiert $$in Ihrer Quelle in \[die Ausgabe, sodass Sie MathJax nicht einmal eine Konfiguration bereitstellen müssen. Dies ist der resultierende HTML-Code:

<!-- l. 4 --><p class='noindent'>We have \(a = a\), \(a = a\) and also \[c = c\] and even \begin {equation*}  E = mc^2.  \end {equation*} All seems to work, except for
                                 \[F = ma.\]
</p>

Bildbeschreibung hier eingeben

verwandte Informationen