The setup is simple. I have a file report.tex which includes an image from a folder. I send the output of htlatex to a separate directory. htlatex copies all images and HTML to that directory. The problem though, now all the links in the HTML are broken, since the links are generated relative to original location of report.tex and not to where the HTML now lives.

In pictures, I have this

 report.tex ...\includegraphics{e1/image.png}
   |                          |
   /e1/image.png             /report/
                               report.htm ....<img src="e1/image.png"

One can see the problem. The HTML is using src= thinking it was in the original location of the .tex file. So, I end up editing the HTML files fixing links by adding "../" to each image src link or by removing "e1/" since the image was copied!

I searched and was not able to find an option to fix this. Does anyone know of a solution to this?

Here is minimal working example:


Here is the command used

  mkdir report; htlatex report.tex "htm" "" -dreport

and now looking in the folder report/report.htm shows the problem. The image does not show up without manually fixing the links.

Doing this works:

  htlatex report.tex "htm"

now the report.htm shows the image ok as expected. But I want all the output to go to separate folder.

I am using the TeXlive 2012 Debian package.


This is because of bug in t4ht. This is application which converts images, run system commands, generates css and copies files. For file copying, it uses system copy command, so in your example it is something like:

cp e1/image.png outdir/.


copy e1/image.png outdir/.

on windows.

This command doesn't create subdirectories in output dir, so all generated files are saved directly in this dir.

You can try my new project, make4ht, which tries to generate correct subdirs:

make4ht -d outdir -u report.tex

you have to put scripts to your local texmf tree:


and make symbolic link to texmf/scripts/lua/make4ht/make4ht or create shell script which run this file.

  • thanks for your build system. Using this command worked make4ht foo.tex "nma.cfg,htm,charset=utf-8" " -cunihtf -utf8" -d foo (notice no quotes at the end around the destination folder) see github.com/michal-h21/make4ht for more information.
    – Nasser
    Jun 9 '13 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.