I am considering using the command line option -output-directory=<some/path> so that the temporary files do not clog my working directory but are also available for subsequent builds. This will also eliminate a lot of unnecessary Dropbox activity.

However, I also produce some temporary files of my own, so would like to be able to access what the output-directory was specified as on the command line.

So, in the MWE below, how do I set the value of the macro \OuptutDirectory so that I can correctly determine the names of my temporary files?


Related Question:



\def\OuptutDirectory{????}% <--- How do I determine this?


    My temp file is \MyTempFile.
  • 1
    I don't think there's a variable in pdftex that keeps the value of the output directory. – egreg Feb 20 '16 at 11:42

I set up, in a working directory, the file a.tex containing




I created a temp subdirectory and called

pdftex -output-dir=temp a

and the temp.txt file was created in the temp directory:

> ls -R .
a.tex   temp/

a.log       temp.txt

There's no variable that can be accessed from within pdftex that holds the output directory path, as far as I know.

Of course you can emulate it by passing the definition of \OutputDirectory from the command line:

pdftex -output-dir=temp "\def\OutputDirectory{./temp}\input a"
| improve this answer | |
  • So that explains why some of my temp files were in the temp directory and not others -- I was using \immediate\write18 and getting the shell to create some related files. I guess I'lll use the "emulate" solution... As always, thanks - much appreciated. – Peter Grill Feb 20 '16 at 12:23
  • The last line is a gem luring the newbies into the programming side of TeX. Thanks, @egreg ! – Loves Probability Mar 20 '19 at 23:25
  • @LovesProbability Even better: if you define an environment variable TEMPDIR, you can call pdftex -output-dir=$TEMPDIR "\def\OutputDirectory{./$TEMPDIR}\input a", so this is scriptable. – egreg Mar 20 '19 at 23:36

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.