我正在尝试将 Tex4ht 使用的 MathJax 字体更改为 AMS Euler,这可以通过在网页上包含以下代码来实现
<script type="text/x-mathjax-config">
var font = "Neo-Euler";
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$','$']],
displayMath: [['\\[','\\]']],
processEscapes: true,
},
"SVG":{
font:font
},
"HTML-CSS": {
webFont: font,
imageFont: font,
preferredFont: font,
availableFonts: [],
scale: 85,
mtextFontInherit: true
}
});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
但是,如果我尝试将其插入到\HCode
指令中,我会收到这些错误
\Configure{@HEAD}{\endparagraph\HCode{
<script type="text/x-mathjax-config">
var font = "Neo-Euler";
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$','$']],
displayMath: [['\\[','\\]']],
processEscapes: true,
},
"SVG":{
font:font
},
"HTML-CSS": {
webFont: font,
imageFont: font,
preferredFont: font,
availableFonts: [],
scale: 85,
mtextFontInherit: true
}
}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
}}
[ERROR] htlatex: ./config/html.cfg 149 Argument of \reserved@a has an extra }.
[ERROR] htlatex: ./config/html.cfg 149 Paragraph ended before \reserved@a was complete.
[ERROR] htlatex: ? 60 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Use of \@item doesn't match its definition.
[ERROR] htlatex: ? 68 Argument of \g:Advance has an extra }.
[ERROR] htlatex: ? 68 Paragraph ended before \g:Advance was complete.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Use of \@item doesn't match its definition.
[ERROR] htlatex: ? 68 Argument of \g:Advance has an extra }.
[ERROR] htlatex: ? 68 Paragraph ended before \g:Advance was complete.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Use of \@item doesn't match its definition.
[ERROR] htlatex: ? 68 Argument of \g:Advance has an extra }.
[ERROR] htlatex: ? 68 Paragraph ended before \g:Advance was complete.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Use of \@item doesn't match its definition.
[ERROR] htlatex: ? 68 Argument of \g:Advance has an extra }.
[ERROR] htlatex: ? 68 Paragraph ended before \g:Advance was complete.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Use of \@item doesn't match its definition.
[ERROR] htlatex: ? 68 Argument of \g:Advance has an extra }.
[ERROR] htlatex: ? 68 Paragraph ended before \g:Advance was complete.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Use of \@item doesn't match its definition.
[ERROR] htlatex: ? 68 Argument of \g:Advance has an extra }.
[ERROR] htlatex: ? 68 Paragraph ended before \g:Advance was complete.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Use of \@item doesn't match its definition.
[ERROR] htlatex: ? 68 Argument of \g:Advance has an extra }.
[ERROR] htlatex: ? 68 Paragraph ended before \g:Advance was complete.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Undefined control sequence.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[ERROR] htlatex: ? 68 Use of \@chapter doesn't match its definition.
[FATAL] make4ht-lib: Fatal error. Command htlatex returned exit code 1
我认为嵌入代码\verb||
可能会有帮助,但这会导致不同的问题。
[ERROR] htlatex: Compilation errors in the htlatex run
[ERROR] htlatex: Filename Line Message
[ERROR] htlatex: ? 150 TeX capacity exceeded, sorry [input stack size=5000].
[FATAL] make4ht-lib: Fatal error. Command htlatex returned exit code 1
我的完整配置文件是
\Preamble{xhtml}
% add tufte.css to your document
\Configure{AddCss}{/tufte.css}
\Configure{MathjaxSource}
{}
\Configure{@HEAD}{\endparagraph\HCode{
<script type="text/x-mathjax-config">
var font = "Neo-Euler";
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$','$']],
displayMath: [['\\[','\\]']],
processEscapes: true,
},
"SVG":{
font:font
},
"HTML-CSS": {
webFont: font,
imageFont: font,
preferredFont: font,
availableFonts: [],
scale: 85,
mtextFontInherit: true
}
}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
}}
% helper macro to close the current paragraph
\def\endparagraph{\ifvmode\IgnorePar\fi\EndP}
% insert <article> element to the document body
\Configure{@BODY}{\endparagraph\HCode{<article>}}
\Configure{@/BODY}{\endparagraph\HCode{</article>}}
% Tufte LaTeX makes \section and \subsection to behave like \section* and \subsection*
% so we need to configure like<section level>
% These configurations insert <section> elements and print titles in apropriate header elements
\Configure{likesection}
{\endparagraph\HCode{<section>}}{\endparagraph\HCode{</section>}}
{\HCode{<h2>}}{\HCode{</h2>}\par\ShowPar}
\Configure{likesubsection}
{\endparagraph\HCode{<section>}}{\endparagraph\HCode{</section>}}
{\HCode{<h3>}}{\HCode{</h3>}\par\ShowPar}
% we must redefine TOC to print starred sectioning commands
% \TableOfContents is provided by TeX4ht
\renewcommand\tableofcontents{\endparagraph\HCode{<h2>Contents</h2>\Hnewline}\TableOfContents[likesection,likesubsection]}
% custom \maketitle
\makeatletter
\renewcommand{\maketitle}{%
\begingroup%
\endparagraph\HCode{<h1>}\@title\HCode{</h1>}%
\HCode{<p class="subtitle">}\@author\HCode{</p>}%
\HCode{<p class="subtitle">}\@date\HCode{</p>}%
\endgroup
}
% make images resize automatically
\Configure{Gin-dim}{}
\Css{img {
max-width: 100\%;
height: auto;
}}
% fix for commands redefined by soul
\@ifpackageloaded{soul}{%
\renewcommand{\allcaps}[1]{\MakeTextUppercase{#1}}%
\renewcommand{\smallcaps}[1]{{\scshape\MakeTextLowercase{#1}}}%
\renewcommand{\textsc}[1]{\textcaps{#1}}%
}{}
% footnotes and sidenotes
\long\def\@tufte@sidenote[#1][#2]#3{%
\stepcounter\@mpfn%
\bgroup% make font changes local
\HCode{<label for="sitenote-\thempfn" class="margin-toggle sidenote-number"></label><input type="checkbox" id="sidenote-\thempfn" class="margin-toggle" />}%
\HCode{<span class="sidenote">}#3\HCode{</span>}%
\egroup%
}
\renewcommand\marginnote[2][0pt]{%
\stepcounter\@mpfn%
\bgroup% make font changes local
\HCode{<label for="sitenote-\thempfn" class="margin-toggle"></label><input type="checkbox" id="sidenote-\thempfn" class="margin-toggle" />}%
\HCode{<span class="marginnote">}#2\HCode{</span>}%
\egroup%
}
% environments
\ConfigureEnv{verbatim}{\endparagraph\HCode{<pre><code>}\NoFonts}{\EndNoFonts\endparagraph\HCode{</code></pre>}}{}{}
\ConfigureEnv{fullwidth}{\endparagraph\HCode{<div class="fullwidth">}%
\ConfigureList{list}{}{}{}{}% fullwidth uses list environment internally, we don't need this
\par\ShowPar\indent% require insertion of paragraph
}
{\endparagraph\HCode{</div>}}{}{}
% floats
\NewConfigure{marginfloat}{2}
% redefine internal margin float environment in order to prevent use of minipage and other undersirable environments
\renewenvironment{@tufte@margin@float}[2][-1.2ex]%
{\FloatBarrier% process all floats before this point so the figure/table numbers stay in order.
\begingroup%
\let\textwidth\marginparwidth% \includegraphics[width=\textwidth]{...} should work
\def\@captype{#2}%
\par%
% redefine paragraph
\Configure{HtmlPar}{\EndP\csname a:marginfloat\endcsname}{\EndP\csname a:marginfloat\endcsname}{\csname b:marginfloat\endcsname}{\csname b:marginfloat\endcsname}%
}
{\endgroup}
\Configure{marginfloat}{\HCode{<p><span class="marginnote">}
% we must handle \caption inside marginnote
\Configure{caption}{\HCode{<span class="figure">}}{:\space}{}{\HCode{</span>}}
}{\HCode{</span></p>}}{}{}
% display marginnote caption on a separate line
\Css{.marginnote .figure{display:block;}}
\renewenvironment{@tufte@float}[3][htbp]%
{\@float{#2}[#1]}{\end@float}
% caption should produce margin note by default
\Configure{caption}{\HCode{<span class="marginnote">}}{:\space}{}{\HCode{</span>}}
% figure* should produce full width image
% we need to make few adjustments
\ConfigureEnv{figure*}{
\Configure{float}{}{\endparagraph\HCode{<figure class="fullwidth">}}{\endparagraph\HCode{</figure>}\csname par\endcsname\ShowPar}
\Configure{caption}{\endparagraph\HCode{<span class="figure">}}{:\space}{}{\HCode{</span>}}
}{}{}{}
\ConfigureEnv{margintable}{\endparagraph\HCode{<div class="margintable">}\Configure{caption}{}{:\space}{}{}}{\endparagraph\HCode{</div>}}{}{}
% fix for display math length
\Css{div.math-display, div.par-math-display {width: 55\%}}
\makeatother
\begin{document}
\EndPreamble
有问题的 $\LaTeX$ 文件可以找到这里。
答案1
这似乎是 MathJax 配置中不必要的扩展的问题。您可以使用以下方法\detokenize
来防止这种情况:
\Configure{MathjaxSource}
{}
\Configure{@HEAD}{\endparagraph\HCode{
\detokenize{%
<script type="text/x-mathjax-config">
var font = "Neo-Euler";
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$','$']],
displayMath: [['\\[','\\]']],
processEscapes: true,
},
"SVG":{
font:font
},
"HTML-CSS": {
webFont: font,
imageFont: font,
preferredFont: font,
availableFonts: [],
scale: 85,
mtextFontInherit: true
}
}); </script> <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js"></script>
}}}
% helper macro to close the current paragraph
\def\endparagraph{\ifvmode\IgnorePar\fi\EndP}
请注意,我必须使用不同的 MathJax 地址,因为您使用的地址不再有效。另请注意,如果您使用最新的 TeX4ht,则可以使用\Configure{MathJaxConfig}
:
\Configure{MathJaxConfig}{{
\detokenize{
tex2jax: {
inlineMath: [['$','$']],
displayMath: [['\\[','\\]']],
processEscapes: true,
},
"SVG":{
font:"Neo-Euler"
},
"HTML-CSS": {
webFont: "Neo-Euler",
imageFont: "Neo-Euler",
preferredFont: "Neo-Euler",
availableFonts: [],
scale: 85,
mtextFontInherit: true
}
}
}}
当您使用选项时它可用make4ht filename.tex "mathjax"
。
不管怎样,看起来欧拉字体无论如何都没有被使用: