[tex4ht] How to \includegraphics using absolute path with tex4ht?

Nasser M. Abbasi nma at 12000.org
Sat Jun 17 09:51:19 CEST 2023


I have to use an absolute path for my graphics, because the
code is generated by a program, and the resulting index.tex can
be in different locations in the tree, while the image location
is fixed at once place at root of the tree.

So hard to make it relative to each generated index.tex since the tree
has many branches and different depths.

This causes no problem with pdf generation, since the image is put
inside the pdf file during compile time. So when viewing the
completed PDF, the image is inside the PDF already.

But with HTML, a reference is put in the web page. Hence when
loading the page from different places, it can't find
the image, since HTML will have something like this

<img alt='pict' src='/mnt/g/public_html/images/image.svg' ' />

And it can't find it of course. I compile on Linux, view on windows. And on
the server this path makes no sense.  Even if I use

     src='/images/image.svg'

i.e. relative to public_html/, it still does not see it on windows.

How can one then use absolute path for an image when compiling to HTML?

Normally, I have the image in a folder inside the same folder I am
building the HTML, so it was never a problem. So the HTML would
have this

<img alt='pict' src='images/image.svg' style='width:13.876em;' />

And now it can find the image, since the images/ folder is in same folder
where the web page is. But now I want to use images at different location
but use absolute path for the image when compiling.

Any suggestions or workaround this? I really do not want to make copies
of the image in 100 different locations to workaround this.

Thanks
--Nasser


More information about the tex4ht mailing list.