[tex4ht] make output of tex4ht go to sub-folder without leaving temporary and intermediate files in the current folder?

Nasser M. Abbasi nma at 12000.org
Mon Feb 11 19:16:14 CET 2013

On 2/11/2013 7:21 AM, Radhakrishnan CV wrote:
> On Mon, Feb 11, 2013 at 5:23 PM, Nasser M. Abbasi <nma at 12000.org> wrote:
>> On 2/11/2013 5:46 AM, Radhakrishnan CV wrote:
>>   True, aux and other scratch files still remain in your working directory.
>>> In order to move all files to your target directory, you need to provide
>>> \Needs{} directive in your source document. For example, I will modify
>>> your
>>> example document to the following manner:
>>> --- foo-changed.tex ----------
>>> \documentclass{article}%
>>> \usepackage{graphics}
>>> \begin{document}
>>> \includegraphics{a.png}
>>> \Needs{"find ./ -maxdepth 1 -mindepth 1 -type f -not -name \jobname.tex
>>> -exec mv '{}' A \string\; "}
>>> \end{document}
>>> -------------------------
>>> \Needs{...} directive is operating system dependent. The one I have given
>>> above is for bash in linux or unix like operating systems.  You might
>>> provide the one fit for your OS.
>> Thanks, that is useful. But is it possible to put this \Needs
>> command in my .cfg file somehow? The reason is, I have one common
>> .cfg file, and if this can be used in .cfg file, then I do not
>> have to edit all my .tex file and add this command to each. I
>> have 1,000's of small .tex files, and they all use the same .cfg file.
> That is quite possible. You might add the following line in your *.cfg:
>   \AtEndDocument{\Needs{...}}
> Let that be the last directive in \jobname.lg file which is read by t4ht
> binary.
> Best regards

I am sorry, but I am not following you. Your description is short
and assumes knowledge of the user. It will really help if you
could give a tiny/minimal but complete example of how all this
is supposed to work.

You mention that I need to put something at end of \jobname.lg,
which I do not understand. Do I need to put the command


in the .cfg file or in this .lg file?

I only know about myconfig.cfg. Also, the command itself

\Needs{"find ./ -maxdepth 1 -mindepth 1 -type f -not
-name \jobname.tex -exec mv '{}' A \string\; "}

seems to have hardcoded values in it. What is 'A' above? This
folder will be different from one .tex file to another, I can't
have it hardcoded, as I have large tree and different names for
latex files all over. I send output of each latex file to a
sub-folder by the same name as the latex file.

Also the name `\jobname.tex` in the command, should that also a function
of the latex file itself?

When I run this small example (no config file for now,
just wanted to see how it work)

------------- t15.tex---------------

\Needs{"find ./ -maxdepth 1 -mindepth 1 -type f -not -name \jobname.tex
-exec mv '{}' A \string\; "}


htlatex foo.tex

I get

Execute script `t15.lg'
t4ht.c (2009-01-31-07:34 kpathsea)
t4ht -f/t15.tex
Entering t15.lg
Entering t15.css
Entering t15.tmp
System call: find ./ -maxdepth 1 -mindepth 1 -type f -not
-name t15.tex -exec mv '{}' A \;

mv: cannot move `./t15.lg' to `A/t15.lg': Text file busy

System return: 0

In addition, this command removed all other .tex files in
the same folder to the folder `A` ! which is not what I want.

The folder `A` should really be the same as the latex file.
So in this example, it should be `t15/`

I really think the best solution should be to make


which currently works, finish the job right, and move
all these scratch and temp files to the `Folder` above
as well. That would be the best solution to this problem.

Thank you,

More information about the tex4ht mailing list