Search code examples
latex

Perform separate compilation of Latex documents


When compiling latex documents the compiler emits a lot of "object" files. This clutters the directories I'm working on and it difficults the use of VCS like SVN. When I work with C++ code I have separate directories for the code and the objects, I can run make on the source directory but the .o files go to the build directory.

Is there a proper way to perform this separate compilation with Latex documents? Can it be done by using Makefiles or by passing options to the latex compiler?

Thanks


Solution

  • You can use:

    pdflatex --output-directory=tmp file.tex
    

    and all the files will be stored in the folder tmp (pdf included).

    Because this is not an optimal solution, I made my own tool, pydflatex, that compiles the LaTeX source by stashing away the auxilliary files (using the trick above), and brings the pdf back to the current directory, so after compiling you only have file.tex and file.pdf in your directory. This plays very well with version control.