
다음 (최소화된) 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>