6
\documentclass{beamer}
\usetheme{Madrid}
\begin{document}
\begin{frame}
aaa
\end{frame}
\begin{frame}
bbb
\end{frame}
\end{document}

The above tex file is to be converted into html. I am using the following command

make4ht filename.tex

However it throws error. The basic question is "Is it possible to convert beamer presentation to html using make4ht?"

1
  • An off-topic (but I think useful comment): pandoc is a powerful converter (at least for linux) that accepts tex files as input and output. It is not perfect ... But does a good job in many cases.
    – koleygr
    Mar 29, 2019 at 15:35

1 Answer 1

3

There is some support for Beamer in tex4ht, but it seems to be a little bit old - it is dated to 2003. It seems that it doesn't really work anymore, as Beamer changed substantially since that time. For example, it seems to support a slide environment instead of frame.

So it seems that we can just discard the current Beamer support and create a new one. Before it is added to the tex4ht sources, you can use the following beamer.4ht file:

\let\Hy@EveryPageAnchor\relax
\def\pgf@trimright@final{0pt}
\def\pgf@trimleft@final{0pt}
\let\origEndP\EndP
\AtBeginDocument{\def\EndP{\let\EndP\origEndP}\SaveEndP}
\endinput

It just fixes basic issues - spurious elements inserted for every page, some missing PGF commands and issues with paragraphs. This version will create just a plain document, without frames. If we want to keep the frames, we can configure them in a .cfg file:

\Preamble{xhtml}
   \ConfigureEnv{beamer@frameslide}
      {\ifvmode\IgnorePar\fi\EndP
       \HCode{<section class="slide">}\RecallEndP\par\ShowPar
      }
      {\ifvmode\IgnorePar\fi\EndP \HCode{</section>}}
      {} {}
   \Css{section.slide {border:solid black 0.4pt;margin-bottom:1em;}}
\begin{document}
\EndPreamble

This will insert <section class="slide"> element for every frame.

Result:

enter image description here

<section class="slide">


    <ul class="itemize1">
    <li class="itemize">
    first
    </li>
    <li class="itemize">
    second</li></ul>
<!--l. 16--><p class="noindent" >aaa


</p>
</section>


<section class="slide">


<!--l. 19--><p class="noindent" >bbb


</p>
</section>
2
  • I get framed frames, with the final contents, repeated for each slide of the frame. Frametitle shows with a color rectangle superimposed.
    – vonbrand
    Sep 1, 2020 at 17:10
  • @vonbrand the Beamer support is quite old, so some things maybe don't work well as Beamer changes and old configurations may break. I worked on Beamer support last year, but didn't finish it. I can try to take a look again, if you have some example.
    – michal.h21
    Sep 1, 2020 at 20:14

You must log in to answer this question.

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