[tex4ht] About the duplicate files when building with tex4ht using -d option

Michal Hoftich michal.h21 at gmail.com
Sat May 28 18:23:00 CEST 2016

Hi Nasser,

Quoting Nasser M. Abbasi (2016-05-28 15:33:36)
> (or using htlatex), what happens is this: all the html files
> and the small image files (one for each math expression) are first
> generated in the current folder (where the latex file is), then at
> the end they are copied to the destination folder.

Yes, this is the default behaviour. 

> So one ends up with 1000's of duplicate small files
> (.htm and many .png or .svg, which are used for the math) in
> two places.
> I was wondering if there could be a way to design the compile
> so to eliminate this duplication of files when using -d option?

I've changed the behaviour of make4ht, check the Github repo. It in fact
uses OS commands to copy files (cp on Unix, copy on Windows), so I've
just replaced it with mv, resp move. Could you please test it on

Regarding htlatex, you can modify the tex4ht.env file: 

Mmv %%1 %%2%%3                                                                                                                                        
Cmv %%1 %%2%3"             


Mmv %%1 %%2%%3                                                                                                                                        
Cmv %%1 "%%2/%%1"             

(this is Unix version, it will be different for Windows). Beware that
the output directory must exist, make4ht will create it automatically.

> It is very hard to clean all these files automatically in makefiles
> after the build, since one can easily delete wrong files by mistake
> and I am not sure which files I should be deleting also.

You can grep the .lg file for output files.
Best regards,

More information about the tex4ht mailing list