I am trying to convert some TeX files to html, for this I am using tex4ht. I am also using myconfig.cfg to produce html file. In this config file I have declared following two lines to translate \textit and \textbf declarations to <span class"italic>data</span> and <span class"bold>data</span>.

\Configure{textit}{\HCode{`<span class="italic">`}}{\HCode{`</span>`}}<br />
\Configure{textbf}{\HCode{`<span class="bold">`}}{\HCode{`</span>`}}

After running through tex4ht using the command htlatex test5 "myconfig, fn-out", output is

<span class="italic"><span class="t1xi-x-x-109">italic</span></span> 
<span class="bold"><span class="t1xb-x-x-109">bold</span></span>

my question is how to tell tex4ht to not to generate <span class="t1xi-x-x-109"> and <span class="t1xb-x-x-109">.

1 Answer 1


Sure, you can disable generating of such classes with \NoFonts ... \EndNoFonts command:

\Configure{textit}{\HCode{<span class="italic">}\NoFonts}{\EndNoFonts\HCode{</span>}}
\Configure{textbf}{\HCode{<span class="bold">}\NoFonts}{\EndNoFonts\HCode{</span>}}

The result:

<p class="noindent" >
<span class="bold">hello</span> <span class="italic">world</span> 
  • @michal.h21 Somewhere I found \Configure{textit}{\ifvmode\ShowPar\fi\HCode{<em>}\NoFonts}{\EndNoFonts\HCode{</em>}}. What is \ifvmode\ShowPar\fi purpose?
    – mmj
    Aug 3, 2016 at 5:57
  • 1
    @mmj It requests closing of previous paragraph in the case it wasn't closed yet. When that happens invalid xml code may be produced.
    – michal.h21
    Aug 3, 2016 at 18:10

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.