michal-h21 / make4ht

Build system for tex4ht
131 stars 15 forks source link

Unable to compile using xr-hyper, cleveref and \externaldocument #113

Closed alfredholmes closed 1 year ago

alfredholmes commented 1 year ago

The following simple example fails to compile with make4ht but works with pdflatex

main.tex:

\documentclass{article}

\usepackage{hyperref}
\usepackage{cleveref}

\begin{document}
\section{First Section} \label{section}
\begin{equation} \label{equation}
    \int f(x) dx
\end{equation}

\end{document}

ref.tex:

\documentclass{article}

\usepackage{amsmath}
\usepackage{xr-hyper}
\usepackage{hyperref}
\usepackage{cleveref}

\externaldocument[main-]{main}

\begin{document}

    Equation \eqref{main-equation} in \cref{main-section}.

\end{document}

It gives these errors

[ERROR]   htlatex: ./ref.tex    10   Argument of \XR:rEfLiNK has an extra }.
[ERROR]   htlatex: ./ref.tex    10   Paragraph ended before \XR:rEfLiNK was complete.
...
[ERROR]   htlatex: ./ref.tex    12   Argument of \@firstoftwo has an extra }.
[ERROR]   htlatex: ./ref.tex    12   Paragraph ended before \@firstoftwo was complete.
[ERROR]   htlatex: ./ref.tex    12   Paragraph ended before \@@cref@gettype was complete.
[ERROR]   htlatex: ./ref.tex    12   Undefined control sequence.
...

There used to be an almost identical bug with make4ht, xr-hyper and hyperref discussed here which has since been fixed.

michal-h21 commented 1 year ago

Thanks for the report. I described this issue in more details here, and updated the TeX4ht sources, so the update should be available in TeX Live soon.

alfredholmes commented 1 year ago

Great that's sorted it. Thanks for looking into this so quickly