13

I have a directory structure like this:

project
   pdf
   src

My source file is located in src, and I'm trying to run pdflatex from the project directory using a command like this:

pdflatex -halt-on-error src/foo.tex -output-directory pdf

The compilation works, but foo.pdf ends up in project, rather than in pdf, which is obviously not what I want. I would assume that -output-directory would take care of this, but it doesn't seem to. What am I missing?

  • 6
    I think the order is important here. The command is: latex [options] [file] [commands]. But -output-directory is not a command; it is an option. – jon Sep 23 '15 at 4:17
  • @jon Thanks - that actually solved it. – Koz Ross Sep 23 '15 at 12:21
17

From the trusty man page for tex and pdftex (the command name):

tex [options] [&format] [file|\commands]

So the order is important: options go before the filename. Therefore, you should use:

pdflatex -halt-on-error -output-directory pdf src/foo.tex
  • Arg! I spent so much time on finding this! Thank you so much :) – ingomueller.net Feb 5 '17 at 13:29
  • @ingomueller.net -- Haha, always the worst! Glad you found it eventually! – jon Feb 5 '17 at 22:37
0

I tried jon's solution, but I got an error regarding where the .log file to write to, so I found this:

pdflatex -aux-directory=<DIRECTORY OF LOG & AUX FILES> -output-directory=<DIRECTORY OF OUTPUT PDF FILE> FILENAME.tex

Worked like a charm!

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.