如果我尝试编译此示例文档
\documentclass{beamer}
\begin{document}
\begin{frame}{Test}
Test
\end{frame}
\end{document}
我htlatex temp.tex
得到输出:
l.34951 --- TeX4ht warning --- \Configure{frametitle}? ---
! LaTeX Error: Missing \begin{document} in `'.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.34952 ...i \EndP \HCode{<h2 class="frametitle">}
\bgroup
?
! Emergency stop.
...
l.34952 ...i \EndP \HCode{<h2 class="frametitle">}
\bgroup
No pages of output.
可以找到完整日志这里
答案1
这是的现代化版本beamer.4ht
,它可以编译您的示例:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% beamer.4ht 2021-04-30-17:38 %
% Copyright (C) 2003-2009 Eitan M. Gurari %
% Copyright 2009-2021 TeX Users Group
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work
% is the TeX4ht Project <http://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.
\NewConfigure{titlepage}{2}
\NewConfigure{title}{2}
\NewConfigure{author}{2}
\NewConfigure{institute}{2}
\NewConfigure{date}{2}
\NewConfigure{titlegraphic}{2}
\NewConfigure{andtitle}{1}
\NewConfigure{inst}{2}
\let\o:@section:\@section
\def\@section[#1]#2{%
\expandafter\global\expandafter\sl:toks\expandafter
{\the\sl:toks\leavevmode \o:@section:[#1]{#2}%
\add:toc{section}{\thesection}{\secname}}%
\expandafter\ifx\csname a:sec@slide\endcsname\relax
\expandafter\ifx\csname b:sec@slide\endcsname\relax
\the\sl:toks \global\sl:toks={}%
\fi\fi
%
}
\let\o:untitledsubsection:\untitledsubsection
\def\untitledsubsection#1{%
\expandafter\global\expandafter\sl:toks\expandafter
{\the\sl:toks\leavevmode \o:untitledsubsection:}%
\expandafter\ifx\csname a:sec@slide\endcsname\relax
\expandafter\ifx\csname b:sec@slide\endcsname\relax
\the\sl:toks \global\sl:toks={}%
\fi\fi
%
}
\newtoks\sl:toks
\NewConfigure{sec@slide}{2}
\def\addtocontents#1#2{%
\add:toc{#1}{}{#2}%
}
\def\add:toc#1#2#3{{%
\csname if:toc\endcsname{
\def\protect{\noexpand\noexpand\noexpand}%
\edef\:tempa{\the\:tokwrite{\string\doTocEntry
\string\toc#1{#2}{%
\string\csname\space a:TocLink\string\endcsname
{\FileNumber}{\cur:th\@currentlabel}{}{#3}%
}{}\relax
}%
}\:tempa
}%
}}
\def\tableofcontents{\futurelet\:temp\:TOC}
\def\:TOC{\ifx [\:temp \expandafter\:TableOfContents
\else \:TableOfContents[toc]\fi}
\pend:defI\alert{\a:alert}
\append:defI\alert{\b:alert}
\NewConfigure{alert}{2}
\pend:defI\structure{\a:structure}
\append:defI\structure{\b:structure}
\NewConfigure{structure}{2}
\NewConfigure{sectionshadedintoc}{2}
\NewConfigure{sectionintoc}{2}
\NewConfigure{subsectionshadedintoc}{2}
\NewConfigure{subsectionintoc}{2}
\ifx \beamer@version\:UnDef
\ifx \insertinstituteshort\:UnDef
\append:def\beamer@andtitle{\a:andtitle}
\def\beamer@insttitle#1{\a:inst$\sp{#1}$\b:inst}
\def\beamer@instinst#1{\a:inst$\sp{#1}$\b:inst\ignorespaces}
\pend:def\titlepage{%
\a:titlepage
\pend:def\inserttitle{\a:title}%
\append:def\inserttitle{\b:title}%
\pend:def\insertauthor{\a:author}%
\append:def\insertauthor{\b:author}%
\pend:def\insertinstitute{\a:institute}%
\append:def\insertinstitute{\b:institute}%
\pend:def\insertdate{\a:date}%
\append:def\insertdate{\b:date}%
\pend:def\inserttitlegraphic{\a:titlegraphic}%
\append:def\inserttitlegraphic{\b:titlegraphic}%
}
\append:def\titlepage{\b:titlepage}
\let\o:@subsection:\@subsection
\def\@subsection[#1]#2{%
\expandafter\global\expandafter\sl:toks\expandafter
{\the\sl:toks\leavevmode \o:@subsection:[#1]{#2}%
\add:toc{subsection}{\thesection.\thesubsection}{#2}}%
\expandafter\ifx\csname a:sec@slide\endcsname\relax
\expandafter\ifx\csname b:sec@slide\endcsname\relax
\the\sl:toks \global\sl:toks={}%
\fi\fi
%
}
\let\be:frameslide\frameslide
\def\frameslide{\a:sec@slide\the\sl:toks\b:sec@slide
\global\sl:toks={}\be:frameslide}
\else
\append:def\andtitle{\a:andtitle}
\def\insttitle#1{\a:inst$\sp{#1}$\b:inst}
\def\instinst#1{\a:inst$\sp{#1}$\b:inst\ignorespaces}
\pend:def\titlepage{%
\a:titlepage
\pend:def\inserttitletitle{\a:title}%
\append:def\inserttitletitle{\b:title}%
\pend:def\insertauthortitle{\a:author}%
\append:def\insertauthortitle{\b:author}%
\pend:def\insertinstitute{\a:institute}%
\append:def\insertinstitute{\b:institute}%
\pend:def\insertdate{\a:date}%
\append:def\insertdate{\b:date}%
\pend:def\inserttitlegraphic{\a:titlegraphic}%
\append:def\inserttitlegraphic{\b:titlegraphic}%
}
\append:def\titlepage{\b:titlepage}
\let\o:subsection:\subsection
\def\subsection#1{%
\expandafter\global\expandafter\sl:toks\expandafter
{\the\sl:toks\leavevmode \o:subsection:{#1}%
\add:toc{subsection}{\thesection.\thesubsection}{#1}}%
\expandafter\ifx\csname a:sec@slide\endcsname\relax
\expandafter\ifx\csname b:sec@slide\endcsname\relax
\the\sl:toks \global\sl:toks={}%
\fi\fi
%
}
\pend:def\slide{\a:sec@slide\the\sl:toks\b:sec@slide
\global\sl:toks={}}
\fi
\else
\fi
\let\Hy@EveryPageAnchor\relax
\def\pgf@trimright@final{0pt}
\def\pgf@trimleft@final{0pt}
\let\origEndP\EndP
\AtBeginDocument{\def\EndP{\let\EndP\origEndP}\SaveEndP}
\NewConfigure{frame}{2}
\NewConfigure{frametitle}{2}
\AddToHook{env/beamer@frameslide/before}{\RecallEndP\a:frame}
\AddToHook{env/beamer@frameslide/after}{\b:frame}
\long\def\:temp[#1]#2{%
\a:frametitle%
\o:beamer@@frametitle:[#1]{#2}%
\b:frametitle%
}
\HLet\beamer@@frametitle\:temp
% Beamer redefines \emph, it is necessary to insert hooks again
\pend:defI\emph{\a:emph}%
\append:defI\emph{\b:emph}%
\Hinput{beamer}
\endinput
它为默认情况下未配置的幻灯片定义了可配置的挂钩。因此您还需要使用一个myconfig.cfg
文件:
\Preamble{xhtml}
\Css{section.slide {border:solid black 0.4pt;margin-bottom:1em;}}
\Configure{frame}{\ifvmode\IgnorePar\fi\EndP
\HCode{<section class="slide">}
}{\ifvmode\IgnorePar\fi\EndP\HCode{</section>}}
\Configure{frametitle}{\ifvmode\IgnorePar\fi\EndP\HCode{<h2>}}{\ifvmode\IgnorePar\fi\EndP\HCode{</h2>}\par\ShowPar}
\begin{document}
\EndPreamble
使用 进行编译(不要使用htlatex
,因为它已被弃用):
make4ht -c myconfig.cfg temp.tex
结果如下: