使用 make4ht 进行编译以及使用 biblatex 和 geometry 时的错误消息

使用 make4ht 进行编译以及使用 biblatex 和 geometry 时的错误消息

使用biblatexgeometry会导致编译时出错make4ht。示例文档为:

\documentclass{article}
\usepackage{biblatex}
\usepackage{geometry}
\begin{document}
Test
\end{document}

使用make4ht -x-l选项进行编译会给出以下错误消息:

[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename     Line    Message
[ERROR]   htlatex: ./testbibgeom.tex    4        
File ended while scanning use of \@for.

并且该.log文件具有:

Runaway argument?
\CurrentOption: =\@classoptionslist \do {\@ifundefined {KV@Gm@\CurrentOption \ETC.
! File ended while scanning use of \@for.
<inserted text>
\parl.4 \begin
        {document}
I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.

尽管有这些错误信息,但.html看起来还不错。

答案1

这个问题似乎是由我的修复另一个问题。当您使用 BibLaTeX 时,TeX4ht 会加载文件biblatex-hooks.4ht

\:AtEndOfPackage{%
  \def\blx@mknoautolang{%
    \blx@lbxinput{\blx@languagename}%
    {}{}%
  }%
  \def\blx@lbxinput@iii#1#2{%
  \global\csundef{blx@lng@#2}%
  \:IfFileExists{#1.lbx}
    {\blx@lbxinput@iv{#2}{#1}{language '#2' -> '#1'}}
    {\ifcsdef{blx@suffmaptried@#2}
      {}
      {\blx@warning@noline{%
          File '#1.lbx' not found!\MessageBreak
          Ignoring mapping '#2' -> '#1'}%
       \global\cslet{blx@suffmaptried@#2}\@empty}%
     \blx@lbxinput@iv{#2}{#2}{language '#2'}}}

}

\RequirePackage{nameref}

重要的是

\RequirePackage{nameref}

目前,一些 catcode 发生了变化(最明显的是:字符可以成为命令名称的一部分)。我怀疑这会导致 Nameref 中的一些宏执行错误。

我们仍然需要在 BibLaTeX 之前加载 Nameref,但需要使用包的常用 catcode 来加载。我们可以借助新的 LaTeX 钩子机制来实现这一点:

\AddToHook{package/before/biblatex}{\RequirePackage{nameref}}

完整的biblatex-hooks.4ht现在看起来像这样:

% biblatex-hooks.4ht (2021-10-22-14:44), generated from tex4ht-4ht.tex
% Copyright 2020 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 2021-10-22-14:44}

\:AtEndOfPackage{%
  \def\blx@mknoautolang{%
    \blx@lbxinput{\blx@languagename}%
    {}{}%
  }%
  \def\blx@lbxinput@iii#1#2{%
  \global\csundef{blx@lng@#2}%
  \:IfFileExists{#1.lbx}
    {\blx@lbxinput@iv{#2}{#1}{language '#2' -> '#1'}}
    {\ifcsdef{blx@suffmaptried@#2}
      {}
      {\blx@warning@noline{%
          File '#1.lbx' not found!\MessageBreak
          Ignoring mapping '#2' -> '#1'}%
       \global\cslet{blx@suffmaptried@#2}\@empty}%
     \blx@lbxinput@iv{#2}{#2}{language '#2'}}}

}
\AddToHook{package/before/biblatex}{\RequirePackage{nameref}}

您的示例现在应该可以正确编译了。

相关内容