使用 ABNT 样式的 biblatex 以及 hyperref 包并使用 make4ht 进行编译时出错

使用 ABNT 样式的 biblatex 以及 hyperref 包并使用 make4ht 进行编译时出错

abnt一个使用样式的文档biblatex,同时还包含hyperref包,导致编译时出错make4ht。出现以下错误:

[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename Line    Message
[ERROR]   htlatex: ./article.tex    21   Argument of \@secondoftwo has an extra }.
[ERROR]   htlatex: ./article.tex    21   Paragraph ended before \@secondoftwo was complete.
[ERROR]   htlatex: ./article.tex    21   Missing number, treated as zero.
[ERROR]   htlatex: ./article.tex    21   Missing = inserted for \ifnum.
[ERROR]   htlatex: ./article.tex    21   Missing number, treated as zero.

文件中.log含有以下消息:

! Argument of \@secondoftwo has an extra }.
<inserted text>
                \par
l.21 Test \cite{knuth1986}.

I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce

.tex重现此错误的示例是:

\documentclass{article}
\begin{filecontents*}[overwrite]{article.bib}
@book{knuth1986,
  address = {Reading, Mass},
  series = {Computers \& typesetting},
  title = {The {TeXbook}},
  isbn = {9780201134476 9780201134483},
  number = {A},
  publisher = {Addison-Wesley},
  author = {Knuth, Donald Ervin and Knuth, Donald Ervin},
  year = {1986},
  keywords = {TeX (Computer file), Computerized typesetting, Mathematics printing, Computer programs},
}
\end{filecontents*}
\usepackage[backend=biber,style=abnt]{biblatex}
\addbibresource{article.bib}
\usepackage{hyperref}
\begin{document}
Test \cite{knuth1986}.
%\href{https://tex.stackexchange.com/}{TeX StackExchange}
\printbibliography
\end{document}

删除选项后style=abnt,编译不会出现错误。

使用的版本:

biblatex version: 2020/12/31 3.16
hyperref version: 2020-05-15 v7.00
make4ht version: v0.3f

答案1

这是一个有点奇怪的问题,但它似乎与 TeX4ht 和 BibLaTeX 都修补了该命令有关\ifthenelse。我们需要在 中为此做出一些变通biblatex.4ht,但似乎这些变通方法在abnt样式上失败了。最后,我发现加载 Nameref 包有帮助。这是因为 Nameref\ifthenelse也会重新定义,并且此版本适用于 BibLaTeX 和 TeX4ht。

因此,您可以尝试这个版本biblatex-hooks.4ht

% biblatex-hooks.4ht (2020-10-17-13:53), 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 2020-10-17-13:53}

\: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}

这是早期钩子文件,这意味着它会在您使用时同时加载\usepackage{biblatex}。通常.4ht文件在文档前言的末尾进行处理,此时它已经太晚了。

结果如下:

在此处输入图片描述

相关内容