## tex4ht - Bugs: bug #560, problem using tex4ht with xr-hyper...

Show feedback again

You are not allowed to post comments on this tracker with your current authentification level.

## bug #560: problem using tex4ht with xr-hyper when other documents are in separate folders

 Submitted by: Nasser M. Abbasi Submitted on: Sat Apr 23 05:23:31 2022 Category: None Priority: 5 - Normal Severity: 5 - Normal Status: Fixed Privacy: Public Assigned to: None Open/Closed: Closed

Tue Apr 26 08:21:28 2022, comment #2:

I've also fixed it for the Xr package. I think we can fix this now.

Michal Hoftich <michal_h21>
Mon Apr 25 13:32:32 2022, comment #1:

Hi Nasser, thanks for the report. I've fixed this issue in the TeX4ht sources and posted answer on TeX.sx.

Michal Hoftich <michal_h21>
Sat Apr 23 05:23:31 2022, original submission:

reference and screen shots at

I am splitting my large document into smaller separate documents, where now each chapter will be compiled separately, as separate PDF file (not using \include or input, but as a separate document with its own title and \begin{document})

But I still need to have reference from a main document to the other documents to build tables and references.

So I am using xr-hyper. Which worked well. I have this MWE tree to show my current set

main.tex
|
+------ chapter_1/ch1.tex
+------ chapter_2/ch2.tex

I put each chapter in separate folder to reduce clutter. This is what my main.tex, ch1.tex and ch2.tex look like

%main.tex
\documentclass{book}
\usepackage{xr-hyper}
\usepackage{hyperref}
\externaldocument{chapter_1/ch1} %notice folder name included
\externaldocument{chapter_2/ch2}
\begin{document}
See problem \hyperref[1]{1} below and problem \hyperref[2]{2}.
\end{document}

and ch1.tex which is inside folder chapter_1/

\documentclass{book}
\usepackage{xr-hyper}
\usepackage{hyperref}

\begin{document}
\chapter{chapter 1 in document ch1.tex}
\section{some section name}
\subsection{problem 1 from some book}
\label{1}
This is problem 1
\end{document}

and ch2.tex

\documentclass{book}
\usepackage{xr-hyper}
\usepackage{hyperref}
\begin{document}

\chapter{chapter 2 in document ch2.tex}
\section{some section name}
\subsection{problem 2 from some book}
\label{2}
This is problem 2
\end{document}

Next, compiled ch1.tex,ch2.tex and finally main.tex in this order using lualatex. Now I opened main.pdf and the links there correct and work.

Next, I did the same for tex4ht. Compiled ch1.tex,ch2.tex then main.tex in this order, all using the commands

make4ht ch1.tex 'mathjax,htm'
make4ht ch2.tex 'mathjax,htm'
make4ht main.tex 'mathjax,htm'

Then opened main.htm and it shows correct output

Now here is the problem, when I click on the link, it drops the folder name from the link. The link for 1 says

ch1.htm#x1-30001.1.1

chapter_1/ch1.htm#x1-30001.1.1

So the link did not work.

By manually editing the link and adding the folder name chapter_1/ to it, then it works and opens chapter 1 page correctly.

I can fix all of this by having all separate documents (main.tex, ch1.tex and ch2.tex) in same top level folder.

But to reduce clutter, and since I have many chapters that I want to make now completely separate PDF files for each chapter (but still have cross references from main document to them), it will be much better to have each in separate folder to make it easier to manage and reduce clutter in same folder, since I need to compile each one separately now.

This looks like a bug in tex4ht, in that it drops the folder name from the reference. Or Am I doing something wrong?

TL 2021

Nasser M. Abbasi <nma123>

No files currently attached

Depends on the following items: None found

Items that depend on this one: None found

Carbon-Copy List
• -unavailable- added by michal_h21 (Posted a comment)
• -unavailable- added by nma123 (Submitted the item)
•

Do you think this task is very important?
This task has 0 encouragements so far.

Only logged-in users can vote.

Please enter the title of George Orwell's famous dystopian book (it's a date):