2

I am using TeX4HT to convert LaTeX into HTML. I need the HTML structure of theorem-like environment to be like below:

  1. The <div> class attribute value should be the name of the type, such as theorem, lemma, or remark, based on the type of the environment. For instance, these tags could look like <div class="theorem"> or <div class="lemma">.

  2. Theorem label and head should be like below with the different class attribute value

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

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

I tried \Configure{newtheorem}, but I don't know how to update the expected result.

MWE:

\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}
5
  • 1
    Welcome to TeX.SE.
    – Mico
    Sep 8, 2023 at 5:32
  • Can you confirm that what command you are using for TeX4ht conversion?
    – MadyYuvi
    Sep 8, 2023 at 5:45
  • @MadyYuvi, I am using Make4ht.exe
    – sizr
    Sep 8, 2023 at 5:45
  • Is this tex.stackexchange.com/questions/369043/… helpful for you?
    – MadyYuvi
    Sep 8, 2023 at 6:02
  • @MadyYuvi, thanks for your suggestion, I already looked that solution in that solution also label and titles in same <label> tag but i need different tag
    – sizr
    Sep 8, 2023 at 6:14

1 Answer 1

3

Try this configuration file:

\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

It is a copy of the default TeX4ht configuration for theorems with two changes. It inserts the current theorem environment name as a class, thanks to the \@currenvir command, and I also changed the class to the name you wanted.

Unfortunately, it is not easy to insert tags between the theorem number and label, so we had to copy definition of \@begintheorem from amsmath.sty and here we can insert a modified version of \thmnote, named \beforethmname, which prints the label. Here we can close the thmlbl span element and open the thmhead.

This is the result:

enter image description here

 <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>
7
  • Thank you for the helpful advice; everything is operating as intended.
    – sizr
    Sep 9, 2023 at 7:23
  • i have an another doubt is possible to get the font style formatting like <italic> <bold> tag for the theorem label and head as in the dvi output i am using NoFonts option for genereating html file
    – sizr
    Sep 9, 2023 at 7:26
  • @sizr Sure, you can change <span> elements to <it> or <b>.
    – michal.h21
    Sep 9, 2023 at 10:22
  • thanks for the suggesting, sometime theorem head in bold, and remark head in italic in this case, both head style are same formatting in the HTML file, but should be in different formatting as in DVI
    – sizr
    Sep 14, 2023 at 14:14
  • @sizr I was wrong, the correct tag for italics is <i>, not <it>. Maybe that is the issue?
    – michal.h21
    Sep 14, 2023 at 15:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .