使用 htlatex 时出错,没有生成输出文件:(

使用 htlatex 时出错,没有生成输出文件:(

我对使用 LaTeX 还很陌生,所以请多多包涵 :)

规格:使用 Windows 操作系统、TexLive、Overleaf(最初)。使用可访问的软件包https://libguides.lib.msu.edu/c.php?g=995742&p=8207771

情况:我正在用 LaTeX 开发一个基于数学的可访问性模板。我的 tex 文件是在 Overleaf 上制作的,没有错误。我已将此文件下载为 zip 文件,并将其解压缩,现在正尝试将此 tex 文件转换为 HTML 文件,以便屏幕阅读器可以更轻松地读取它(与 PDF 相比)。我在 Windows 操作系统上使用 TexLive 进行转换。

问题:我在 TexLive 命令行中使用 htlatex LaTeX_Accessible_Template.tex,但没有生成输出文件。我尝试查看日志文件,但在谷歌上搜索警告/错误却无济于事。

问题:有人能帮我解读日志文件并找出我做错的地方吗?我已将模板和日志文件都包含在下面的 Google Drive 中:

我认为主要问题在于日志文件中的以下几行:

! pdfTeX error (\pdfobj): not allowed in DVI mode (\pdfoutput <= 0).
<recently read> \pdfobj

l.68 \pdfobj
             reserveobjnum%
No pages of output.
Transcript written on LaTeX_Accessible_Template.log.
----------------------------
tex4ht.c (2023-10-13-15:32 kpathsea)
tex4ht LaTeX_Accessible_Template.tex
  -i/tex4ht/ht-fonts/
  -ewin32/tex4ht.env
--- warning --- Can't find/open file `LaTeX_Accessible_Template.dvi'
--- error --- Can't find/open file `LaTeX_Accessible_Template.dvi'
----------------------------
t4ht.c (2018-07-04-14:25 kpathsea)
t4ht LaTeX_Accessible_Template.tex
  -ewin32/tex4ht.env
(c:/texlive/2023/texmf-dist/tex4ht/base/unix/tex4ht.env)
--- warning --- Can't find/open file `LaTeX_Accessible_Template.lg'

答案1

正如 Ulrike 所说,这个accessibility软件包才是罪魁祸首。它明确使用了一些 PDFTeX 原语,导致 TeX4ht 使用的 DVI 模式下的 LaTeX 出现致命错误。

这是一个可以防止此致命错误的配置。它有点复杂,所以你可能需要等到 TeX Live 中包含修复程序,这应该很快就会实现。

我们需要多个配置文件才能使其工作。首先是usepackage.4ht

% usepackage.4ht (2023-11-10-15:20), generated from tex4ht-4ht.tex
% Copyright 2003-2009 Eitan M. Gurari
% Copyright 2009-2023 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.
\immediate\write-1{version 2023-11-10-15:20}

   \def\:temp{tex4ht}\ifx \:temp\@currname
   \:warning{\string\usepackage{tex4ht} again?}
   \def\:temp#1htex4ht.def,tex4ht.sty#2!*?: {\def\:temp{#2}}
\expandafter\:temp \@filelist htex4ht.def,tex4ht.sty!*?: %
\ifx \:temp\empty  \else
   \:warning{if
    \string\RequirePackage[tex4ht]{hyperref} or
    \string\usepackage[tex4ht]{hyperref} was
    used try instead, repectively,
    \string\RequirePackage{hyperref} or
    \string\usepackage{hyperref}}
\fi

\fi
\gdef\a:usepackage{\use:package ,!*?: }
\gdef\use:package#1,{%
   \if :#1:\def\:temp##1!*?: {}\else
      \def\:temp{#1}\ifx \@currname\:temp
             \def\:temp##1!*?: {\input usepackage.4ht  }%
      \else \let\:temp=\use:package \fi
   \fi \:temp}
\Configure{PackageHooks}{titlesec.sty}{titlesec-hooks.4ht}
\Configure{PackageHooks}{biblatex-chicago.sty}{biblatex-chicago-hooks.4ht}
\Configure{PackageHooks}{cleveref.sty}{cleveref-hooks.4ht}
\Configure{PackageHooks}{xr.sty}{xr-hooks.4ht}
\Configure{PackageHooks}{xr-hyper.sty}{xrhyper-hooks.4ht}
\Configure{PackageHooks}{eso-pic.sty}{esopic-hooks.4ht}
\Configure{PackageHooks}{showframe.sty}{showframe-hooks.4ht}
\Configure{PackageHooks}{expl3.sty}{expl3-hooks.4ht}
\Configure{PackageHooks}{savetrees.sty}{savetrees-hooks.4ht}
\Configure{PackageHooks}{newcomputermodern.sty}{newcomputermodern-hooks.4ht}
\Configure{PackageHooks}{newcomputermodern.sty}{newcomputermodern-hooks.4ht}
\Configure{PackageHooks}{fontawesome5-utex-helper.sty}%
{fontawesome5-utex-helper-hooks.4ht}
\Configure{PackageHooks}{fontawesome5.sty}{fontawesome5-hooks.4ht}
\Configure{PackageHooks}{biblatex.sty}{biblatex-hooks.4ht}
\Configure{PackageHooks}{xeCJK.sty}{xecjk-hooks.4ht}
\Configure{PackageHooks}{unicode-math.sty}{unicode-math-hooks.4ht}
\Configure{PackageHooks}{ctex.sty}{ctex-hooks.4ht}
\AddToHook{class/ctexart/before}{\input{ctexart-hooks.4ht}}
\Configure{PackageHooks}{luatexja.sty}{luatexja-hooks.4ht}
\Configure{PackageHooks}{luatexja-fontspec.sty}{luatexja-hooks.4ht}
\Configure{PackageHooks}{polyglossia.sty}{polyglossia-hooks.4ht}
\Configure{PackageHooks}{fontspec.sty}{fontspec-hooks.4ht}
\Configure{PackageHooks}{tikz.sty}{tikz-hooks.4ht}
\Configure{PackageHooks}{pdfbase.sty}{pdfbase-hooks.4ht}
\Configure{PackageHooks}{pdfx.sty}{pdfx-hooks.4ht}
\Configure{PackageHooks}{lua-widow-control.sty}{lua-widow-control-hooks.4ht}
\Configure{PackageHooks}{tagpdf.sty}{tagpdf-hooks.4ht}
\Configure{PackageHooks}{accessibility.sty}{accessibility-hooks.4ht}
\Configure{PackageHooks}{embedfile.sty}{embedfile-hooks.4ht}
\Configure{PackageHooks}{breakurl.sty}{breakurl-hooks.4ht}
\Configure{PackageHooks}{hyperref.sty}{hyperref-hooks.4ht}
\Configure{PackageHooks}{bookmark.sty}{bookmark-hooks.4ht}
\AddToHook{package/tabu/before}{\RequirePackage{tabularx}}
\Configure{PackageHooks}{caption.sty}{caption-hooks.4ht}
\Configure{PackageHooks}{footnotebackref.sty}{footnotebackref-hooks.4ht}
\AddToHook{package/doc/before}{\SUPOff}
\AddToHook{package/doc/after}{\SUPOn}
\AddToHook{package/hypdoc/before}{\SUPOff}
\AddToHook{package/hypdoc/after}{\SUPOn}
\Configure{PackageHooks}{mathtools.sty}{mathtools-hooks.4ht}
\Configure{PackageHooks}{babel.sty}{babel-sty-hooks.4ht}
\Configure{PackageHooks}{minted.sty}{minted-sty-hooks.4ht}
\Configure{PackageHooks}{graphics.sty}{graphics-hooks.4ht}
\Configure{PackageHooks}{graphbox.sty}{graphbox-hooks.4ht}
\Configure{PackageHooks}{xcolor.sty}{xcolor-hooks.4ht}
\Configure{PackageHooks}{imakeidx.sty}{imakeidx-hooks.4ht}
\Configure{PackageHooks}{fancyhdr.sty}{fancyhdr-hooks.4ht}
\Configure{PackageHooks}{exerquiz.sty}{exerquiz-hooks.4ht}
\Configure{PackageHooks}{hyperxmp.sty}{hyperxmp-hooks.4ht}
\Configure{PackageHooks}{datetime2.sty}{datetime2-hooks.4ht}


\endinput

此文件声明了应在 LaTeX 包之前加载的配置文件。可访问性的配置文件accessibility-hooks.4ht如下所示:

% accessibility-hooks.4ht (2023-11-10-15:20), generated from tex4ht-4ht.tex
% Copyright 2023 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.
\immediate\write-1{version 2023-11-10-15:20}

% redefine commands that would cause fatal error when the package is being processed
\let\:origpdfobj\pdfobj
\let\:origpdfoutput\pdfoutput
\let\pdfoutput\@undefined
\def\pdfobj reserveobjnum{}
\:AtEndOfPackage{
  \let\pdfobj\:origpdfobj
  \let\pdfoutput\:origpdfoutput
  \def\PDFStructObj#1#2{}%
}
\endinput

最后一个必需的文件是accessibility.4ht,我们可以在其中重新定义文档中使用的命令。在本例中,\alt使用的是:

% accessibility.4ht (2023-11-10-15:20), generated from tex4ht-4ht.tex
% Copyright 2023 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.
\immediate\write-1{version 2023-11-10-15:20}

\NewConfigure{accessibilityalt}{2}
\def\:tempa#1{\a:accessibilityalt #1\b:accessibilityalt}
\def\alt#1{}
\HLet\alt\:tempa

\Hinput{accessibility}
\endinput

此重新定义的版本\alt将在文档文本中打印其内容,但不会在图片中显示任何内容。这是为了防止出现其他错误。

在此处输入图片描述

相关内容