make4ht 失败,显示“LaTeX 错误:缺少 \begin{document} in `'”

make4ht 失败,显示“LaTeX 错误:缺少 \begin{document} in `'”

我在用基本TeX在 macOS Catalina 上。以下是我的 LaTeX 版本详细信息。

$ tex --version
TeX 3.14159265 (TeX Live 2020)
kpathsea version 6.3.2
Copyright 2020 D.E. Knuth.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the TeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the TeX source.
Primary author of TeX: D.E. Knuth.

$ pdflatex --version
pdfTeX 3.14159265-2.6-1.40.21 (TeX Live 2020)
kpathsea version 6.3.2
Copyright 2020 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.37; using libpng 1.6.37
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 4.02

$ make4ht --version
make4ht version v0.3f

我已经安装了 TeX Live,make4ht如下所示:

brew install --cask basictex
sudo tlmgr update --self
sudo tlmgr install make4ht luaxml tex4ht environ trimspaces

这是我的输入文件foo.tex

\documentclass{article}
\begin{document}
hello, world
\end{document}

失败的原因如下make4ht

$ make4ht foo.tex
[STATUS]  make4ht: Conversion started
[STATUS]  make4ht: Input file: foo.tex
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename     Line    Message
[ERROR]   htlatex: ./foo.tex    2        Undefined control sequence.
[ERROR]   htlatex: ./foo.tex    2        LaTeX Error: Missing \begin{document} in `'.
[ERROR]   htlatex: ./foo.tex    2        Undefined control sequence.
[ERROR]   htlatex: ./foo.tex    4        Undefined control sequence.
[ERROR]   htlatex: /usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/article.4ht       140      Undefined control sequence.
[ERROR]   htlatex: /usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/article.4ht       140      LaTeX Error: Missing \begin{document} in `'.
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename     Line    Message
[ERROR]   htlatex: ./foo.tex    2        Undefined control sequence.
[ERROR]   htlatex: ./foo.tex    2        LaTeX Error: Missing \begin{document} in `'.
[ERROR]   htlatex: ./foo.tex    2        Undefined control sequence.
[ERROR]   htlatex: ./foo.tex    4        Undefined control sequence.
[ERROR]   htlatex: /usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/article.4ht       140      Undefined control sequence.
[ERROR]   htlatex: /usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/article.4ht       140      LaTeX Error: Missing \begin{document} in `'.
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename     Line    Message
[ERROR]   htlatex: ./foo.tex    2        Undefined control sequence.
[ERROR]   htlatex: ./foo.tex    2        LaTeX Error: Missing \begin{document} in `'.
[ERROR]   htlatex: ./foo.tex    2        Undefined control sequence.
[ERROR]   htlatex: ./foo.tex    4        Undefined control sequence.
[ERROR]   htlatex: /usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/article.4ht       140      Undefined control sequence.
[ERROR]   htlatex: /usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/article.4ht       140      LaTeX Error: Missing \begin{document} in `'.
[STATUS]  make4ht: Conversion finished

以下是调试输出:

$ make4ht -m draft -a debug foo.tex
[INFO]    mkparams: Output dir: 
[INFO]    mkparams: Compiler: latex
[INFO]    mkparams: Latex options: -jobname=foo  
[INFO]    mkparams: tex4ht.sty: xhtml,,charset=utf-8
[INFO]    mkparams: tex4ht:  -cmozhtf -utf8
[INFO]    mkparams: build_file: foo.mk4
[INFO]    mkparams: Output format: html5
[STATUS]  make4ht: Conversion started
[STATUS]  make4ht: Input file: foo.tex
[INFO]    mkutils: Load extension   common_domfilters
[INFO]    mkutils: Cannot open config file  foo.mk4
[INFO]    make4ht-lib: setting param correct_exit
[INFO]    make4ht-lib: setting param ext
[INFO]    make4ht-lib: Adding:  ext dvi
[INFO]    htlatex: LaTeX call: latex --interaction=errorstopmode -jobname=foo   '\makeatletter\def\HCode{\futurelet\HCode\HChar}\def\HChar{\ifx"\HCode\def\HCode"##1"{\Link##1}\expandafter\HCode\else\expandafter\Link\fi}\def\Link#1.a.b.c.{\g@addto@macro\@documentclasshook{\RequirePackage[#1,html]{tex4ht}}\let\HCode\documentstyle\def\documentstyle{\let\documentstyle\HCode\expandafter\def\csname tex4ht\endcsname{#1,html}\def\HCode####1{\documentstyle[tex4ht,}\@ifnextchar[{\HCode}{\documentstyle[tex4ht]}}}\makeatother\HCode xhtml,,charset=utf-8,html5.a.b.c.\input "\detokenize{foo.tex}"'
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=latex)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-03-06> (./foo.tex
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/tex4ht.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/tex4ht.4ht
::::::::::::::::::::::::::::::::::::::::::
 TeX4ht info is available in the log file 
::::::::::::::::::::::::::::::::::::::::::
) (/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/tex4ht.sty
--- needs --- tex4ht foo ---
(./foo.tmp) (./foo.xref)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/html5.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/html5.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/html5.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/latex.4ht
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/html5.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/html5.4ht))
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/fontmath.4ht
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/unicode.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/html4-math.4ht)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/html5.4ht))
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/tex4ht/article.4ht
! Undefined control sequence.
l.140 \AtBeginEnvironment
                         [tex4ht]{abstract}{\ConfigureEnv{center}{\a:abstrac...

?

答案1

@michal.h21 的评论对解决问题非常有帮助。以下是解决问题的最小步骤:

sudo tlmgr update latex-bin

但是如果你要使用tlmgr它来更新 LaTeX,你不妨像这样更新整个 TeX Live 发行版,这也可以解决这个问题:

sudo tlmgr update --all

我更喜欢第二种解决方案,因为它会更新整个发行版,因此系统上不会存在不兼容版本的软件包。

相关内容