michal-h21 / make4ht

Build system for tex4ht
131 stars 15 forks source link

xr-hyper doesn't work when referencing the current file #140

Open alfredholmes opened 7 months ago

alfredholmes commented 7 months ago

The document example.tex with contents

\documentclass{article}

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

\externaldocument[example-]{example}

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

    \hyperref[example-equation]{The equation in main}.

\end{document}

compiles, but the link doesn't work.

michal-h21 commented 7 months ago

Thanks for the report. Debugging issues with Xr and Hyperref is quite tricky, so finding a solution can take some time. What is the reason to reference the current file in this way?

alfredholmes commented 7 months ago

I was trying to use this project (https://github.com/alfredholmes/TeXNotes) to quickly generate a static html website using LaTeX, just to see if it was possible.

I setup a header template (containing a title and a couple of links) that I could import into each document, but the links don't work if they reference something on the current page.

More generally, TeXNotes uses \catchfilebetweentags to allow parts of LaTeX documents to be imported to other LaTeX documents, and uses xr-hyper to allow references between files. If you import a file that references something in the current document, then the link doesn't work.

In principle I could get TeXNotes to preprocess the LaTeX documents to fix this, but I would be nicer from an application design point of view if this was handled by make4ht in the same way as pdflatex.

michal-h21 commented 6 months ago

It seems that even referencing of external files doesn't work anymore, as the previous issue produces runtime errors. Both Hyperref and Xr received updates, so there are some regressions.

alfredholmes commented 6 months ago

That's a shame. I think it would be nice to be able to generate a static html site from pages written in LaTeX using make4ht. Due to the new errors, do you have any suggestions on alternative ways to implement this rather than with the above packages?

michal-h21 commented 6 months ago

I still hope I will get it to work. I already fixed the error that I mentioned in my previous message. I will just need to find some more time to dive into this issue deeply.

u-fischer commented 2 months ago

if this was handled by make4ht in the same way as pdflatex.

just to note: this doesn't properly work in pdflatex. xr-hyper/hyperref produces a GoToR-link to an external document from such a reference:

/Subtype/Link/A<</F(test-utf8.pdf)/S/GoToR/D(equation.1.1)>>

If you are lucky your PDF viewer can handle that, but it is clearly not the same as a normal internal link.