3

I am tried to create configure the below environment with optional argument in TeX4ht

\newenvironment{proof}[1][Proof]{\textit{#1}:\ \ignorespaces}
                            {}

MWE

\documentclass{book}

\newenvironment{proof}[1][]{\def\arg{#1}\ifx\arg\empty\textit{Proof}\else\textit{#1}\fi:\ \ignorespaces}
                          {} 
\begin{document}
\begin{proof}
  Sample text
\end{proof}

\begin{proof}[Proof of Theorem~1]
Sample text
\end{proof}

\end{document}

CFG

\ConfigureEnv{proof}
         {\ifvmode \IgnorePar\fi \EndP\HCode{<statement>\Hnewline\Hnewline<label>Proof</label>}\IgnoreIndent \ShowPar\par}
         {\ifvmode \IgnorePar\fi \EndP\HCode{</statement>}}
         {}{}

I am using the optional argument in the definition, if the argument is present, it should be captured in the <label>xxxxxx</label> part, if else it should be captured as like <label>Proof</label>

I am getting the wrong output

<statement>
<label>Proof</label>
<p class="noindent"><italic>Proof </italic>:&#x00A0;Sample text</p>
</statement>

<statement>
<label>Proof</label>
<p class="noindent"><italic>Proof of Theorem&#x00A0;1</italic>:&#x00A0;Sample text
</p></statement>

Proof' was repeating due to the hard written in the in the\ConfigureEnv`,

How to add the argument in the \ConfigureEnv ?

or how to get the expected result like below

<statement>
<label>Proof</label>
<p class="noindent">Sample text</p>
</statement>

<statement>
<label>Proof of Theorem&#x00A0;1</label>
<p class="noindent">Sample text</p>
</statement>
2

I would make move the proof label printing part out of the environment to standalone command, which can be then configured to print your desired <label>:

package myproof.sty

\ProvidesPackage{myproof}

\newcommand\printproof[1]{\def\arg{#1}\ifx\arg\empty\textit{Proof}\else\textit{#1}\fi:}
\newenvironment{proof}[1][]{\printproof{#1}\ \ignorespaces}
                          {} 


\endinput

configuration file myproof.4ht:

\NewConfigure{printproof}{2}

\pend:defI\printproof{\a:printproof}
\append:defI\printproof{\b:printproof}

\ConfigureEnv{proof}
         {\ifvmode \IgnorePar\fi \EndP\HCode{<statement>}\IgnoreIndent \ShowPar\par}
         {\ifvmode \IgnorePar\fi \EndP\HCode{</statement>}}
         {}{}

\Configure{printproof}{\ifvmode\IgnorePar\fi\EndP\HCode{<label>}\NoFonts}{\EndNoFonts\HCode{</label>}\par}

\endinput

First, two hooks for tags inserting are defined using \NewConfigure, they are then inserted at the beginning and at the end of \printproof command using \pend:defI and \append:defI commands. The rest is just configuration for the tags. \NoFonts ... \EndNoFonts are used to suppress the italic fonts in <label> element.

The result:

<statement>
   <label>Proof :</label>
<!--l. 6--><p class="indent" >    Sample text
</p></statement>
   <statement>
   <label>Proof of Theorem 1:</label>
<!--l. 9--><p class="indent" >    Sample text
</p></statement>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.