当我尝试在 TeX4ht 中配置自定义定理环境时,得到了预期的错误输出
平均能量损失
\documentclass{book}
\newtheorem{theorem}{Theorem}
\newtheorem{theorem*}{Theorem}
\begin{document}
\begin{theorem}
Sample Theorem
\end{theorem}
\begin{theorem*}
Sample Theorem
\end{theorem*}
\end{document}
以下是我的 cfg 文件配置
\Preamble{xml,NoFonts,ext=xml}
%\Configure{newtheorem}{}{}{}{}
\ConfigureEnv{theorem}
{\ifvmode \IgnorePar\fi \EndP\HCode{<statement>\Hnewline<label>Theorem \thetheorem</label>}\IgnoreIndent \ShowPar\par}
{\ifvmode \IgnorePar\fi \EndP\HCode{</statement>}}
{}{}
\ConfigureEnv{theorem*}
{\ifvmode \IgnorePar\fi \EndP\HCode{<statement>\Hnewline<label>Theorem</label>}\IgnoreIndent \ShowPar\par}
{\ifvmode \IgnorePar\fi \EndP\HCode{</statement>}}
{}{}
\begin{document}
\EndPreamble
我得到如下输出:
<statement><label>Theorem 0</label>
<div class="newtheorem">
<p class="noindent"><span class="head">Theorem 1 </span>Sample Theorem</p>
<p class="indent"> </p>
</div>
</statement>
我没有配置<div class="newtheorem">
,但它是从\Configure{newtheorem}
html.4ht 中获取的,所以我将其复制到我的 cfg 文件中并进行修改,例如“\Configure{newtheorem}{}{}{}{}”,然后我也得到了如下所示的错误输出
<statement><label>Theorem 0</label>
<p class="noindent">Theorem 1 Sample Theorem</p>
</statement>
定理标签再次打印在段落开头<p class="noindent">Theorem 1
请帮助我如何配置如下所示的预期结果
<statement>
<label>Theorem 1</label>
<p class="noindent">Sample Theorem</p>
</statement>
答案1
我会<label>
在配置中插入元素newtheorem
,不需要打印定理编号环境配置:
\Preamble{xml,NoFonts,ext=xml}
%\Configure{newtheorem}{}{}{}{}
\ConfigureEnv{theorem}
{\ifvmode \IgnorePar\fi \EndP\HCode{<statement>\Hnewline}}
{\ifvmode \IgnorePar\fi \EndP\HCode{</statement>}}
{}{}
\ConfigureEnv{theorem*}
{\ifvmode \IgnorePar\fi \EndP\HCode{<statement>\Hnewline}}
{\ifvmode \IgnorePar\fi \EndP\HCode{</statement>}}
{}{}
\Configure{newtheorem}{\HCode{<label>}}{\HCode{</label>}\ifvmode\IgnorePar\fi\EndP\par}{}{}
\begin{document}
\EndPreamble
您唯一需要注意的是将\IgnorePar
语句放在哪里以删除虚假的段落。
结果如下:
<statement>
<label>
Theorem 1 </label>
<!--l. 7--><p class="indent" > Sample Theorem
</p>
</statement>
<statement>
<label>
Theorem 1 </label>
<!--l. 11--><p class="indent" > Sample Theorem
</p>
</statement>