
我想將以下(最小化)TeX 文件轉換為 HTML:
\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}
我的設定檔是
\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
我運行的命令是
make4ht -c /CONF/sample.cfg markup.tex "mathjax"
不幸的是,這會為兩個美元符號 $$ 之間的每個公式產生圖像。我怎樣才能解決這個問題?我試圖模仿解決方案這和這Michal 的答案是將兩個美元符號之間的所有內容進行去標記,但它不起作用。
另外,我不想使用 MathML,因為它解析我的公式的效果不如 TeX-to-MathJax。
答案1
它應該與最新的 TeX Live 發行版一起使用,但您也可以使用以下設定檔新增支援:
\Preamble{xhtml}
\catcode`\:=11
\Configure{$$}{\:HandleMathjaxCatcodes}{\:RestoreMathjaxCatcodes}{\expandafter\AltlDisplayDollars}
\long\def\AltlDisplayDollars#1$${\alteqtoks{\[#1\]}$$}
\catcode`\:=12
\begin{document}
\EndPreamble
它將$$
原始程式碼轉換為\[
輸出,因此您甚至不需要向 MathJax 提供任何配置。這是產生的 HTML 程式碼:
<!-- 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>