[tex4ht] [bug #561] tex4ht with xr-hyper does not work when splitting other document.

Nasser M. Abbasi nma at 12000.org
Sat May 14 10:13:58 CEST 2022

On 5/13/2022 7:58 PM, Nasser M. Abbasi wrote:

> Not only that, it had the good side effect of making your eralier
> changes in xrhyper-hooks.4ht now also work when splitting the external document!

I am sorry, but I was wrong.  I only checked one external document. But when
I added a second one, I found it does not work. Links to the first one are lost.

But I spend more time looking at this and I found the cause of the bug
in tex4ht which makes xr-hyper not work the same way with pdf.

This for me is a deal breaker. Without this working correctly, I can't
compile each chapter separately, since I need the references to automatically
work across documents. I could not add all references needed by hand.

I have this set up: main.tex in one folder, and ch1.tex and ch2.tex each
in separate folders.  main.tex has a link to ch1.tex and to ch2.tex.

Here is the problem I found. When I do this in main.tex


See problem \hyperref[1]{1} in chapter 1

See problem \hyperref[2]{2} in chapter 2


then ONLY the last \externaldocument is used.

The first one is ignored. So tex4ht implementation of \externaldocument
seems faulty. It only accept one external document, and it  is the last one.

When I change the order, the links now go the last one listed.

In pdf, this is not the case. Both externaldocument are used.

Hopefully this finding will make it easier to locate where the problem is
and fix it tex4ht? If not, I will just have to continue to build the whole
document each time even if I make change in only one chapter.

I include a zip file which contains all the files and the tree.

The commands I used are

cd CHAPTERS/chapter_1
make4ht  -ulm default  -a debug ch1.tex 'mathjax,htm,4,cut-fullname'
cd ../chapter_2
make4ht  -ulm default  -a debug ch2.tex 'mathjax,htm,4,cut-fullname'
cd ../..
make4ht  -ulm default  -a debug main.tex 'mathjax,htm,cut-fullname'

I am using the new cut-fullname option thanks to Michal just added,
which might not yet be in tex4ht but can be replaced by using this
.cfg from


\def\fx:pt#1xxx!*?: {%
    \expandafter\ifx \csname big:#1:\endcsname\relax
          \expandafter\gHAssign\csname big:#1:\endcsname  0  \fi
    \expandafter\gHAdvance\csname big:#1:\endcsname  1
    \edef\big:fn{#1\csname big:#1:\endcsname}}

the zip file is at



More information about the tex4ht mailing list.