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

Nasser M. Abbasi puszcza-hackers at gnu.org.ua
Sat Apr 23 07:23:31 CEST 2022


                 Summary: problem using tex4ht with xr-hyper when other
documents are in separate folders
                 Project: tex4ht
            Submitted by: nma123
            Submitted on: Sat Apr 23 05:23:31 2022
                Category: None
                Priority: 5 - Normal
                Severity: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any



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

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

      +------ 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

\externaldocument{chapter_1/ch1} %notice folder name included
See problem \hyperref[1]{1} below and problem \hyperref[2]{2}.

and ch1.tex which is inside folder chapter_1/


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

and ch2.tex


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

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


instead of


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


Reply to this item at:


  Message sent via/by Puszcza

More information about the tex4ht mailing list.