tex4ht:hyperref 和 cleveref 之间的冲突

tex4ht:hyperref 和 cleveref 之间的冲突

梅威瑟:

\documentclass{amsart}
\usepackage{hyperref}
\usepackage{cleveref}

\newtheorem{theorem}{Theorem}

\begin{document}

\begin{theorem}
  \label{test}
  This is a theorem.
\end{theorem}

Look at \Cref{test}.

\end{document}

使用编译时make4ht出现错误

[ERROR]   htlatex: ./test.tex   14   Argument of \@fourthoffive has an extra }.
[ERROR]   htlatex: ./test.tex   14   Paragraph ended before \@fourthoffive was complete.
[ERROR]   htlatex: ./test.tex   14   Argument of \@fifthoffive has an extra }.
[ERROR]   htlatex: ./test.tex   14   Paragraph ended before \@fifthoffive was complete.
[ERROR]   htlatex: ./test.tex   14   Paragraph ended before \hyper@readexternallink was complete.
[ERROR]   htlatex: ./test.tex   14   LaTeX Error: There's no line here to end.

一种解决方法是删除\usepackage{hyperref}它,这似乎不会影响html输出。但是,我想知道为什么它们在 tex4ht 下会发生冲突,以及更好的解决方案。

答案1

这是由另一个问题的修复引起的 -Hyperref 和 Biblatex 之间的冲突。如果您不使用 Biblatex,您可以使用此版本的重新引入原始代码cleveref-hooks.4ht

% cleveref-hooks.4ht (2021-06-30-14:33), generated from tex4ht-4ht.tex
% Copyright 2020-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.
\immediate\write-1{version 2021-06-30-14:33}

\let\HyOrg@addtoreset\@addtoreset
% fixes for \refstepcounter
\let\orig:refstepcounter\refstepcounter
\let\orig:@thm\@thm
\:AtEndOfPackage{%
\let\refstepcounter\orig:refstepcounter
\let\@thm\orig:@thm
}

\RequirePackage{nameref}

结果如下:

在此处输入图片描述

目前,我不知道适用于所有软件包的正确解决方案是什么。所以这只是一个临时解决方案。

相关内容