Compile LaTeX source without the trash
When compiling LaTeX documents pdflatex generates .aux and .log files in the process of generating the output .pdf. These auxiliary files are only mildly annoying, but when writing a LaTeX document in a Dropbox-synced directory, those files are synchronized every time you compile — what was mildly annoying becomes wasteful garbage. Since currently Dropbox does not support file exclusion, you’re stuck with all that clutter.
On Windows platforms the LaTeX implementation MiKTeX supports an option on pdflatex called —aux-directory so’s you can divert all those annoying garbage files somewhere else outside of Dropbox’s control. On OS X platforms the common MacTeX implementation does not, however, support this option. A travesty!
As a workaround to this situation, I’ve written a rudimentary (read: sloppy) Python script that will simply divert your current working directory somewhere else, compile the source file, and copy only the output pdf back to your original location. It should also pass any options straight to the pdflatex program. I can’t make any promises as to its robustness in the presence of failures and weird cases, but I can attest to its efficacy in Dropbox’ed directories.
Get the script here: http://www.mpi-sws.org/~skilpat/files/pdflatex-noaux.py. Afterwards, I recommend putting an alias in your ~/.bash_profile to redirect shell calls to pdflatex to the script: alias pdflatex=”/path/to/pdflatex-noaux.py”
***
If you use TextMate to write your LaTeX documents, then there is more work to be done. From what I can tell, there’s no feature currently implemented in the LaTeX bundle that will send auxiliary files elsewhere. TextMate will indeed use pdflatex to compile, but it doesn’t seem to do so in a way that’s conducive to the tomfoolery of the script. Here’s how I got a minimal, operational setup:
Go to the Bundle Editor and add a new command under LaTeX. Set the input to “None”, the Output to “Show as HTML”, the activation key to Cmd+R (and remove the key from the old Typeset command), and Scope Selector to “text.tex”. For the body of the command, use
echo "<html><body><pre style=\"font-size:11px;font-family: Monaco,monospace;\">" cd $TM_PROJECT_DIRECTORY /path/to/pdflatex-noaux.py $TM_FILEPATH echo "</pre></body></html>"
Now Cmd+R will compile the document with the script and put only the resulting pdf in this directory. For monitoring the changes to your pdf as you work on it, I recommend using Skim to view the pdf; Skim can automatically refresh the view whenever the file is updated.