TeX4HT - 如何在类似定理的环境中添加额外标签

TeX4HT - 如何在类似定理的环境中添加额外标签

我正在使用 TeX4HT 将 LaTeX 转换为 HTML。我需要类定理环境的 HTML 结构如下所示:

  1. class<div>属性值应为类型的名称,例如定理、引理或注释,具体取决于环境的类型。例如,这些标签可能看起来像<div class="theorem"><div class="lemma">

  2. 定理标签和头部应该像下面这样具有不同的类属性值

    <span class='thmlbl'><a id='x1-1002r1'></a>Theorem 1.1<span>

    <span class="thmhead">(CG as a special case of GUG).</span>

我试过了\Configure{newtheorem},但我不知道如何更新预期结果。

梅威瑟:

\documentclass{book}
\usepackage{amsmath,amsfonts}
\usepackage{amsthm}


\newtheorem{theorem}{Theorem}

\begin{document}


\begin{theorem}[CG as a special case of GUG]\label{th(0)} 
Let $D'=\{(0,0)^t,(\alpha_1,\alpha_2)^t, (\beta_1,\beta_2)^t, (-\alpha_1-\beta_1,-\alpha_2-\beta_2)^t\}$ be an integer digit set and $M\in M_2(\mathbb{Z})$ be an expanding matrix. If $\alpha_1\beta_2-\alpha_2\beta_1\notin 2\mathbb{Z}$, then $\mu_{M,D'}$ is a spectral measure if and only if $M\in M_2(2\mathbb{Z})$.
\end{theorem}




\begin{theorem}\label{th1} 
Let $D'=\{(0,0)^t,(\alpha_1,\alpha_2)^t, (\beta_1,\beta_2)^t, (-\alpha_1-\beta_1,-\alpha_2-\beta_2)^t\}$ be an integer digit set and $M\in M_2(\mathbb{Z})$ be an expanding matrix. If $\alpha_1\beta_2-\alpha_2\beta_1\notin 2\mathbb{Z}$, then $\mu_{M,D'}$ is a spectral measure if and only if $M\in M_2(2\mathbb{Z})$.
\end{theorem}


\end{document}

答案1

尝试这个配置文件:

\Preamble{xhtml}

\begin{document}
\makeatletter
\Configure{newtheorem}
   {\ifvmode\IgnorePar\fi\EndP
     \HCode{<div class="\@currenvir">}\par\noindent\HCode{<span
           class="thmlbl">}\NoFonts}
   {\EndNoFonts\HCode{</span>}}
   {\ifvmode\IgnorePar\fi\EndP\HCode{</div>}\par\indent\ShowPar}

\def\@beforethmname#1{\HCode{</span><span class="thmhead">}#1}
\def\@begintheorem#1#2[#3]{%
  \deferred@thm@head{\the\thm@headfont \thm@indent
    \@ifempty{#1}{\let\thmname\@gobble}{\let\thmname\@iden}%
    \@ifempty{#2}{\let\thmnumber\@gobble}{\let\thmnumber\@iden}%
    \@ifempty{#3}{\let\thmnote\@gobble}{\let\thmnote\@beforethmname}%
    \thm@swap\swappedhead\thmhead{#1}{#2}{#3}%
    \the\thm@headpunct
    \thmheadnl % possibly a newline.
    \hskip\thm@headsep
  }%
  \ignorespaces}

\Css{.thmlbl{font-weight: bold;}}
\makeatother
\EndPreamble

这是 TeX4ht 定理默认配置的副本,但有两处更改。它通过命令将当前定理环境名称作为类插入\@currenvir,我还将类更改为您想要的名称。

不幸的是,在定理编号和标签之间插入标签并不容易,所以我们必须\@begintheorem从中复制定义,在这里我们可以插入一个名为amsmath.sty的修改版本,它打印标签。在这里我们可以关闭span 元素并打开。\thmnote\beforethmnamethmlblthmhead

结果如下:

在此处输入图片描述

 <div class='theorem'>
<!-- l. 11 --><p class='noindent'><span class='thmlbl'>
<a id='x1-2r1'></a>
Theorem 1</span><span class='thmhead'> (CG as a special case of GUG).   </span><span class='cmti-10'>Let</span> \(D'=\{(0,0)^t,(\alpha _1,\alpha _2)^t, (\beta _1,\beta _2)^t, (-\alpha _1-\beta _1,-\alpha _2-\beta _2)^t\}\) <span class='cmti-10'>be an integer digit set and</span> \(M\in M_2(\mathbb {Z})\)
<span class='cmti-10'>be an expanding matrix. If</span> \(\alpha _1\beta _2-\alpha _2\beta _1\notin 2\mathbb {Z}\)<span class='cmti-10'>, then</span> \(\mu _{M,D'}\) <span class='cmti-10'>is a spectral measure if and only if</span> \(M\in M_2(2\mathbb {Z})\)<span class='cmti-10'>.</span>
</p>
   </div>
<!-- l. 13 --><p class='indent'>
</p>
   <div class='theorem'>
<!-- l. 18 --><p class='noindent'><span class='thmlbl'>
<a id='x1-3r2'></a>
Theorem 2.  </span> <span class='cmti-10'>Let</span> \(D'=\{(0,0)^t,(\alpha _1,\alpha _2)^t, (\beta _1,\beta _2)^t, (-\alpha _1-\beta _1,-\alpha _2-\beta _2)^t\}\) <span class='cmti-10'>be an integer digit set and</span> \(M\in M_2(\mathbb {Z})\) <span class='cmti-10'>be an expanding matrix. If</span> \(\alpha _1\beta _2-\alpha _2\beta _1\notin 2\mathbb {Z}\)<span class='cmti-10'>, then</span>
\(\mu _{M,D'}\) <span class='cmti-10'>is a spectral measure if and only if</span> \(M\in M_2(2\mathbb {Z})\)<span class='cmti-10'>.</span>
</p>
   </div>

相关内容