I'm seeing some strange output for \emph text using htlatex with the beamer class. Using the following source:

        \emph{bold text}
            \item \emph{bold text}

and compiling with

pdflatex test.tex
mk4ht htlatex test.tex 'xhtml,html5,charset=utf-8' ' -cunihtf -utf8 -cvalidate'

I see the following HTML output (reformatted for readability, but otherwise unmodified):

<!DOCTYPE html> 
<html lang="en-US" xml:lang="en-US" > 
        <meta  charset="utf-8" /> 
        <meta name="generator" content="TeX4ht (http://www.tug.org/tex4ht/)" />
        <meta name="viewport" content="width=device-width,initial-scale=1" />
        <link rel="stylesheet" type="text/css" href="test.css" /> 
        <meta name="src" content="test.tex" /> 
        <span class="cmss-12x-x-120">Test</span>                                                               
        <!--l. 8--><p class="noindent" >
            <span class="cmssi-10x-x-109">bold text </span>
        <ul class="itemize1">
            <li class="itemize">
                <span class="cmssi-10x-x-109">bold</span>
                <span class="cmssi-10x-x-109">text</span>

As you can see, all \emph text is enclosed in <span> tags, and additionally \emph text within the itemize environment is separated into individual words, each in its own span.

No amount of \Configure{emph} in a config file affects this behaviour.

Clearly the output could be made to look right despite this weirdness. However my use case is generating accessible versions of content from presentation slides, so it's important to me to have semantically appropriate tags (e.g. <em>) and contiguous spans.

Is there a simple way to override this behaviour?

1 Answer 1


Beamer patches common font commands in order to support overlays. For most of them, it uses the original command definition, so tex4ht configurations still work. But it redefines \emph completely, so the configuration doesn't have any effect. It needs to be inserted again in beamer.4ht:


% Beamer redefines \emph, it is necessary to insert hooks again



The configuration may look like this (this contains also configuration for slide insertion):


    \HCode{<section class="slide">}\RecallEndP\par\ShowPar
   {\ifvmode\IgnorePar\fi\EndP \HCode{</section>}}
   {} {}
\Css{section.slide {border:solid black 0.4pt;margin-bottom:1em;}}


And this is the result:

<section class="slide">

<!--l. 8--><p class="noindent" ><em>bold text</em> </p>
    <ul class="itemize1">
    <li class="itemize">

  • Thank you! I'll try this once my toddler is asleep. Is beamer.4ht picked up automatically or do I have to add it to the htlatex arguments somewhere like I would with the config?
    – cooperised
    Jul 27, 2019 at 11:20
  • 1
    It is picked automatically if it is placed in the same directory as the Tex file
    – michal.h21
    Jul 27, 2019 at 13:13

You must log in to answer this question.

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