3

I'm trying to run pdflatex on a specific file stored in ~/path/template.tex, now I also want to have the output be in the same path. Note that I'm currently working in another path (Not the root).

So I'm currently in the directory ~/workspace/ and issue the following command:

pdflatex -output-directory=~/path/ ~/path/template.tex

However this is giving me the following error:

! I can't write on file `template.log'.
(Press Enter to retry, or Control-D to exit; default file extension is `.log')
Please type another transcript file name: 
! Emergency stop
!  ==> Fatal error occurred, no output PDF file produced!

Does anybody know how to fix this issue?

I saw some people write, that it could be because of another process using pdflatex, or because the template.log is already being written to. But this does not seem to be the case here, I have checked for other processes being run. Also note that it can find the template.tex, and more importantly I can run pdflatex from the root of my computer without issues.

  • This is is a security issue: you don't normally allow TeX to write outside of the working directory. – Joseph Wright Sep 8 '16 at 9:59
  • Then why is there a out-directory argument? Also this works when I'm in the root of my system (And not actually inside the directory I want to output). However it doesn't work from my workspace. – cenh Sep 8 '16 at 10:06
  • (cd ../path;pdflatex template) – egreg Sep 8 '16 at 10:13
5

Under normal settings, TeX binaries don't allow writing files specified with absolute paths or above the working directory. The -output-dir option allows to specify a directory below the working one.

This is for security; it can be changed, but I'd avoid doing it.

A standard method with Unix shells is

(cd ~/path ; pdflatex template)
  • Sadly the issue is, that I want to automatically generate the pdfs via a Perl script. I guess I pretty much have to put the script and the template/output into the same directory. Anyways thanks for the help. – cenh Sep 8 '16 at 10:43
  • @cenh What's preventing you from using the same method in the script? – egreg Sep 8 '16 at 10:58
  • I can, but I prefer not to change the working directory for part of the script (It does more than generate pdfs). – cenh Sep 8 '16 at 12:18

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.