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

Nasser M. Abbasi nma at 12000.org
Sun Oct 8 12:38:11 CEST 2023

On 6/20/2023 10:21 AM, Michal Hoftich wrote:
>> If it works for you, I can add it to make4ht as a new extension, so it
>> could be then enabled from the command line.
> I've added a new extension to make4ht, copy_images. It should fix this issue.
> Best regards,
> Michal

Thanks Michal for adding copy_images,

I am trying this option now, but I do not think it is working.
If I can explain with an example:

I have this latex file


Using absolute path for image. I compile using

make4ht -ulm default -d . foo.tex "mathjax,htm,nostyle,copy_images"

Where I said the output_dir is current directory. This is what  "-d ." for.

Then added "copy_images" extension.

I see that make4ht did copy the image tree to the local directory
correctly and now I have in the current directory this new tree


But the problem is that the HTML still has the absolute path in it!

<p class='noindent'><img alt='PIC' height='273'
src='/mnt/g/public_html/my_notes/images/my_image.svg' width='272' />

So even though the image was copied to local directory, the
HTML itself still pointing the original image, and not
to the copied one.

Is one supposed to now edit the HTML and remove the first "/" from the src=
manually each time?

This is really a big problem for me. Since I have lots of images in
one central location and I need to include them from different places.
Using relative path is very hard to manage. An absolute path is
much easier to use.

If I copy an image to different place each time I need to include
it, then things will get out of sync very quickly and I will have
many copies all over the place.

Is there a way to make copy_images adjust the "src=" automatically
to new copy location?


More information about the tex4ht mailing list.