tonicebrian
tonicebrian

Reputation: 4795

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

Upvotes: 5

Views: 1781

Answers (4)

Charles Stewart
Charles Stewart

Reputation: 11837

Two options, besides the above.

  1. Use Lyx: it looks after the separate files. I think it copies the Latex file over to its own private directory and runs latex on it. In any case, nothing is created in the current directory.
  2. Use a makefile or one of the special Latex make programs, and have your regular targets run make clean.

Upvotes: 0

Olivier Verdier
Olivier Verdier

Reputation: 49146

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.

Upvotes: 4

midtiby
midtiby

Reputation: 15106

Latex generates the temporary files in the directory where the main document is located. If you want the contents to be placed in a different location, try with a main file like below.

\documentclass{article}
\input{src/maindocument.tex}

Using this method, you could maintain a directory structure like below

/
    main.tex
    /src
         maindocument.tex

Upvotes: 0

Alex Martelli
Alex Martelli

Reputation: 881595

I can't help much with LaTeX (having last user it seriously 20 years ago;-), but for Subversion, you should read up on the svn:ignore property -- it makes it easy to ignore files with extensions you do not want to version (object files, bytecode files as Python can often put in the same directory as the sources, backup files some text editors use, &c).

Upvotes: 2

Related Questions