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

Nasser M. Abbasi nma at 12000.org
Sat May 28 15:33:36 CEST 2016


When building with -d <folder_name>, as in

      make4ht foo.tex -d some_folder

----------------------------------
make4ht [options] filename ["tex4ht.sty op." "tex4ht op." "t4ht op" "latex op"]
     -d,--output-dir (default nil)  Output directory
----------------------------------------

(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.

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.

Here is MWE, say one is in  /home/A/ folder:

-------------------------------
\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\frac{\sin(x)}{2}$
\end{document}
----------------------------------

compile with

make4ht foo.tex  -d foo

Now there will copy of foo0x.png and foo.htm and foo.css
in both A/* (where the latex file was) and also in A/foo/*

Here is an abbreviated  log:
------------------------------
....
Make4ht: dvisvgm -v1 -n -c 1.15,1.15 -p 1- foo.idv
Make4ht: tex4ht  -cunihtf -utf8 foo can be executed only 1x
Make4ht: t4ht  -p foo.dvi can be executed only 1x
mv foo.svg fo0x.svg
outdir: foo/
Copy: cp foo.htm foo
outdir: foo/
Copy: cp foo.css foo
tmp file
outdir: foo/
Copy: cp fo0x.svg foo
.....
---------------------------------------

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 know the compile has to be in the same folder as the .tex
file, due to the relative paths inside the latex file in places
as as \href or \includegraphics etc..., so the latex file can not
be moved to destination directory to do the build there,
as it will break things.

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.
  
May be it is possible to send the output, during the compile,
directly to the destination folder, to eliminate the copy step?

Now my source tree is full of 10's of thousands of duplicate
files.

--Nasser





More information about the tex4ht mailing list