2

When i am trying to configure the customized theorem environment in TeX4ht, getting wrong output as expected

MWE

\documentclass{book}
\newtheorem{theorem}{Theorem}
\newtheorem{theorem*}{Theorem}

\begin{document}
\begin{theorem}
Sample Theorem
\end{theorem}

\begin{theorem*}
Sample Theorem
\end{theorem*}
\end{document}

below is My cfg file configuration

\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

I am getting the output like below:

<statement><label>Theorem 0</label>
   <div class="newtheorem">
   <p class="noindent"><span class="head">Theorem&#x00A0;1 </span>Sample Theorem</p>
   <p class="indent">   </p>
   </div>
</statement>

I didn't configured <div class="newtheorem"> but it is taking from \Configure{newtheorem} from html.4ht, so i copied in to my cfg file and modified like `\Configure{newtheorem}{}{}{}{}' then also i am getting wrong output like below

<statement><label>Theorem 0</label>
<p class="noindent">Theorem&#x00A0;1 Sample Theorem</p>
</statement>

the theorem label is printed again at begining of para <p class="noindent">Theorem&#x00A0;1

Please help me to how to configure the expected result like below

<statement>
    <label>Theorem 1</label>
    <p class="noindent">Sample Theorem</p>
</statement>

1 Answer 1

5

I would insert <label> element in newtheorem configuration, there is no need to print the theorem number the environment configuration:

\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

The only thing you need to pay attention is where to put \IgnorePar statements to remove spurious paragraphs.

This is the result:

   <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>  
0

You must log in to answer this question.

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