# tex4ht: conflict between hyperref and cleveref

MWE:

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


Compiling with make4ht, I get errors

[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   LaTeX Error: There's no line here to end.


A workaround is to remove \usepackage{hyperref} which does not seem to affect the html output. However, I wonder why they are conflict under tex4ht and a better solution for that.

This is caused by fix for another issue - clashes between Hyperref and Biblatex. If you don't use Biblatex, you can reintroduce the original code using this version of 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
%   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}

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

\RequirePackage{nameref}


This is the result:

At this moment, I don't know what is the correct solution that will work across all packages. So this is just a temporary fix.

• Is there any reason to import the hyperref package for tex4ht? Seemingly, even when it is not imported, the links are compiled into hyperlinks by default. Nov 23, 2021 at 11:53
• @Yai0Phah in general, I think you should import hyperref with TeX4ht only if you use commands that it provides (like \href). Otherwise, it isn't really useful. Nov 23, 2021 at 12:42
• You are correct. \hyperref is defined in this package. Nov 25, 2021 at 10:38